/* Generated by Cython 0.29.21 */

#define PY_SSIZE_T_CLEAN
#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 < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_21"
#define CYTHON_HEX_VERSION 0x001D15F0
#define CYTHON_FUTURE_DIVISION 0
#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
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#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_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #ifndef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#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
#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
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif 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

#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #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"
#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #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)
#endif
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #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
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#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_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #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)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
  #endif
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #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_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #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]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#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)
#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))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? 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 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#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
#ifndef PyObject_Unicode
  #define PyObject_Unicode             PyObject_Str
#endif
#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
#if PY_VERSION_HEX >= 0x030900A4
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#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) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif

#define __PYX_MARK_ERR_POS(f_index, lineno) \
    { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
    { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }

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

#define __PYX_HAVE__GPy__models__state_space_cython
#define __PYX_HAVE_API__GPy__models__state_space_cython
/* Early includes */
#include <string.h>
#include <stdio.h>
#include "numpy/arrayobject.h"
#include "numpy/ndarrayobject.h"
#include "numpy/ndarraytypes.h"
#include "numpy/arrayscalars.h"
#include "numpy/ufuncobject.h"

    /* NumPy API declarations from "numpy/__init__.pxd" */
    
#include "numpy/npy_math.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const 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_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#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 int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const 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_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
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);
}
#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_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#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
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(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*) "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) + 1);
    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 CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

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

/* Header.proto */
#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[] = {
  "GPy/models/state_space_cython.pyx",
  "stringsource",
  "__init__.pxd",
  "type.pxd",
};
/* BufferFormatStructs.proto */
#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;


/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":690
 * # 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":691
 * 
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":692
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":693
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":697
 * #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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":698
 * 
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":699
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":700
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":704
 * #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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":705
 * 
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":714
 * # 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":715
 * # 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":716
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":718
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":719
 * 
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 */
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":720
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":722
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uintp      uintp_t
 * 
 */
typedef npy_intp __pyx_t_5numpy_intp_t;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":723
 * 
 * ctypedef npy_intp       intp_t
 * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_double     float_t
 */
typedef npy_uintp __pyx_t_5numpy_uintp_t;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":725
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":726
 * 
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longdouble longdouble_t
 * 
 */
typedef npy_double __pyx_t_5numpy_double_t;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":727
 * 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;

/* "GPy/models/state_space_cython.pyx":17
 * DTYPE_int = np.int64
 * 
 * ctypedef np.float64_t DTYPE_t             # <<<<<<<<<<<<<<
 * ctypedef np.int64_t DTYPE_int_t
 * 
 */
typedef __pyx_t_5numpy_float64_t __pyx_t_3GPy_6models_18state_space_cython_DTYPE_t;

/* "GPy/models/state_space_cython.pyx":18
 * 
 * ctypedef np.float64_t DTYPE_t
 * ctypedef np.int64_t DTYPE_int_t             # <<<<<<<<<<<<<<
 * 
 * # Template class for dynamic callables
 */
typedef __pyx_t_5numpy_int64_t __pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t;
/* Declarations.proto */
#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
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);

/* Declarations.proto */
#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
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);


/*--- Type declarations ---*/
struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython;
struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython;
struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython;
struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython;
struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython;
struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython;
struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":729
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":730
 * 
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
 * ctypedef npy_clongdouble clongdouble_t
 * 
 */
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":731
 * 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;

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":733
 * 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_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset;
struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset;
struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset;
struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset;
struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_inverse;

/* "GPy/models/state_space_cython.pyx":40
 *         raise NotImplemented("(cython) dQk is not implemented!")
 * 
 *     cpdef reset(self, bint compute_derivatives = False):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) reset is not implemented!")
 * 
 */
struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset {
  int __pyx_n;
  int compute_derivatives;
};

/* "GPy/models/state_space_cython.pyx":63
 *         raise NotImplemented("(cython) dQk is not implemented!")
 * 
 *     cpdef reset(self,compute_derivatives = False):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) reset is not implemented!")
 * 
 */
struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset {
  int __pyx_n;
  PyObject *compute_derivatives;
};

/* "GPy/models/state_space_cython.pyx":365
 * 
 * 
 *     cpdef reset(self, bint compute_derivatives=False):             # <<<<<<<<<<<<<<
 *         """
 *         For reusing this object e.g. in smoother computation. It makes sence
 */
struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset {
  int __pyx_n;
  int compute_derivatives;
};

/* "GPy/models/state_space_cython.pyx":446
 *             return np.dot(A, m) # default dynamic model
 * 
 *         cpdef reset(self, bint compute_derivatives=False):             # <<<<<<<<<<<<<<
 *             """
 *             For reusing this object e.g. in smoother computation. It makes sence
 */
struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset {
  int __pyx_n;
  int compute_derivatives;
};

/* "GPy/models/state_space_cython.pyx":501
 * 
 * 
 *         cpdef Q_inverse(self, int k, float jitter=0.0):             # <<<<<<<<<<<<<<
 *             """
 *             Square root of the noise matrix Q
 */
struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_inverse {
  int __pyx_n;
  float jitter;
};

/* "GPy/models/state_space_cython.pyx":21
 * 
 * # Template class for dynamic callables
 * cdef class Dynamic_Callables_Cython:             # <<<<<<<<<<<<<<
 *     cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A):
 *         raise NotImplemented("(cython) f_a is not implemented!")
 */
struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython {
  PyObject_HEAD
  struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_vtab;
};


/* "GPy/models/state_space_cython.pyx":44
 * 
 * # Template class for measurement callables
 * cdef class Measurement_Callables_Cython:             # <<<<<<<<<<<<<<
 *     cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk):
 *         raise NotImplemented("(cython) f_a is not implemented!")
 */
struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython {
  PyObject_HEAD
  struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_vtab;
};


/* "GPy/models/state_space_cython.pyx":66
 *         raise NotImplemented("(cython) reset is not implemented!")
 * 
 * cdef class R_handling_Cython(Measurement_Callables_Cython):             # <<<<<<<<<<<<<<
 *     """
 *     The calss handles noise matrix R.
 */
struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython __pyx_base;
  PyArrayObject *R;
  PyArrayObject *index;
  int R_time_var_index;
  PyArrayObject *dR;
  int svd_each_time;
  PyObject *R_square_root;
};


/* "GPy/models/state_space_cython.pyx":165
 * 
 * 
 * cdef class Std_Measurement_Callables_Cython(R_handling_Cython):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython {
  struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython __pyx_base;
  PyArrayObject *H;
  int H_time_var_index;
  PyArrayObject *dH;
};


/* "GPy/models/state_space_cython.pyx":212
 * 
 * 
 * cdef class Q_handling_Cython(Dynamic_Callables_Cython):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython __pyx_base;
  PyArrayObject *Q;
  PyArrayObject *index;
  int Q_time_var_index;
  PyArrayObject *dQ;
  PyObject *Q_square_root;
  int svd_each_time;
};


/* "GPy/models/state_space_cython.pyx":318
 *         return square_root
 * 
 * cdef class Std_Dynamic_Callables_Cython(Q_handling_Cython):             # <<<<<<<<<<<<<<
 *     cdef:
 *         np.ndarray A
 */
struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython __pyx_base;
  PyArrayObject *A;
  int A_time_var_index;
  PyArrayObject *dA;
};


/* "GPy/models/state_space_cython.pyx":373
 *         return self
 * 
 * cdef class AQcompute_batch_Cython(Q_handling_Cython):             # <<<<<<<<<<<<<<
 *         """
 *         Class for calculating matrices A, Q, dA, dQ of the discrete Kalman Filter
 */
struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython __pyx_base;
  PyArrayObject *As;
  PyArrayObject *Qs;
  PyArrayObject *dAs;
  PyArrayObject *dQs;
  PyArrayObject *reconstruct_indices;
  PyObject *Q_svd_dict;
  int last_k;
};



/* "GPy/models/state_space_cython.pyx":21
 * 
 * # Template class for dynamic callables
 * cdef class Dynamic_Callables_Cython:             # <<<<<<<<<<<<<<
 *     cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A):
 *         raise NotImplemented("(cython) f_a is not implemented!")
 */

struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython {
  PyObject *(*f_a)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch);
  PyObject *(*Ak)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch);
  PyObject *(*Qk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch);
  PyObject *(*Q_srk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch);
  PyObject *(*dAk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch);
  PyObject *(*dQk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch);
  PyObject *(*reset)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args);
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython;


/* "GPy/models/state_space_cython.pyx":44
 * 
 * # Template class for measurement callables
 * cdef class Measurement_Callables_Cython:             # <<<<<<<<<<<<<<
 *     cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk):
 *         raise NotImplemented("(cython) f_a is not implemented!")
 */

struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython {
  PyObject *(*f_h)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch);
  PyObject *(*Hk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch);
  PyObject *(*Rk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch);
  PyObject *(*R_isrk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch);
  PyObject *(*dHk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch);
  PyObject *(*dRk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch);
  PyObject *(*reset)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset *__pyx_optional_args);
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython;


/* "GPy/models/state_space_cython.pyx":66
 *         raise NotImplemented("(cython) reset is not implemented!")
 * 
 * cdef class R_handling_Cython(Measurement_Callables_Cython):             # <<<<<<<<<<<<<<
 *     """
 *     The calss handles noise matrix R.
 */

struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_R_handling_Cython {
  struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython __pyx_base;
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_R_handling_Cython;


/* "GPy/models/state_space_cython.pyx":165
 * 
 * 
 * cdef class Std_Measurement_Callables_Cython(R_handling_Cython):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython {
  struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_R_handling_Cython __pyx_base;
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython;


/* "GPy/models/state_space_cython.pyx":212
 * 
 * 
 * cdef class Q_handling_Cython(Dynamic_Callables_Cython):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Q_handling_Cython {
  struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython __pyx_base;
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython;


/* "GPy/models/state_space_cython.pyx":318
 *         return square_root
 * 
 * cdef class Std_Dynamic_Callables_Cython(Q_handling_Cython):             # <<<<<<<<<<<<<<
 *     cdef:
 *         np.ndarray A
 */

struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython {
  struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Q_handling_Cython __pyx_base;
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython;


/* "GPy/models/state_space_cython.pyx":373
 *         return self
 * 
 * cdef class AQcompute_batch_Cython(Q_handling_Cython):             # <<<<<<<<<<<<<<
 *         """
 *         Class for calculating matrices A, Q, dA, dQ of the discrete Kalman Filter
 */

struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_AQcompute_batch_Cython {
  struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Q_handling_Cython __pyx_base;
  PyObject *(*Q_inverse)(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *, int, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_inverse *__pyx_optional_args);
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_AQcompute_batch_Cython;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#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)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* IsLittleEndian.proto */
static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);

/* BufferFormatCheck.proto */
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type);

/* BufferGetAndValidate.proto */
#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\
    ((obj == Py_None || obj == NULL) ?\
    (__Pyx_ZeroBuffer(buf), 0) :\
    __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack))
static int  __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
    __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static void __Pyx_ZeroBuffer(Py_buffer* buf);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 };
static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 };

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyObjectCall.proto */
#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

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* RaiseArgTupleInvalid.proto */
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);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

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

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* GetItemInt.proto */
#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 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);

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* BufferFallbackError.proto */
static void __Pyx_RaiseBufferFallbackError(void);

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* PyDictContains.proto */
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
    int result = PyDict_Contains(dict, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

/* PySequenceContains.proto */
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* SetItemInt.proto */
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
               __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

/* PyFloatBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyFloat_DivideCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyFloat_DivideCObj(op1, op2, floatval, inplace, zerodivision_check)\
    ((inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2)))
    #endif

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* CallNextTpTraverse.proto */
static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);

/* CallNextTpClear.proto */
static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* PyObjectGetAttrStrNoError.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* TypeImport.proto */
#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __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);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* BufferStructDeclare.proto */
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


/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value);

/* RealImag.proto */
#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(__cplusplus) && CYTHON_CCOMPLEX\
        && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
    #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

/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq_float(a, b)   ((a)==(b))
    #define __Pyx_c_sum_float(a, b)  ((a)+(b))
    #define __Pyx_c_diff_float(a, b) ((a)-(b))
    #define __Pyx_c_prod_float(a, b) ((a)*(b))
    #define __Pyx_c_quot_float(a, b) ((a)/(b))
    #define __Pyx_c_neg_float(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
    #define __Pyx_c_conj_float(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs_float(z)     (::std::abs(z))
        #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero_float(z) ((z)==0)
    #define __Pyx_c_conj_float(z)    (conjf(z))
    #if 1
        #define __Pyx_c_abs_float(z)     (cabsf(z))
        #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
    #if 1
        static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
    #endif
#endif

/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq_double(a, b)   ((a)==(b))
    #define __Pyx_c_sum_double(a, b)  ((a)+(b))
    #define __Pyx_c_diff_double(a, b) ((a)-(b))
    #define __Pyx_c_prod_double(a, b) ((a)*(b))
    #define __Pyx_c_quot_double(a, b) ((a)/(b))
    #define __Pyx_c_neg_double(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
    #define __Pyx_c_conj_double(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs_double(z)     (::std::abs(z))
        #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero_double(z) ((z)==0)
    #define __Pyx_c_conj_double(z)    (conj(z))
    #if 1
        #define __Pyx_c_abs_double(z)     (cabs(z))
        #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
    #endif
#endif

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Ak(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_P, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Qk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Q_srk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dAk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dQk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_Hk, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Hk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Rk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_R_isrk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dHk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dRk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_f_h(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_H, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_P, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_inverse(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_inverse *__pyx_optional_args); /* proto*/

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

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

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

/* Module declarations from '__builtin__' */

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

/* Module declarations from 'cpython' */

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

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

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

/* 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_generic = 0;
static PyTypeObject *__pyx_ptype_5numpy_number = 0;
static PyTypeObject *__pyx_ptype_5numpy_integer = 0;
static PyTypeObject *__pyx_ptype_5numpy_signedinteger = 0;
static PyTypeObject *__pyx_ptype_5numpy_unsignedinteger = 0;
static PyTypeObject *__pyx_ptype_5numpy_inexact = 0;
static PyTypeObject *__pyx_ptype_5numpy_floating = 0;
static PyTypeObject *__pyx_ptype_5numpy_complexfloating = 0;
static PyTypeObject *__pyx_ptype_5numpy_flexible = 0;
static PyTypeObject *__pyx_ptype_5numpy_character = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;

/* Module declarations from 'cython' */

/* Module declarations from 'GPy.models.state_space_cython' */
static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython = 0;
static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython = 0;
static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_R_handling_Cython = 0;
static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython = 0;
static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_Q_handling_Cython = 0;
static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython = 0;
static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_AQcompute_batch_Cython = 0;
static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Dynamic_Callables_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, PyObject *); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Measurement_Callables_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, PyObject *); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_R_handling_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *, PyObject *); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Std_Measurement_Callables_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *, PyObject *); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Q_handling_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *, PyObject *); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *, PyObject *); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_AQcompute_batch_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *, PyObject *); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_3GPy_6models_18state_space_cython_DTYPE_t), { 0 }, 0, 'R', 0, 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t = { "DTYPE_int_t", NULL, sizeof(__pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t), 0 };
#define __Pyx_MODULE_NAME "GPy.models.state_space_cython"
extern int __pyx_module_is_main_GPy__models__state_space_cython;
int __pyx_module_is_main_GPy__models__state_space_cython = 0;

/* Implementation of 'GPy.models.state_space_cython' */
static PyObject *__pyx_builtin_NotImplemented;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ImportError;
static const char __pyx_k_A[] = "A";
static const char __pyx_k_H[] = "H";
static const char __pyx_k_K[] = "K";
static const char __pyx_k_M[] = "M";
static const char __pyx_k_P[] = "P";
static const char __pyx_k_Q[] = "Q";
static const char __pyx_k_R[] = "R";
static const char __pyx_k_S[] = "S";
static const char __pyx_k_T[] = "T";
static const char __pyx_k_U[] = "U";
static const char __pyx_k_X[] = "X";
static const char __pyx_k_Y[] = "Y";
static const char __pyx_k_j[] = "j";
static const char __pyx_k_k[] = "k";
static const char __pyx_k_m[] = "m";
static const char __pyx_k_v[] = "v";
static const char __pyx_k_Ak[] = "Ak";
static const char __pyx_k_As[] = "As";
static const char __pyx_k_Hk[] = "Hk";
static const char __pyx_k_Qk[] = "Qk";
static const char __pyx_k_Qs[] = "Qs";
static const char __pyx_k_Rk[] = "Rk";
static const char __pyx_k_Vh[] = "Vh";
static const char __pyx_k_dA[] = "dA";
static const char __pyx_k_dH[] = "dH";
static const char __pyx_k_dK[] = "dK";
static const char __pyx_k_dQ[] = "dQ";
static const char __pyx_k_dR[] = "dR";
static const char __pyx_k_dS[] = "dS";
static const char __pyx_k_dv[] = "dv";
static const char __pyx_k_np[] = "np";
static const char __pyx_k_pi[] = "pi";
static const char __pyx_k_sp[] = "sp";
static const char __pyx_k_all[] = "all";
static const char __pyx_k_any[] = "any";
static const char __pyx_k_dAk[] = "dAk";
static const char __pyx_k_dAs[] = "dAs";
static const char __pyx_k_dHk[] = "dHk";
static const char __pyx_k_dQk[] = "dQk";
static const char __pyx_k_dQs[] = "dQs";
static const char __pyx_k_dRk[] = "dRk";
static const char __pyx_k_dot[] = "dot";
static const char __pyx_k_f_a[] = "f_a";
static const char __pyx_k_f_h[] = "f_h";
static const char __pyx_k_log[] = "log";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_p_P[] = "p_P";
static const char __pyx_k_p_m[] = "p_m";
static const char __pyx_k_res[] = "res";
static const char __pyx_k_ret[] = "ret";
static const char __pyx_k_sum[] = "sum";
static const char __pyx_k_svd[] = "svd";
static const char __pyx_k_Q_sr[] = "Q_sr";
static const char __pyx_k_axis[] = "axis";
static const char __pyx_k_diag[] = "diag";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_p_dP[] = "p_dP";
static const char __pyx_k_p_dm[] = "p_dm";
static const char __pyx_k_sqrt[] = "sqrt";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_tmp1[] = "tmp1";
static const char __pyx_k_tmp2[] = "tmp2";
static const char __pyx_k_tmp3[] = "tmp3";
static const char __pyx_k_tmp5[] = "tmp5";
static const char __pyx_k_DTYPE[] = "DTYPE";
static const char __pyx_k_P_upd[] = "P_upd";
static const char __pyx_k_Q_srk[] = "Q_srk";
static const char __pyx_k_R_isr[] = "R_isr";
static const char __pyx_k_S_new[] = "S_new";
static const char __pyx_k_S_old[] = "S_old";
static const char __pyx_k_S_svd[] = "S_svd";
static const char __pyx_k_S_upd[] = "S_upd";
static const char __pyx_k_U_upd[] = "U_upd";
static const char __pyx_k_V_new[] = "V_new";
static const char __pyx_k_V_old[] = "V_old";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_empty[] = "empty";
static const char __pyx_k_index[] = "index";
static const char __pyx_k_int64[] = "int64";
static const char __pyx_k_isnan[] = "isnan";
static const char __pyx_k_m_upd[] = "m_upd";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_param[] = "param";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_reset[] = "reset";
static const char __pyx_k_scipy[] = "scipy";
static const char __pyx_k_shape[] = "shape";
static const char __pyx_k_super[] = "super";
static const char __pyx_k_zeros[] = "zeros";
static const char __pyx_k_P_init[] = "P_init";
static const char __pyx_k_P_pred[] = "P_pred";
static const char __pyx_k_R_isrk[] = "R_isrk";
static const char __pyx_k_S_pred[] = "S_pred";
static const char __pyx_k_V_pred[] = "V_pred";
static const char __pyx_k_dP_upd[] = "dP_upd";
static const char __pyx_k_dm_upd[] = "dm_upd";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_jitter[] = "jitter";
static const char __pyx_k_linalg[] = "linalg";
static const char __pyx_k_m_init[] = "m_init";
static const char __pyx_k_m_pred[] = "m_pred";
static const char __pyx_k_nbytes[] = "nbytes";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_unique[] = "unique";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_vstack[] = "vstack";
static const char __pyx_k_dP_init[] = "dP_init";
static const char __pyx_k_dP_pred[] = "dP_pred";
static const char __pyx_k_dm_init[] = "dm_init";
static const char __pyx_k_dm_pred[] = "dm_pred";
static const char __pyx_k_float64[] = "float64";
static const char __pyx_k_regular[] = "regular";
static const char __pyx_k_Prev_cov[] = "Prev_cov";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_steps_no[] = "steps_no";
static const char __pyx_k_DTYPE_int[] = "DTYPE_int";
static const char __pyx_k_Q_inverse[] = "Q_inverse";
static const char __pyx_k_prev_mean[] = "prev_mean";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_state_dim[] = "state_dim";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_compute_uv[] = "compute_uv";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_svd_1_matr[] = "svd_1_matr";
static const char __pyx_k_svd_2_matr[] = "svd_2_matr";
static const char __pyx_k_ImportError[] = "ImportError";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_measurement[] = "measurement";
static const char __pyx_k_overwrite_a[] = "overwrite_a";
static const char __pyx_k_check_finite[] = "check_finite";
static const char __pyx_k_k_measurment[] = "k_measurment";
static const char __pyx_k_param_number[] = "param_number";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_dA_all_params[] = "dA_all_params";
static const char __pyx_k_dH_all_params[] = "dH_all_params";
static const char __pyx_k_dQ_all_params[] = "dQ_all_params";
static const char __pyx_k_dR_all_params[] = "dR_all_params";
static const char __pyx_k_full_matrices[] = "full_matrices";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_NotImplemented[] = "NotImplemented";
static const char __pyx_k_Q_inverse_dict[] = "Q_inverse_dict";
static const char __pyx_k_grad_params_no[] = "grad_params_no";
static const char __pyx_k_log_likelihood[] = "log_likelihood";
static const char __pyx_k_time_series_no[] = "time_series_no";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_unique_Q_number[] = "unique_Q_number";
static const char __pyx_k_unique_R_number[] = "unique_R_number";
static const char __pyx_k_A_time_var_index[] = "A_time_var_index";
static const char __pyx_k_H_time_var_index[] = "H_time_var_index";
static const char __pyx_k_Q_time_var_index[] = "Q_time_var_index";
static const char __pyx_k_R_time_var_index[] = "R_time_var_index";
static const char __pyx_k_Q_handling_Cython[] = "Q_handling_Cython";
static const char __pyx_k_R_handling_Cython[] = "R_handling_Cython";
static const char __pyx_k_p_unique_Q_number[] = "p_unique_Q_number";
static const char __pyx_k_p_unique_R_number[] = "p_unique_R_number";
static const char __pyx_k_Q_square_root_dict[] = "Q_square_root_dict";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_dP_pred_all_params[] = "dP_pred_all_params";
static const char __pyx_k_dm_pred_all_params[] = "dm_pred_all_params";
static const char __pyx_k_total_size_of_data[] = "total_size_of_data";
static const char __pyx_k_calc_log_likelihood[] = "calc_log_likelihood";
static const char __pyx_k_compute_derivatives[] = "compute_derivatives";
static const char __pyx_k_grad_log_likelihood[] = "grad_log_likelihood";
static const char __pyx_k_p_dynamic_callables[] = "p_dynamic_callables";
static const char __pyx_k_reconstruct_indices[] = "reconstruct_indices";
static const char __pyx_k_p_kalman_filter_type[] = "p_kalman_filter_type";
static const char __pyx_k_dA_derivative_is_None[] = "dA derivative is None";
static const char __pyx_k_dH_derivative_is_None[] = "dH derivative is None";
static const char __pyx_k_dQ_derivative_is_None[] = "dQ derivative is None";
static const char __pyx_k_dR_derivative_is_None[] = "dR derivative is None";
static const char __pyx_k_log_likelihood_update[] = "log_likelihood_update";
static const char __pyx_k_AQcompute_batch_Cython[] = "AQcompute_batch_Cython";
static const char __pyx_k_measurement_dim_gt_one[] = "measurement_dim_gt_one";
static const char __pyx_k_d_log_likelihood_update[] = "d_log_likelihood_update";
static const char __pyx_k_p_measurement_callables[] = "p_measurement_callables";
static const char __pyx_k_Dynamic_Callables_Cython[] = "Dynamic_Callables_Cython";
static const char __pyx_k_calc_grad_log_likelihood[] = "calc_grad_log_likelihood";
static const char __pyx_k_Measurement_Callables_Cython[] = "Measurement_Callables_Cython";
static const char __pyx_k_Std_Dynamic_Callables_Cython[] = "Std_Dynamic_Callables_Cython";
static const char __pyx_k_cython_Ak_is_not_implemented[] = "(cython) Ak is not implemented!";
static const char __pyx_k_cython_Hk_is_not_implemented[] = "(cython) Hk is not implemented!";
static const char __pyx_k_cython_Qk_is_not_implemented[] = "(cython) Qk is not implemented!";
static const char __pyx_k_cython_Rk_is_not_implemented[] = "(cython) Rk is not implemented!";
static const char __pyx_k_GPy_models_state_space_cython[] = "GPy.models.state_space_cython";
static const char __pyx_k_cython_dAk_is_not_implemented[] = "(cython) dAk is not implemented!";
static const char __pyx_k_cython_dQk_is_not_implemented[] = "(cython) dQk is not implemented!";
static const char __pyx_k_cython_f_a_is_not_implemented[] = "(cython) f_a is not implemented!";
static const char __pyx_k_kalman_update_step_SVD_Cython[] = "_kalman_update_step_SVD_Cython";
static const char __pyx_k_pyx_unpickle_AQcompute_batch_C[] = "__pyx_unpickle_AQcompute_batch_Cython";
static const char __pyx_k_pyx_unpickle_Dynamic_Callables[] = "__pyx_unpickle_Dynamic_Callables_Cython";
static const char __pyx_k_pyx_unpickle_Measurement_Calla[] = "__pyx_unpickle_Measurement_Callables_Cython";
static const char __pyx_k_pyx_unpickle_Q_handling_Cython[] = "__pyx_unpickle_Q_handling_Cython";
static const char __pyx_k_pyx_unpickle_R_handling_Cython[] = "__pyx_unpickle_R_handling_Cython";
static const char __pyx_k_pyx_unpickle_Std_Dynamic_Calla[] = "__pyx_unpickle_Std_Dynamic_Callables_Cython";
static const char __pyx_k_pyx_unpickle_Std_Measurement_C[] = "__pyx_unpickle_Std_Measurement_Callables_Cython";
static const char __pyx_k_Contains_some_cython_code_for_s[] = "\nContains some cython code for state space modelling.\n";
static const char __pyx_k_Nan_values_in_likelihood_update[] = "Nan values in likelihood update!";
static const char __pyx_k_cont_discr_kalman_filter_raw_Cy[] = "_cont_discr_kalman_filter_raw_Cython";
static const char __pyx_k_cython_Q_srk_is_not_implemented[] = "(cython) Q_srk is not implemented!";
static const char __pyx_k_cython_reset_is_not_implemented[] = "(cython) reset is not implemented!";
static const char __pyx_k_kalman_prediction_step_SVD_Cyth[] = "_kalman_prediction_step_SVD_Cython";
static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
static const char __pyx_k_GPy_models_state_space_cython_py[] = "GPy/models/state_space_cython.pyx";
static const char __pyx_k_Incompatible_checksums_s_vs_0x14[] = "Incompatible checksums (%s vs 0x146e1f7 = (As, Q, Q_square_root, Q_svd_dict, Q_time_var_index, Qs, dAs, dQ, dQs, index, last_k, reconstruct_indices, svd_each_time))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x70[] = "Incompatible checksums (%s vs 0x706c35f = (H, H_time_var_index, R, R_square_root, R_time_var_index, dH, dR, index, svd_each_time))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x77[] = "Incompatible checksums (%s vs 0x77b5360 = (Q, Q_square_root, Q_time_var_index, dQ, index, svd_each_time))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x9e[] = "Incompatible checksums (%s vs 0x9e97ca7 = (R, R_square_root, R_time_var_index, dR, index, svd_each_time))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xd4[] = "Incompatible checksums (%s vs 0xd41d8cd = ())";
static const char __pyx_k_Incompatible_checksums_s_vs_0xdf[] = "Incompatible checksums (%s vs 0xdff0f56 = (A, A_time_var_index, Q, Q_square_root, Q_time_var_index, dA, dQ, index, svd_each_time))";
static const char __pyx_k_Kalman_Filter_Update_SVD_S_is_ne[] = "Kalman Filter Update SVD: S is negative step %i";
static const char __pyx_k_Measurement_dimension_larger_the[] = "Measurement dimension larger then 1 is currently not supported";
static const char __pyx_k_Nan_measurements_are_currently_n[] = "Nan measurements are currently not supported if\n                                     they are intermixed with not NaN measurements";
static const char __pyx_k_Std_Measurement_Callables_Cython[] = "Std_Measurement_Callables_Cython";
static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
static PyObject *__pyx_n_s_A;
static PyObject *__pyx_n_s_AQcompute_batch_Cython;
static PyObject *__pyx_n_s_A_time_var_index;
static PyObject *__pyx_n_s_Ak;
static PyObject *__pyx_n_s_As;
static PyObject *__pyx_n_s_DTYPE;
static PyObject *__pyx_n_s_DTYPE_int;
static PyObject *__pyx_n_s_Dynamic_Callables_Cython;
static PyObject *__pyx_n_s_GPy_models_state_space_cython;
static PyObject *__pyx_kp_s_GPy_models_state_space_cython_py;
static PyObject *__pyx_n_s_H;
static PyObject *__pyx_n_s_H_time_var_index;
static PyObject *__pyx_n_s_Hk;
static PyObject *__pyx_n_s_ImportError;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x14;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x70;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x77;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x9e;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xd4;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xdf;
static PyObject *__pyx_n_s_K;
static PyObject *__pyx_kp_s_Kalman_Filter_Update_SVD_S_is_ne;
static PyObject *__pyx_n_s_M;
static PyObject *__pyx_n_s_Measurement_Callables_Cython;
static PyObject *__pyx_kp_s_Measurement_dimension_larger_the;
static PyObject *__pyx_kp_s_Nan_measurements_are_currently_n;
static PyObject *__pyx_kp_s_Nan_values_in_likelihood_update;
static PyObject *__pyx_n_s_NotImplemented;
static PyObject *__pyx_n_s_P;
static PyObject *__pyx_n_s_P_init;
static PyObject *__pyx_n_s_P_pred;
static PyObject *__pyx_n_s_P_upd;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_n_s_Prev_cov;
static PyObject *__pyx_n_s_Q;
static PyObject *__pyx_n_s_Q_handling_Cython;
static PyObject *__pyx_n_s_Q_inverse;
static PyObject *__pyx_n_s_Q_inverse_dict;
static PyObject *__pyx_n_s_Q_square_root_dict;
static PyObject *__pyx_n_s_Q_sr;
static PyObject *__pyx_n_s_Q_srk;
static PyObject *__pyx_n_s_Q_time_var_index;
static PyObject *__pyx_n_s_Qk;
static PyObject *__pyx_n_s_Qs;
static PyObject *__pyx_n_s_R;
static PyObject *__pyx_n_s_R_handling_Cython;
static PyObject *__pyx_n_s_R_isr;
static PyObject *__pyx_n_s_R_isrk;
static PyObject *__pyx_n_s_R_time_var_index;
static PyObject *__pyx_n_s_Rk;
static PyObject *__pyx_n_s_S;
static PyObject *__pyx_n_s_S_new;
static PyObject *__pyx_n_s_S_old;
static PyObject *__pyx_n_s_S_pred;
static PyObject *__pyx_n_s_S_svd;
static PyObject *__pyx_n_s_S_upd;
static PyObject *__pyx_n_s_Std_Dynamic_Callables_Cython;
static PyObject *__pyx_n_s_Std_Measurement_Callables_Cython;
static PyObject *__pyx_n_s_T;
static PyObject *__pyx_n_s_U;
static PyObject *__pyx_n_s_U_upd;
static PyObject *__pyx_n_s_V_new;
static PyObject *__pyx_n_s_V_old;
static PyObject *__pyx_n_s_V_pred;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_s_Vh;
static PyObject *__pyx_n_s_X;
static PyObject *__pyx_n_s_Y;
static PyObject *__pyx_n_s_all;
static PyObject *__pyx_n_s_any;
static PyObject *__pyx_n_s_axis;
static PyObject *__pyx_n_s_calc_grad_log_likelihood;
static PyObject *__pyx_n_s_calc_log_likelihood;
static PyObject *__pyx_n_s_check_finite;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_compute_derivatives;
static PyObject *__pyx_n_s_compute_uv;
static PyObject *__pyx_n_s_cont_discr_kalman_filter_raw_Cy;
static PyObject *__pyx_kp_s_cython_Ak_is_not_implemented;
static PyObject *__pyx_kp_s_cython_Hk_is_not_implemented;
static PyObject *__pyx_kp_s_cython_Q_srk_is_not_implemented;
static PyObject *__pyx_kp_s_cython_Qk_is_not_implemented;
static PyObject *__pyx_kp_s_cython_Rk_is_not_implemented;
static PyObject *__pyx_kp_s_cython_dAk_is_not_implemented;
static PyObject *__pyx_kp_s_cython_dQk_is_not_implemented;
static PyObject *__pyx_kp_s_cython_f_a_is_not_implemented;
static PyObject *__pyx_kp_s_cython_reset_is_not_implemented;
static PyObject *__pyx_n_s_dA;
static PyObject *__pyx_n_s_dA_all_params;
static PyObject *__pyx_kp_s_dA_derivative_is_None;
static PyObject *__pyx_n_s_dAk;
static PyObject *__pyx_n_s_dAs;
static PyObject *__pyx_n_s_dH;
static PyObject *__pyx_n_s_dH_all_params;
static PyObject *__pyx_kp_s_dH_derivative_is_None;
static PyObject *__pyx_n_s_dHk;
static PyObject *__pyx_n_s_dK;
static PyObject *__pyx_n_s_dP_init;
static PyObject *__pyx_n_s_dP_pred;
static PyObject *__pyx_n_s_dP_pred_all_params;
static PyObject *__pyx_n_s_dP_upd;
static PyObject *__pyx_n_s_dQ;
static PyObject *__pyx_n_s_dQ_all_params;
static PyObject *__pyx_kp_s_dQ_derivative_is_None;
static PyObject *__pyx_n_s_dQk;
static PyObject *__pyx_n_s_dQs;
static PyObject *__pyx_n_s_dR;
static PyObject *__pyx_n_s_dR_all_params;
static PyObject *__pyx_kp_s_dR_derivative_is_None;
static PyObject *__pyx_n_s_dRk;
static PyObject *__pyx_n_s_dS;
static PyObject *__pyx_n_s_d_log_likelihood_update;
static PyObject *__pyx_n_s_diag;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_dm_init;
static PyObject *__pyx_n_s_dm_pred;
static PyObject *__pyx_n_s_dm_pred_all_params;
static PyObject *__pyx_n_s_dm_upd;
static PyObject *__pyx_n_s_dot;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_dv;
static PyObject *__pyx_n_s_empty;
static PyObject *__pyx_n_s_f_a;
static PyObject *__pyx_n_s_f_h;
static PyObject *__pyx_n_s_float64;
static PyObject *__pyx_n_s_full_matrices;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_n_s_grad_log_likelihood;
static PyObject *__pyx_n_s_grad_params_no;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_index;
static PyObject *__pyx_n_s_init;
static PyObject *__pyx_n_s_int64;
static PyObject *__pyx_n_s_isnan;
static PyObject *__pyx_n_s_j;
static PyObject *__pyx_n_s_jitter;
static PyObject *__pyx_n_s_k;
static PyObject *__pyx_n_s_k_measurment;
static PyObject *__pyx_n_s_kalman_prediction_step_SVD_Cyth;
static PyObject *__pyx_n_s_kalman_update_step_SVD_Cython;
static PyObject *__pyx_n_s_linalg;
static PyObject *__pyx_n_s_log;
static PyObject *__pyx_n_s_log_likelihood;
static PyObject *__pyx_n_s_log_likelihood_update;
static PyObject *__pyx_n_s_m;
static PyObject *__pyx_n_s_m_init;
static PyObject *__pyx_n_s_m_pred;
static PyObject *__pyx_n_s_m_upd;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_measurement;
static PyObject *__pyx_n_s_measurement_dim_gt_one;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_nbytes;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_n_s_np;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to;
static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor;
static PyObject *__pyx_n_s_overwrite_a;
static PyObject *__pyx_n_s_p_P;
static PyObject *__pyx_n_s_p_dP;
static PyObject *__pyx_n_s_p_dm;
static PyObject *__pyx_n_s_p_dynamic_callables;
static PyObject *__pyx_n_s_p_kalman_filter_type;
static PyObject *__pyx_n_s_p_m;
static PyObject *__pyx_n_s_p_measurement_callables;
static PyObject *__pyx_n_s_p_unique_Q_number;
static PyObject *__pyx_n_s_p_unique_R_number;
static PyObject *__pyx_n_s_param;
static PyObject *__pyx_n_s_param_number;
static PyObject *__pyx_n_s_pi;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_n_s_prev_mean;
static PyObject *__pyx_n_s_pyx_PickleError;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle_AQcompute_batch_C;
static PyObject *__pyx_n_s_pyx_unpickle_Dynamic_Callables;
static PyObject *__pyx_n_s_pyx_unpickle_Measurement_Calla;
static PyObject *__pyx_n_s_pyx_unpickle_Q_handling_Cython;
static PyObject *__pyx_n_s_pyx_unpickle_R_handling_Cython;
static PyObject *__pyx_n_s_pyx_unpickle_Std_Dynamic_Calla;
static PyObject *__pyx_n_s_pyx_unpickle_Std_Measurement_C;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_reconstruct_indices;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_regular;
static PyObject *__pyx_n_s_res;
static PyObject *__pyx_n_s_reset;
static PyObject *__pyx_n_s_ret;
static PyObject *__pyx_n_s_scipy;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_s_sp;
static PyObject *__pyx_n_s_sqrt;
static PyObject *__pyx_n_s_state_dim;
static PyObject *__pyx_n_s_steps_no;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_n_s_sum;
static PyObject *__pyx_n_s_super;
static PyObject *__pyx_n_s_svd;
static PyObject *__pyx_n_s_svd_1_matr;
static PyObject *__pyx_n_s_svd_2_matr;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_time_series_no;
static PyObject *__pyx_n_s_tmp1;
static PyObject *__pyx_n_s_tmp2;
static PyObject *__pyx_n_s_tmp3;
static PyObject *__pyx_n_s_tmp5;
static PyObject *__pyx_n_s_total_size_of_data;
static PyObject *__pyx_n_s_unique;
static PyObject *__pyx_n_s_unique_Q_number;
static PyObject *__pyx_n_s_unique_R_number;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_s_v;
static PyObject *__pyx_n_s_vstack;
static PyObject *__pyx_n_s_zeros;
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_2Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_P); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_4Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_6Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_8dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_10dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_12reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_compute_derivatives); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_14__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_16__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_Hk); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_2Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_4Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_6R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_8dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_10dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_12reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, PyObject *__pyx_v_compute_derivatives); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_14__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_16__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, PyArrayObject *__pyx_v_R, PyArrayObject *__pyx_v_index, int __pyx_v_R_time_var_index, int __pyx_v_p_unique_R_number, PyArrayObject *__pyx_v_dR); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_2Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_4dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_6R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_8__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_10__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, PyArrayObject *__pyx_v_H, int __pyx_v_H_time_var_index, PyArrayObject *__pyx_v_R, PyArrayObject *__pyx_v_index, int __pyx_v_R_time_var_index, int __pyx_v_unique_R_number, PyArrayObject *__pyx_v_dH, PyArrayObject *__pyx_v_dR); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_2f_h(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_H); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_4Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_6dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_8__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_10__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, PyArrayObject *__pyx_v_Q, PyArrayObject *__pyx_v_index, int __pyx_v_Q_time_var_index, int __pyx_v_p_unique_Q_number, PyArrayObject *__pyx_v_dQ); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_2Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_4dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_6Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_8__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_10__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, PyArrayObject *__pyx_v_A, int __pyx_v_A_time_var_index, PyArrayObject *__pyx_v_Q, PyArrayObject *__pyx_v_index, int __pyx_v_Q_time_var_index, int __pyx_v_unique_Q_number, PyArrayObject *__pyx_v_dA, PyArrayObject *__pyx_v_dQ); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_2f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_4Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_6dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_8reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_compute_derivatives); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_10__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_12__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, PyArrayObject *__pyx_v_As, PyArrayObject *__pyx_v_Qs, PyArrayObject *__pyx_v_reconstruct_indices, PyArrayObject *__pyx_v_dAs, PyArrayObject *__pyx_v_dQs); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_2f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_4reset(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_compute_derivatives); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_6Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_P); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_8Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_10dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_12dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_14Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_16Q_inverse(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, float __pyx_v_jitter); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_18__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_20__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython__kalman_prediction_step_SVD_Cython(CYTHON_UNUSED PyObject *__pyx_self, long __pyx_v_k, PyArrayObject *__pyx_v_p_m, PyObject *__pyx_v_p_P, struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables, int __pyx_v_calc_grad_log_likelihood, PyArrayObject *__pyx_v_p_dm, PyArrayObject *__pyx_v_p_dP); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_2_kalman_update_step_SVD_Cython(CYTHON_UNUSED PyObject *__pyx_self, long __pyx_v_k, PyArrayObject *__pyx_v_p_m, PyObject *__pyx_v_p_P, struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables, PyArrayObject *__pyx_v_measurement, int __pyx_v_calc_log_likelihood, int __pyx_v_calc_grad_log_likelihood, PyArrayObject *__pyx_v_p_dm, PyArrayObject *__pyx_v_p_dP); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_4_cont_discr_kalman_filter_raw_Cython(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_state_dim, struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables, struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables, CYTHON_UNUSED PyObject *__pyx_v_X, PyObject *__pyx_v_Y, PyArrayObject *__pyx_v_m_init, PyArrayObject *__pyx_v_P_init, CYTHON_UNUSED PyObject *__pyx_v_p_kalman_filter_type, int __pyx_v_calc_log_likelihood, int __pyx_v_calc_grad_log_likelihood, int __pyx_v_grad_params_no, PyArrayObject *__pyx_v_dm_init, PyArrayObject *__pyx_v_dP_init); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_6__pyx_unpickle_Dynamic_Callables_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_8__pyx_unpickle_Measurement_Callables_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_10__pyx_unpickle_R_handling_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_12__pyx_unpickle_Std_Measurement_Callables_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_14__pyx_unpickle_Q_handling_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_16__pyx_unpickle_Std_Dynamic_Callables_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_18__pyx_unpickle_AQcompute_batch_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Measurement_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_R_handling_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Q_handling_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_AQcompute_batch_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_float_0_5;
static PyObject *__pyx_float_1_0;
static PyObject *__pyx_float_1eneg_17;
static PyObject *__pyx_float_neg_0_5;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_21422583;
static PyObject *__pyx_int_117883743;
static PyObject *__pyx_int_125522784;
static PyObject *__pyx_int_166296743;
static PyObject *__pyx_int_222419149;
static PyObject *__pyx_int_234819414;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_slice__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_codeobj__22;
static PyObject *__pyx_codeobj__24;
static PyObject *__pyx_codeobj__26;
static PyObject *__pyx_codeobj__28;
static PyObject *__pyx_codeobj__30;
static PyObject *__pyx_codeobj__32;
static PyObject *__pyx_codeobj__34;
static PyObject *__pyx_codeobj__36;
static PyObject *__pyx_codeobj__38;
static PyObject *__pyx_codeobj__40;
/* Late includes */

/* "GPy/models/state_space_cython.pyx":22
 * # Template class for dynamic callables
 * cdef class Dynamic_Callables_Cython:
 *     cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) f_a is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_1f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_A;
  __Pyx_Buffer __pyx_pybuffer_A;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("f_a", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __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_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 22, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 22, __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]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1];
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_f_a); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_1f_a)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __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_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_A)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_A)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 22, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(((PyObject *)__pyx_v_m));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_m));
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m));
          __Pyx_INCREF(((PyObject *)__pyx_v_A));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_A));
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_A));
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __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;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":23
 * cdef class Dynamic_Callables_Cython:
 *     cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A):
 *         raise NotImplemented("(cython) f_a is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 23, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":22
 * # Template class for dynamic callables
 * cdef class Dynamic_Callables_Cython:
 *     cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) f_a is not implemented!")
 * 
 */

  /* 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_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_1f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_1f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_m = 0;
  PyArrayObject *__pyx_v_A = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("f_a (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_A,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 1); __PYX_ERR(0, 22, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 2); __PYX_ERR(0, 22, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f_a") < 0)) __PYX_ERR(0, 22, __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_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 22, __pyx_L3_error)
    __pyx_v_m = ((PyArrayObject *)values[1]);
    __pyx_v_A = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 22, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) __PYX_ERR(0, 22, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_A), __pyx_ptype_5numpy_ndarray, 1, "A", 0))) __PYX_ERR(0, 22, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __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_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_A;
  __Pyx_Buffer __pyx_pybuffer_A;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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("f_a", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __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_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 22, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 22, __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]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(__pyx_v_self, __pyx_v_k, __pyx_v_m, __pyx_v_A, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":25
 *         raise NotImplemented("(cython) f_a is not implemented!")
 * 
 *     cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Ak is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_3Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Ak(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_P, int __pyx_skip_dispatch) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P;
  __Pyx_Buffer __pyx_pybuffer_P;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Ak", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __pyx_pybuffer_P.pybuffer.buf = NULL;
  __pyx_pybuffer_P.refcount = 0;
  __pyx_pybuffernd_P.data = NULL;
  __pyx_pybuffernd_P.rcbuffer = &__pyx_pybuffer_P;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 25, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P.rcbuffer->pybuffer, (PyObject*)__pyx_v_P, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 25, __pyx_L1_error)
  }
  __pyx_pybuffernd_P.diminfo[0].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P.diminfo[0].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P.diminfo[1].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P.diminfo[1].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[1];
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Ak); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_3Ak)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __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_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_P)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_P)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 25, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(((PyObject *)__pyx_v_m));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_m));
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m));
          __Pyx_INCREF(((PyObject *)__pyx_v_P));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_P));
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_P));
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __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;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":26
 * 
 *     cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix
 *         raise NotImplemented("(cython) Ak is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef Qk(self, int k):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 26, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":25
 *         raise NotImplemented("(cython) f_a is not implemented!")
 * 
 *     cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Ak is not implemented!")
 * 
 */

  /* 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_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_3Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_3Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_m = 0;
  PyArrayObject *__pyx_v_P = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("Ak (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_P,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 1); __PYX_ERR(0, 25, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_P)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 2); __PYX_ERR(0, 25, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Ak") < 0)) __PYX_ERR(0, 25, __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_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 25, __pyx_L3_error)
    __pyx_v_m = ((PyArrayObject *)values[1]);
    __pyx_v_P = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 25, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) __PYX_ERR(0, 25, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P), __pyx_ptype_5numpy_ndarray, 1, "P", 0))) __PYX_ERR(0, 25, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_2Ak(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __pyx_v_P);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_2Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_P) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P;
  __Pyx_Buffer __pyx_pybuffer_P;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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("Ak", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __pyx_pybuffer_P.pybuffer.buf = NULL;
  __pyx_pybuffer_P.refcount = 0;
  __pyx_pybuffernd_P.data = NULL;
  __pyx_pybuffernd_P.rcbuffer = &__pyx_pybuffer_P;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 25, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P.rcbuffer->pybuffer, (PyObject*)__pyx_v_P, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 25, __pyx_L1_error)
  }
  __pyx_pybuffernd_P.diminfo[0].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P.diminfo[0].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P.diminfo[1].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P.diminfo[1].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Ak(__pyx_v_self, __pyx_v_k, __pyx_v_m, __pyx_v_P, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":28
 *         raise NotImplemented("(cython) Ak is not implemented!")
 * 
 *     cpdef Qk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Qk is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_5Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Qk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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("Qk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Qk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_5Qk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":29
 * 
 *     cpdef Qk(self, int k):
 *         raise NotImplemented("(cython) Qk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef Q_srk(self, int k):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 29, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":28
 *         raise NotImplemented("(cython) Ak is not implemented!")
 * 
 *     cpdef Qk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Qk is not implemented!")
 * 
 */

  /* 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("GPy.models.state_space_cython.Dynamic_Callables_Cython.Qk", __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_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_5Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_5Qk(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("Qk (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_ERR(0, 28, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_4Qk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_4Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k) {
  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("Qk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Qk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __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("GPy.models.state_space_cython.Dynamic_Callables_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":31
 *         raise NotImplemented("(cython) Qk is not implemented!")
 * 
 *     cpdef Q_srk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Q_srk is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_7Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Q_srk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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("Q_srk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_srk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_7Q_srk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":32
 * 
 *     cpdef Q_srk(self, int k):
 *         raise NotImplemented("(cython) Q_srk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef dAk(self, int k):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 32, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":31
 *         raise NotImplemented("(cython) Qk is not implemented!")
 * 
 *     cpdef Q_srk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Q_srk is not implemented!")
 * 
 */

  /* 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("GPy.models.state_space_cython.Dynamic_Callables_Cython.Q_srk", __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_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_7Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_7Q_srk(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("Q_srk (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_ERR(0, 31, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_6Q_srk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_6Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k) {
  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("Q_srk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Q_srk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __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("GPy.models.state_space_cython.Dynamic_Callables_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":34
 *         raise NotImplemented("(cython) Q_srk is not implemented!")
 * 
 *     cpdef dAk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) dAk is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_9dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dAk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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("dAk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dAk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_9dAk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 34, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":35
 * 
 *     cpdef dAk(self, int k):
 *         raise NotImplemented("(cython) dAk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef dQk(self, int k):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 35, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":34
 *         raise NotImplemented("(cython) Q_srk is not implemented!")
 * 
 *     cpdef dAk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) dAk is not implemented!")
 * 
 */

  /* 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("GPy.models.state_space_cython.Dynamic_Callables_Cython.dAk", __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_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_9dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_9dAk(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("dAk (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_ERR(0, 34, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_8dAk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_8dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k) {
  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("dAk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dAk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __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("GPy.models.state_space_cython.Dynamic_Callables_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":37
 *         raise NotImplemented("(cython) dAk is not implemented!")
 * 
 *     cpdef dQk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) dQk is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_11dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dQk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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("dQk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dQk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_11dQk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 37, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":38
 * 
 *     cpdef dQk(self, int k):
 *         raise NotImplemented("(cython) dQk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef reset(self, bint compute_derivatives = False):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 38, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":37
 *         raise NotImplemented("(cython) dAk is not implemented!")
 * 
 *     cpdef dQk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) dQk is not implemented!")
 * 
 */

  /* 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("GPy.models.state_space_cython.Dynamic_Callables_Cython.dQk", __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_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_11dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_11dQk(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("dQk (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_ERR(0, 37, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_10dQk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_10dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k) {
  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("dQk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dQk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __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("GPy.models.state_space_cython.Dynamic_Callables_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":40
 *         raise NotImplemented("(cython) dQk is not implemented!")
 * 
 *     cpdef reset(self, bint compute_derivatives = False):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) reset is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args) {
  int __pyx_v_compute_derivatives = ((int)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("reset", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_compute_derivatives = __pyx_optional_args->compute_derivatives;
    }
  }
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_13reset)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_compute_derivatives); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 40, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":41
 * 
 *     cpdef reset(self, bint compute_derivatives = False):
 *         raise NotImplemented("(cython) reset is not implemented!")             # <<<<<<<<<<<<<<
 * 
 * # Template class for measurement callables
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 41, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":40
 *         raise NotImplemented("(cython) dQk is not implemented!")
 * 
 *     cpdef reset(self, bint compute_derivatives = False):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) reset is not implemented!")
 * 
 */

  /* 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("GPy.models.state_space_cython.Dynamic_Callables_Cython.reset", __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_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_compute_derivatives;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compute_derivatives,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);
        CYTHON_FALLTHROUGH;
        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 = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_compute_derivatives);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reset") < 0)) __PYX_ERR(0, 40, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_compute_derivatives = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_compute_derivatives == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 40, __pyx_L3_error)
    } else {
      __pyx_v_compute_derivatives = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("reset", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 40, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_12reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_compute_derivatives);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_12reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_compute_derivatives) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reset", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.compute_derivatives = __pyx_v_compute_derivatives;
  __pyx_t_1 = __pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython->reset(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __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("GPy.models.state_space_cython.Dynamic_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_14__reduce_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_14__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = ()             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __Pyx_INCREF(__pyx_empty_tuple);
  __pyx_v_state = __pyx_empty_tuple;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = ()
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = ()
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = False
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = ()
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = False             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Dynamic_Callables_Cython, (type(self), 0xd41d8cd, None), state
 */
  /*else*/ {
    __pyx_v_use_setstate = 0;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = False
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Dynamic_Callables_Cython, (type(self), 0xd41d8cd, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = False
 *     if use_setstate:
 *         return __pyx_unpickle_Dynamic_Callables_Cython, (type(self), 0xd41d8cd, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Dynamic_Callables_Cython, (type(self), 0xd41d8cd, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Dynamic_Callables); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_222419149);
    __Pyx_GIVEREF(__pyx_int_222419149);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_222419149);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = False
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Dynamic_Callables_Cython, (type(self), 0xd41d8cd, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Dynamic_Callables_Cython, (type(self), 0xd41d8cd, None), state
 *     else:
 *         return __pyx_unpickle_Dynamic_Callables_Cython, (type(self), 0xd41d8cd, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Dynamic_Callables_Cython__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Dynamic_Callables); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_222419149);
    __Pyx_GIVEREF(__pyx_int_222419149);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_222419149);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Dynamic_Callables_Cython, (type(self), 0xd41d8cd, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Dynamic_Callables_Cython__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_16__setstate_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_16__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  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("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Dynamic_Callables_Cython, (type(self), 0xd41d8cd, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Dynamic_Callables_Cython__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Dynamic_Callables_Cython__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Dynamic_Callables_Cython, (type(self), 0xd41d8cd, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Dynamic_Callables_Cython__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":45
 * # Template class for measurement callables
 * cdef class Measurement_Callables_Cython:
 *     cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) f_a is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_1f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_Hk, int __pyx_skip_dispatch) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Hk;
  __Pyx_Buffer __pyx_pybuffer_Hk;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred;
  __Pyx_Buffer __pyx_pybuffer_m_pred;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("f_h", 0);
  __pyx_pybuffer_m_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_m_pred.refcount = 0;
  __pyx_pybuffernd_m_pred.data = NULL;
  __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred;
  __pyx_pybuffer_Hk.pybuffer.buf = NULL;
  __pyx_pybuffer_Hk.refcount = 0;
  __pyx_pybuffernd_Hk.data = NULL;
  __pyx_pybuffernd_Hk.rcbuffer = &__pyx_pybuffer_Hk;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 45, __pyx_L1_error)
  }
  __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer, (PyObject*)__pyx_v_Hk, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 45, __pyx_L1_error)
  }
  __pyx_pybuffernd_Hk.diminfo[0].strides = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Hk.diminfo[0].shape = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Hk.diminfo[1].strides = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Hk.diminfo[1].shape = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.shape[1];
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_f_h); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_1f_h)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __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_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m_pred), ((PyObject *)__pyx_v_Hk)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m_pred), ((PyObject *)__pyx_v_Hk)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 45, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(((PyObject *)__pyx_v_m_pred));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred));
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m_pred));
          __Pyx_INCREF(((PyObject *)__pyx_v_Hk));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_Hk));
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_Hk));
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __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;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":46
 * cdef class Measurement_Callables_Cython:
 *     cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk):
 *         raise NotImplemented("(cython) f_a is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 46, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":45
 * # Template class for measurement callables
 * cdef class Measurement_Callables_Cython:
 *     cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) f_a is not implemented!")
 * 
 */

  /* 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_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_1f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_1f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_m_pred = 0;
  PyArrayObject *__pyx_v_Hk = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("f_h (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m_pred,&__pyx_n_s_Hk,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m_pred)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, 1); __PYX_ERR(0, 45, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Hk)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, 2); __PYX_ERR(0, 45, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f_h") < 0)) __PYX_ERR(0, 45, __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_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L3_error)
    __pyx_v_m_pred = ((PyArrayObject *)values[1]);
    __pyx_v_Hk = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 45, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m_pred), __pyx_ptype_5numpy_ndarray, 1, "m_pred", 0))) __PYX_ERR(0, 45, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Hk), __pyx_ptype_5numpy_ndarray, 1, "Hk", 0))) __PYX_ERR(0, 45, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m_pred, __pyx_v_Hk);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_Hk) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Hk;
  __Pyx_Buffer __pyx_pybuffer_Hk;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred;
  __Pyx_Buffer __pyx_pybuffer_m_pred;
  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("f_h", 0);
  __pyx_pybuffer_m_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_m_pred.refcount = 0;
  __pyx_pybuffernd_m_pred.data = NULL;
  __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred;
  __pyx_pybuffer_Hk.pybuffer.buf = NULL;
  __pyx_pybuffer_Hk.refcount = 0;
  __pyx_pybuffernd_Hk.data = NULL;
  __pyx_pybuffernd_Hk.rcbuffer = &__pyx_pybuffer_Hk;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 45, __pyx_L1_error)
  }
  __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer, (PyObject*)__pyx_v_Hk, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 45, __pyx_L1_error)
  }
  __pyx_pybuffernd_Hk.diminfo[0].strides = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Hk.diminfo[0].shape = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Hk.diminfo[1].strides = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Hk.diminfo[1].shape = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(__pyx_v_self, __pyx_v_k, __pyx_v_m_pred, __pyx_v_Hk, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":48
 *         raise NotImplemented("(cython) f_a is not implemented!")
 * 
 *     cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Hk is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_3Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Hk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred;
  __Pyx_Buffer __pyx_pybuffer_P_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred;
  __Pyx_Buffer __pyx_pybuffer_m_pred;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Hk", 0);
  __pyx_pybuffer_m_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_m_pred.refcount = 0;
  __pyx_pybuffernd_m_pred.data = NULL;
  __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred;
  __pyx_pybuffer_P_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_P_pred.refcount = 0;
  __pyx_pybuffernd_P_pred.data = NULL;
  __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 48, __pyx_L1_error)
  }
  __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 48, __pyx_L1_error)
  }
  __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1];
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Hk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_3Hk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __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_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m_pred), ((PyObject *)__pyx_v_P_pred)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m_pred), ((PyObject *)__pyx_v_P_pred)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(((PyObject *)__pyx_v_m_pred));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred));
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m_pred));
          __Pyx_INCREF(((PyObject *)__pyx_v_P_pred));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred));
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_P_pred));
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __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;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":49
 * 
 *     cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix
 *         raise NotImplemented("(cython) Hk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef Rk(self, int k):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 49, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":48
 *         raise NotImplemented("(cython) f_a is not implemented!")
 * 
 *     cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Hk is not implemented!")
 * 
 */

  /* 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_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_3Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_3Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_m_pred = 0;
  PyArrayObject *__pyx_v_P_pred = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("Hk (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m_pred,&__pyx_n_s_P_pred,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m_pred)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, 1); __PYX_ERR(0, 48, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_P_pred)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, 2); __PYX_ERR(0, 48, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Hk") < 0)) __PYX_ERR(0, 48, __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_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 48, __pyx_L3_error)
    __pyx_v_m_pred = ((PyArrayObject *)values[1]);
    __pyx_v_P_pred = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 48, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m_pred), __pyx_ptype_5numpy_ndarray, 1, "m_pred", 0))) __PYX_ERR(0, 48, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P_pred), __pyx_ptype_5numpy_ndarray, 1, "P_pred", 0))) __PYX_ERR(0, 48, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_2Hk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m_pred, __pyx_v_P_pred);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_2Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred;
  __Pyx_Buffer __pyx_pybuffer_P_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred;
  __Pyx_Buffer __pyx_pybuffer_m_pred;
  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("Hk", 0);
  __pyx_pybuffer_m_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_m_pred.refcount = 0;
  __pyx_pybuffernd_m_pred.data = NULL;
  __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred;
  __pyx_pybuffer_P_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_P_pred.refcount = 0;
  __pyx_pybuffernd_P_pred.data = NULL;
  __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 48, __pyx_L1_error)
  }
  __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 48, __pyx_L1_error)
  }
  __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Hk(__pyx_v_self, __pyx_v_k, __pyx_v_m_pred, __pyx_v_P_pred, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":51
 *         raise NotImplemented("(cython) Hk is not implemented!")
 * 
 *     cpdef Rk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Rk is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_5Rk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Rk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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("Rk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Rk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_5Rk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":52
 * 
 *     cpdef Rk(self, int k):
 *         raise NotImplemented("(cython) Rk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef R_isrk(self, int k):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 52, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":51
 *         raise NotImplemented("(cython) Hk is not implemented!")
 * 
 *     cpdef Rk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Rk is not implemented!")
 * 
 */

  /* 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("GPy.models.state_space_cython.Measurement_Callables_Cython.Rk", __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_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_5Rk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_5Rk(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("Rk (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_ERR(0, 51, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.Rk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_4Rk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_4Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k) {
  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("Rk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Rk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __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("GPy.models.state_space_cython.Measurement_Callables_Cython.Rk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":54
 *         raise NotImplemented("(cython) Rk is not implemented!")
 * 
 *     cpdef R_isrk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Q_srk is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_7R_isrk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_R_isrk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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("R_isrk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_R_isrk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_7R_isrk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 54, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 54, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":55
 * 
 *     cpdef R_isrk(self, int k):
 *         raise NotImplemented("(cython) Q_srk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef dHk(self, int k):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 55, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":54
 *         raise NotImplemented("(cython) Rk is not implemented!")
 * 
 *     cpdef R_isrk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) Q_srk is not implemented!")
 * 
 */

  /* 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("GPy.models.state_space_cython.Measurement_Callables_Cython.R_isrk", __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_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_7R_isrk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_7R_isrk(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("R_isrk (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_ERR(0, 54, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.R_isrk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_6R_isrk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_6R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k) {
  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("R_isrk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_R_isrk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __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("GPy.models.state_space_cython.Measurement_Callables_Cython.R_isrk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":57
 *         raise NotImplemented("(cython) Q_srk is not implemented!")
 * 
 *     cpdef dHk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) dAk is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_9dHk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dHk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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("dHk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dHk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_9dHk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 57, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":58
 * 
 *     cpdef dHk(self, int k):
 *         raise NotImplemented("(cython) dAk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef dRk(self, int k):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 58, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":57
 *         raise NotImplemented("(cython) Q_srk is not implemented!")
 * 
 *     cpdef dHk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) dAk is not implemented!")
 * 
 */

  /* 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("GPy.models.state_space_cython.Measurement_Callables_Cython.dHk", __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_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_9dHk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_9dHk(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("dHk (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_ERR(0, 57, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.dHk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_8dHk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_8dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k) {
  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("dHk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dHk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __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("GPy.models.state_space_cython.Measurement_Callables_Cython.dHk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":60
 *         raise NotImplemented("(cython) dAk is not implemented!")
 * 
 *     cpdef dRk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) dQk is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_11dRk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dRk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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("dRk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dRk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_11dRk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":61
 * 
 *     cpdef dRk(self, int k):
 *         raise NotImplemented("(cython) dQk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef reset(self,compute_derivatives = False):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 61, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":60
 *         raise NotImplemented("(cython) dAk is not implemented!")
 * 
 *     cpdef dRk(self, int k):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) dQk is not implemented!")
 * 
 */

  /* 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("GPy.models.state_space_cython.Measurement_Callables_Cython.dRk", __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_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_11dRk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_11dRk(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("dRk (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_ERR(0, 60, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.dRk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_10dRk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_10dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k) {
  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("dRk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dRk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __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("GPy.models.state_space_cython.Measurement_Callables_Cython.dRk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":63
 *         raise NotImplemented("(cython) dQk is not implemented!")
 * 
 *     cpdef reset(self,compute_derivatives = False):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) reset is not implemented!")
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset *__pyx_optional_args) {
  PyObject *__pyx_v_compute_derivatives = ((PyObject *)Py_False);
  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("reset", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_compute_derivatives = __pyx_optional_args->compute_derivatives;
    }
  }
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_13reset)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_compute_derivatives) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_compute_derivatives);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":64
 * 
 *     cpdef reset(self,compute_derivatives = False):
 *         raise NotImplemented("(cython) reset is not implemented!")             # <<<<<<<<<<<<<<
 * 
 * cdef class R_handling_Cython(Measurement_Callables_Cython):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 64, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":63
 *         raise NotImplemented("(cython) dQk is not implemented!")
 * 
 *     cpdef reset(self,compute_derivatives = False):             # <<<<<<<<<<<<<<
 *         raise NotImplemented("(cython) reset is not implemented!")
 * 
 */

  /* 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("GPy.models.state_space_cython.Measurement_Callables_Cython.reset", __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_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compute_derivatives = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compute_derivatives,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_False);
    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);
        CYTHON_FALLTHROUGH;
        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 = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_compute_derivatives);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reset") < 0)) __PYX_ERR(0, 63, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compute_derivatives = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("reset", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 63, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_12reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_compute_derivatives);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_12reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, PyObject *__pyx_v_compute_derivatives) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reset", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.compute_derivatives = __pyx_v_compute_derivatives;
  __pyx_t_1 = __pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython->reset(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __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("GPy.models.state_space_cython.Measurement_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_14__reduce_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_14__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = ()             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __Pyx_INCREF(__pyx_empty_tuple);
  __pyx_v_state = __pyx_empty_tuple;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = ()
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = ()
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = False
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = ()
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = False             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Measurement_Callables_Cython, (type(self), 0xd41d8cd, None), state
 */
  /*else*/ {
    __pyx_v_use_setstate = 0;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = False
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Measurement_Callables_Cython, (type(self), 0xd41d8cd, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = False
 *     if use_setstate:
 *         return __pyx_unpickle_Measurement_Callables_Cython, (type(self), 0xd41d8cd, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Measurement_Callables_Cython, (type(self), 0xd41d8cd, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Measurement_Calla); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_222419149);
    __Pyx_GIVEREF(__pyx_int_222419149);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_222419149);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = False
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Measurement_Callables_Cython, (type(self), 0xd41d8cd, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Measurement_Callables_Cython, (type(self), 0xd41d8cd, None), state
 *     else:
 *         return __pyx_unpickle_Measurement_Callables_Cython, (type(self), 0xd41d8cd, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Measurement_Callables_Cython__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Measurement_Calla); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_222419149);
    __Pyx_GIVEREF(__pyx_int_222419149);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_222419149);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Measurement_Callables_Cython, (type(self), 0xd41d8cd, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Measurement_Callables_Cython__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_16__setstate_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_16__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  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("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Measurement_Callables_Cython, (type(self), 0xd41d8cd, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Measurement_Callables_Cython__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Measurement_Callables_Cython__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Measurement_Callables_Cython, (type(self), 0xd41d8cd, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Measurement_Callables_Cython__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":78
 *         dict R_square_root
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index,             # <<<<<<<<<<<<<<
 *                    int R_time_var_index, int p_unique_R_number, np.ndarray[DTYPE_t, ndim=3] dR = None):
 *         """
 */

/* Python wrapper */
static int __pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_17R_handling_Cython___init__[] = "\n        Input:        \n        ---------------\n        R - array with noise on various steps. The result of preprocessing\n            the noise input.\n        \n        index - for each step of Kalman filter contains the corresponding index\n                in the array.\n        \n        R_time_var_index - another index in the array R. Computed earlier and passed here.\n        \n        unique_R_number - number of unique noise matrices below which square roots\n            are cached and above which they are computed each time.\n        \n        dR: 3D array[:, :, param_num]\n            derivative of R. Derivative is supported only when R do not change over time\n             \n        Output:\n        --------------\n        Object which has two necessary functions:\n            f_R(k)\n            inv_R_square_root(k)\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_3GPy_6models_18state_space_cython_17R_handling_Cython___init__;
#endif
static int __pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_R = 0;
  PyArrayObject *__pyx_v_index = 0;
  int __pyx_v_R_time_var_index;
  int __pyx_v_p_unique_R_number;
  PyArrayObject *__pyx_v_dR = 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_R,&__pyx_n_s_index,&__pyx_n_s_R_time_var_index,&__pyx_n_s_p_unique_R_number,&__pyx_n_s_dR,0};
    PyObject* values[5] = {0,0,0,0,0};

    /* "GPy/models/state_space_cython.pyx":79
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index,
 *                    int R_time_var_index, int p_unique_R_number, np.ndarray[DTYPE_t, ndim=3] dR = None):             # <<<<<<<<<<<<<<
 *         """
 *         Input:
 */
    values[4] = (PyObject *)((PyArrayObject *)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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_R)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); __PYX_ERR(0, 78, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_R_time_var_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); __PYX_ERR(0, 78, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_unique_R_number)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); __PYX_ERR(0, 78, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dR);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 78, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 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_R = ((PyArrayObject *)values[0]);
    __pyx_v_index = ((PyArrayObject *)values[1]);
    __pyx_v_R_time_var_index = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_R_time_var_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 79, __pyx_L3_error)
    __pyx_v_p_unique_R_number = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_p_unique_R_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 79, __pyx_L3_error)
    __pyx_v_dR = ((PyArrayObject *)values[4]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 78, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_R), __pyx_ptype_5numpy_ndarray, 1, "R", 0))) __PYX_ERR(0, 78, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_index), __pyx_ptype_5numpy_ndarray, 1, "index", 0))) __PYX_ERR(0, 78, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dR), __pyx_ptype_5numpy_ndarray, 1, "dR", 0))) __PYX_ERR(0, 79, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython___init__(((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)__pyx_v_self), __pyx_v_R, __pyx_v_index, __pyx_v_R_time_var_index, __pyx_v_p_unique_R_number, __pyx_v_dR);

  /* "GPy/models/state_space_cython.pyx":78
 *         dict R_square_root
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index,             # <<<<<<<<<<<<<<
 *                    int R_time_var_index, int p_unique_R_number, np.ndarray[DTYPE_t, ndim=3] dR = None):
 *         """
 */

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

static int __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, PyArrayObject *__pyx_v_R, PyArrayObject *__pyx_v_index, int __pyx_v_R_time_var_index, int __pyx_v_p_unique_R_number, PyArrayObject *__pyx_v_dR) {
  int __pyx_v_unique_len;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_R;
  __Pyx_Buffer __pyx_pybuffer_R;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dR;
  __Pyx_Buffer __pyx_pybuffer_dR;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_index;
  __Pyx_Buffer __pyx_pybuffer_index;
  int __pyx_r;
  __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("__init__", 0);
  __pyx_pybuffer_R.pybuffer.buf = NULL;
  __pyx_pybuffer_R.refcount = 0;
  __pyx_pybuffernd_R.data = NULL;
  __pyx_pybuffernd_R.rcbuffer = &__pyx_pybuffer_R;
  __pyx_pybuffer_index.pybuffer.buf = NULL;
  __pyx_pybuffer_index.refcount = 0;
  __pyx_pybuffernd_index.data = NULL;
  __pyx_pybuffernd_index.rcbuffer = &__pyx_pybuffer_index;
  __pyx_pybuffer_dR.pybuffer.buf = NULL;
  __pyx_pybuffer_dR.refcount = 0;
  __pyx_pybuffernd_dR.data = NULL;
  __pyx_pybuffernd_dR.rcbuffer = &__pyx_pybuffer_dR;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R.rcbuffer->pybuffer, (PyObject*)__pyx_v_R, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 78, __pyx_L1_error)
  }
  __pyx_pybuffernd_R.diminfo[0].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R.diminfo[0].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_R.diminfo[1].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_R.diminfo[1].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_R.diminfo[2].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_R.diminfo[2].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_index.rcbuffer->pybuffer, (PyObject*)__pyx_v_index, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 78, __pyx_L1_error)
  }
  __pyx_pybuffernd_index.diminfo[0].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_index.diminfo[0].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_index.diminfo[1].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_index.diminfo[1].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR.rcbuffer->pybuffer, (PyObject*)__pyx_v_dR, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 78, __pyx_L1_error)
  }
  __pyx_pybuffernd_dR.diminfo[0].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dR.diminfo[0].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dR.diminfo[1].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dR.diminfo[1].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dR.diminfo[2].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dR.diminfo[2].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[2];

  /* "GPy/models/state_space_cython.pyx":104
 *         """
 * 
 *         self.R = R             # <<<<<<<<<<<<<<
 *         self.index = index
 *         self.R_time_var_index = R_time_var_index
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_R));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_R));
  __Pyx_GOTREF(__pyx_v_self->R);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->R));
  __pyx_v_self->R = ((PyArrayObject *)__pyx_v_R);

  /* "GPy/models/state_space_cython.pyx":105
 * 
 *         self.R = R
 *         self.index = index             # <<<<<<<<<<<<<<
 *         self.R_time_var_index = R_time_var_index
 *         self.dR = dR
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_index));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_index));
  __Pyx_GOTREF(__pyx_v_self->index);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->index));
  __pyx_v_self->index = ((PyArrayObject *)__pyx_v_index);

  /* "GPy/models/state_space_cython.pyx":106
 *         self.R = R
 *         self.index = index
 *         self.R_time_var_index = R_time_var_index             # <<<<<<<<<<<<<<
 *         self.dR = dR
 * 
 */
  __pyx_v_self->R_time_var_index = __pyx_v_R_time_var_index;

  /* "GPy/models/state_space_cython.pyx":107
 *         self.index = index
 *         self.R_time_var_index = R_time_var_index
 *         self.dR = dR             # <<<<<<<<<<<<<<
 * 
 *         cdef int unique_len = len(np.unique(index))
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_dR));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dR));
  __Pyx_GOTREF(__pyx_v_self->dR);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->dR));
  __pyx_v_self->dR = ((PyArrayObject *)__pyx_v_dR);

  /* "GPy/models/state_space_cython.pyx":109
 *         self.dR = dR
 * 
 *         cdef int unique_len = len(np.unique(index))             # <<<<<<<<<<<<<<
 * 
 *         if (unique_len > p_unique_R_number):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_unique); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, ((PyObject *)__pyx_v_index)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_index));
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_unique_len = __pyx_t_4;

  /* "GPy/models/state_space_cython.pyx":111
 *         cdef int unique_len = len(np.unique(index))
 * 
 *         if (unique_len > p_unique_R_number):             # <<<<<<<<<<<<<<
 *             self.svd_each_time = True
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_unique_len > __pyx_v_p_unique_R_number) != 0);
  if (__pyx_t_5) {

    /* "GPy/models/state_space_cython.pyx":112
 * 
 *         if (unique_len > p_unique_R_number):
 *             self.svd_each_time = True             # <<<<<<<<<<<<<<
 *         else:
 *             self.svd_each_time = False
 */
    __pyx_v_self->svd_each_time = 1;

    /* "GPy/models/state_space_cython.pyx":111
 *         cdef int unique_len = len(np.unique(index))
 * 
 *         if (unique_len > p_unique_R_number):             # <<<<<<<<<<<<<<
 *             self.svd_each_time = True
 *         else:
 */
    goto __pyx_L3;
  }

  /* "GPy/models/state_space_cython.pyx":114
 *             self.svd_each_time = True
 *         else:
 *             self.svd_each_time = False             # <<<<<<<<<<<<<<
 * 
 *         self.R_square_root = {}
 */
  /*else*/ {
    __pyx_v_self->svd_each_time = 0;
  }
  __pyx_L3:;

  /* "GPy/models/state_space_cython.pyx":116
 *             self.svd_each_time = False
 * 
 *         self.R_square_root = {}             # <<<<<<<<<<<<<<
 * 
 *     cpdef Rk(self, int k):
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->R_square_root);
  __Pyx_DECREF(__pyx_v_self->R_square_root);
  __pyx_v_self->R_square_root = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":78
 *         dict R_square_root
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index,             # <<<<<<<<<<<<<<
 *                    int R_time_var_index, int p_unique_R_number, np.ndarray[DTYPE_t, ndim=3] dR = None):
 *         """
 */

  /* 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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":118
 *         self.R_square_root = {}
 * 
 *     cpdef Rk(self, int k):             # <<<<<<<<<<<<<<
 *         return self.R[:,:, <int>self.index[self.R_time_var_index, k]]
 * 
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_3Rk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) {
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Rk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Rk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_3Rk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":119
 * 
 *     cpdef Rk(self, int k):
 *         return self.R[:,:, <int>self.index[self.R_time_var_index, k]]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->R_time_var_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->index), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(((int)__pyx_t_6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__10);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->R), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __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;

  /* "GPy/models/state_space_cython.pyx":118
 *         self.R_square_root = {}
 * 
 *     cpdef Rk(self, int k):             # <<<<<<<<<<<<<<
 *         return self.R[:,:, <int>self.index[self.R_time_var_index, k]]
 * 
 */

  /* 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("GPy.models.state_space_cython.R_handling_Cython.Rk", __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_3GPy_6models_18state_space_cython_17R_handling_Cython_3Rk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_3Rk(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("Rk (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_ERR(0, 118, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.Rk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_2Rk(((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_2Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k) {
  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("Rk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_Rk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __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("GPy.models.state_space_cython.R_handling_Cython.Rk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":122
 * 
 * 
 *     cpdef dRk(self,int k):             # <<<<<<<<<<<<<<
 *         if self.dR is None:
 *             raise ValueError("dR derivative is None")
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_5dRk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dRk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dRk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_5dRk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 122, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":123
 * 
 *     cpdef dRk(self,int k):
 *         if self.dR is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("dR derivative is None")
 * 
 */
  __pyx_t_6 = (((PyObject *)__pyx_v_self->dR) == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (unlikely(__pyx_t_7)) {

    /* "GPy/models/state_space_cython.pyx":124
 *     cpdef dRk(self,int k):
 *         if self.dR is None:
 *             raise ValueError("dR derivative is None")             # <<<<<<<<<<<<<<
 * 
 *         return self.dR # the same dirivative on each iteration
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 124, __pyx_L1_error)

    /* "GPy/models/state_space_cython.pyx":123
 * 
 *     cpdef dRk(self,int k):
 *         if self.dR is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("dR derivative is None")
 * 
 */
  }

  /* "GPy/models/state_space_cython.pyx":126
 *             raise ValueError("dR derivative is None")
 * 
 *         return self.dR # the same dirivative on each iteration             # <<<<<<<<<<<<<<
 * 
 *     cpdef R_isrk(self, int k):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dR));
  __pyx_r = ((PyObject *)__pyx_v_self->dR);
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":122
 * 
 * 
 *     cpdef dRk(self,int k):             # <<<<<<<<<<<<<<
 *         if self.dR is None:
 *             raise ValueError("dR derivative is None")
 */

  /* 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("GPy.models.state_space_cython.R_handling_Cython.dRk", __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_3GPy_6models_18state_space_cython_17R_handling_Cython_5dRk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_5dRk(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("dRk (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_ERR(0, 122, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.dRk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_4dRk(((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_4dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k) {
  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("dRk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_dRk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __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("GPy.models.state_space_cython.R_handling_Cython.dRk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":128
 *         return self.dR # the same dirivative on each iteration
 * 
 *     cpdef R_isrk(self, int k):             # <<<<<<<<<<<<<<
 *         """
 *         Function returns the inverse square root of R matrix on step k.
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_7R_isrk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) {
  int __pyx_v_ind;
  PyArrayObject *__pyx_v_R = 0;
  PyArrayObject *__pyx_v_inv_square_root = 0;
  PyArrayObject *__pyx_v_U = 0;
  PyArrayObject *__pyx_v_S = 0;
  CYTHON_UNUSED PyArrayObject *__pyx_v_Vh = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_R;
  __Pyx_Buffer __pyx_pybuffer_R;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S;
  __Pyx_Buffer __pyx_pybuffer_S;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_U;
  __Pyx_Buffer __pyx_pybuffer_U;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh;
  __Pyx_Buffer __pyx_pybuffer_Vh;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_inv_square_root;
  __Pyx_Buffer __pyx_pybuffer_inv_square_root;
  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;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyArrayObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyArrayObject *__pyx_t_14 = NULL;
  PyArrayObject *__pyx_t_15 = NULL;
  PyArrayObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("R_isrk", 0);
  __pyx_pybuffer_R.pybuffer.buf = NULL;
  __pyx_pybuffer_R.refcount = 0;
  __pyx_pybuffernd_R.data = NULL;
  __pyx_pybuffernd_R.rcbuffer = &__pyx_pybuffer_R;
  __pyx_pybuffer_inv_square_root.pybuffer.buf = NULL;
  __pyx_pybuffer_inv_square_root.refcount = 0;
  __pyx_pybuffernd_inv_square_root.data = NULL;
  __pyx_pybuffernd_inv_square_root.rcbuffer = &__pyx_pybuffer_inv_square_root;
  __pyx_pybuffer_U.pybuffer.buf = NULL;
  __pyx_pybuffer_U.refcount = 0;
  __pyx_pybuffernd_U.data = NULL;
  __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U;
  __pyx_pybuffer_S.pybuffer.buf = NULL;
  __pyx_pybuffer_S.refcount = 0;
  __pyx_pybuffernd_S.data = NULL;
  __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S;
  __pyx_pybuffer_Vh.pybuffer.buf = NULL;
  __pyx_pybuffer_Vh.refcount = 0;
  __pyx_pybuffernd_Vh.data = NULL;
  __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh;
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_R_isrk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_7R_isrk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 128, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":132
 *         Function returns the inverse square root of R matrix on step k.
 *         """
 *         cdef int ind = <int>self.index[self.R_time_var_index, k]             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE_t, ndim=2] R = self.R[:,:, ind ]
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->R_time_var_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->index), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 132, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_ind = ((int)__pyx_t_6);

  /* "GPy/models/state_space_cython.pyx":133
 *         """
 *         cdef int ind = <int>self.index[self.R_time_var_index, k]
 *         cdef np.ndarray[DTYPE_t, ndim=2] R = self.R[:,:, ind ]             # <<<<<<<<<<<<<<
 * 
 *         cdef np.ndarray[DTYPE_t, ndim=2] inv_square_root
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__10);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->R), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __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_ERR(0, 133, __pyx_L1_error)
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_R = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_R.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 133, __pyx_L1_error)
    } else {__pyx_pybuffernd_R.diminfo[0].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R.diminfo[0].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_R.diminfo[1].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_R.diminfo[1].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_7 = 0;
  __pyx_v_R = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "GPy/models/state_space_cython.pyx":141
 *         cdef np.ndarray[DTYPE_t, ndim=2] Vh
 * 
 *         if (R.shape[0] == 1): # 1-D case handle simplier. No storage             # <<<<<<<<<<<<<<
 *         # of the result, just compute it each time.
 *             inv_square_root = np.sqrt( 1.0/R )
 */
  __pyx_t_8 = (((__pyx_v_R->dimensions[0]) == 1) != 0);
  if (__pyx_t_8) {

    /* "GPy/models/state_space_cython.pyx":143
 *         if (R.shape[0] == 1): # 1-D case handle simplier. No storage
 *         # of the result, just compute it each time.
 *             inv_square_root = np.sqrt( 1.0/R )             # <<<<<<<<<<<<<<
 *         else:
 *             if self.svd_each_time:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_float_1_0, ((PyObject *)__pyx_v_R)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __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_ERR(0, 143, __pyx_L1_error)
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_2);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer);
      __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_6 < 0)) {
        PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_inv_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
      }
      __pyx_pybuffernd_inv_square_root.diminfo[0].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_inv_square_root.diminfo[0].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_inv_square_root.diminfo[1].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_inv_square_root.diminfo[1].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 143, __pyx_L1_error)
    }
    __pyx_t_9 = 0;
    __pyx_v_inv_square_root = ((PyArrayObject *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "GPy/models/state_space_cython.pyx":141
 *         cdef np.ndarray[DTYPE_t, ndim=2] Vh
 * 
 *         if (R.shape[0] == 1): # 1-D case handle simplier. No storage             # <<<<<<<<<<<<<<
 *         # of the result, just compute it each time.
 *             inv_square_root = np.sqrt( 1.0/R )
 */
    goto __pyx_L3;
  }

  /* "GPy/models/state_space_cython.pyx":145
 *             inv_square_root = np.sqrt( 1.0/R )
 *         else:
 *             if self.svd_each_time:             # <<<<<<<<<<<<<<
 * 
 *                 U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True,
 */
  /*else*/ {
    __pyx_t_8 = (__pyx_v_self->svd_each_time != 0);
    if (__pyx_t_8) {

      /* "GPy/models/state_space_cython.pyx":147
 *             if self.svd_each_time:
 * 
 *                 U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                           overwrite_a=False,check_finite=True)
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_sp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_svd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __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_ERR(0, 147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_R));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_R));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_R));
      __pyx_t_4 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_full_matrices, Py_False) < 0) __PYX_ERR(0, 147, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_compute_uv, Py_True) < 0) __PYX_ERR(0, 147, __pyx_L1_error)

      /* "GPy/models/state_space_cython.pyx":148
 * 
 *                 U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True,
 *                           overwrite_a=False,check_finite=True)             # <<<<<<<<<<<<<<
 * 
 *                 inv_square_root = U * 1.0/np.sqrt(S)
 */
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_overwrite_a, Py_False) < 0) __PYX_ERR(0, 147, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_check_finite, Py_True) < 0) __PYX_ERR(0, 147, __pyx_L1_error)

      /* "GPy/models/state_space_cython.pyx":147
 *             if self.svd_each_time:
 * 
 *                 U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                           overwrite_a=False,check_finite=True)
 * 
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __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_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 147, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __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_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_1 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        index = 2; __pyx_t_2 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_5), 3) < 0) __PYX_ERR(0, 147, __pyx_L1_error)
        __pyx_t_13 = NULL;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L6_unpacking_done;
        __pyx_L5_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_13 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 147, __pyx_L1_error)
        __pyx_L6_unpacking_done:;
      }
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 147, __pyx_L1_error)
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 147, __pyx_L1_error)
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 147, __pyx_L1_error)
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
        }
        __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 147, __pyx_L1_error)
      }
      __pyx_t_14 = 0;
      __pyx_v_U = ((PyArrayObject *)__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_15 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
        }
        __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 147, __pyx_L1_error)
      }
      __pyx_t_15 = 0;
      __pyx_v_S = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_16 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
        }
        __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 147, __pyx_L1_error)
      }
      __pyx_t_16 = 0;
      __pyx_v_Vh = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "GPy/models/state_space_cython.pyx":150
 *                           overwrite_a=False,check_finite=True)
 * 
 *                 inv_square_root = U * 1.0/np.sqrt(S)             # <<<<<<<<<<<<<<
 *             else:
 *                 if ind in self.R_square_root:
 */
      __pyx_t_3 = PyNumber_Multiply(((PyObject *)__pyx_v_U), __pyx_float_1_0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, ((PyObject *)__pyx_v_S)) : __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_S));
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 150, __pyx_L1_error)
      __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_inv_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
        }
        __pyx_pybuffernd_inv_square_root.diminfo[0].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_inv_square_root.diminfo[0].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_inv_square_root.diminfo[1].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_inv_square_root.diminfo[1].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 150, __pyx_L1_error)
      }
      __pyx_t_9 = 0;
      __pyx_v_inv_square_root = ((PyArrayObject *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "GPy/models/state_space_cython.pyx":145
 *             inv_square_root = np.sqrt( 1.0/R )
 *         else:
 *             if self.svd_each_time:             # <<<<<<<<<<<<<<
 * 
 *                 U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True,
 */
      goto __pyx_L4;
    }

    /* "GPy/models/state_space_cython.pyx":152
 *                 inv_square_root = U * 1.0/np.sqrt(S)
 *             else:
 *                 if ind in self.R_square_root:             # <<<<<<<<<<<<<<
 *                     inv_square_root = self.R_square_root[ind]
 *                 else:
 */
    /*else*/ {
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(__pyx_v_self->R_square_root == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 152, __pyx_L1_error)
      }
      __pyx_t_8 = (__Pyx_PyDict_ContainsTF(__pyx_t_4, __pyx_v_self->R_square_root, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 152, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_17 = (__pyx_t_8 != 0);
      if (__pyx_t_17) {

        /* "GPy/models/state_space_cython.pyx":153
 *             else:
 *                 if ind in self.R_square_root:
 *                     inv_square_root = self.R_square_root[ind]             # <<<<<<<<<<<<<<
 *                 else:
 *                     U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True,
 */
        if (unlikely(__pyx_v_self->R_square_root == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 153, __pyx_L1_error)
        }
        __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->R_square_root, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __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_ERR(0, 153, __pyx_L1_error)
        __pyx_t_9 = ((PyArrayObject *)__pyx_t_2);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer);
          __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_6 < 0)) {
            PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_inv_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
          }
          __pyx_pybuffernd_inv_square_root.diminfo[0].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_inv_square_root.diminfo[0].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_inv_square_root.diminfo[1].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_inv_square_root.diminfo[1].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 153, __pyx_L1_error)
        }
        __pyx_t_9 = 0;
        __pyx_v_inv_square_root = ((PyArrayObject *)__pyx_t_2);
        __pyx_t_2 = 0;

        /* "GPy/models/state_space_cython.pyx":152
 *                 inv_square_root = U * 1.0/np.sqrt(S)
 *             else:
 *                 if ind in self.R_square_root:             # <<<<<<<<<<<<<<
 *                     inv_square_root = self.R_square_root[ind]
 *                 else:
 */
        goto __pyx_L7;
      }

      /* "GPy/models/state_space_cython.pyx":155
 *                     inv_square_root = self.R_square_root[ind]
 *                 else:
 *                     U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                               overwrite_a=False,check_finite=True)
 * 
 */
      /*else*/ {
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_sp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_svd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(((PyObject *)__pyx_v_R));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_R));
        PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_R));
        __pyx_t_3 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_full_matrices, Py_False) < 0) __PYX_ERR(0, 155, __pyx_L1_error)
        if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_compute_uv, Py_True) < 0) __PYX_ERR(0, 155, __pyx_L1_error)

        /* "GPy/models/state_space_cython.pyx":156
 *                 else:
 *                     U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True,
 *                               overwrite_a=False,check_finite=True)             # <<<<<<<<<<<<<<
 * 
 *                     inv_square_root = U * 1.0/np.sqrt(S)
 */
        if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_overwrite_a, Py_False) < 0) __PYX_ERR(0, 155, __pyx_L1_error)
        if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_check_finite, Py_True) < 0) __PYX_ERR(0, 155, __pyx_L1_error)

        /* "GPy/models/state_space_cython.pyx":155
 *                     inv_square_root = self.R_square_root[ind]
 *                 else:
 *                     U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                               overwrite_a=False,check_finite=True)
 * 
 */
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
          PyObject* sequence = __pyx_t_1;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 3)) {
            if (size > 3) __Pyx_RaiseTooManyValuesError(3);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 155, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
            __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
          } else {
            __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
            __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
          }
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_2);
          #else
          __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 155, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext;
          index = 0; __pyx_t_3 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L8_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_3);
          index = 1; __pyx_t_4 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L8_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_4);
          index = 2; __pyx_t_2 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L8_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_2);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_5), 3) < 0) __PYX_ERR(0, 155, __pyx_L1_error)
          __pyx_t_13 = NULL;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L9_unpacking_done;
          __pyx_L8_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_13 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 155, __pyx_L1_error)
          __pyx_L9_unpacking_done:;
        }
        if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 155, __pyx_L1_error)
        if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 155, __pyx_L1_error)
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 155, __pyx_L1_error)
        __pyx_t_14 = ((PyArrayObject *)__pyx_t_3);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
          __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_6 < 0)) {
            PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
          }
          __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 155, __pyx_L1_error)
        }
        __pyx_t_14 = 0;
        __pyx_v_U = ((PyArrayObject *)__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_15 = ((PyArrayObject *)__pyx_t_4);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
          __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
          if (unlikely(__pyx_t_6 < 0)) {
            PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
          }
          __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0];
          if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 155, __pyx_L1_error)
        }
        __pyx_t_15 = 0;
        __pyx_v_S = ((PyArrayObject *)__pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_16 = ((PyArrayObject *)__pyx_t_2);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
          __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_6 < 0)) {
            PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
          }
          __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 155, __pyx_L1_error)
        }
        __pyx_t_16 = 0;
        __pyx_v_Vh = ((PyArrayObject *)__pyx_t_2);
        __pyx_t_2 = 0;

        /* "GPy/models/state_space_cython.pyx":158
 *                               overwrite_a=False,check_finite=True)
 * 
 *                     inv_square_root = U * 1.0/np.sqrt(S)             # <<<<<<<<<<<<<<
 * 
 *                     self.R_square_root[ind] = inv_square_root
 */
        __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_U), __pyx_float_1_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 158, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 158, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_S)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_S));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 158, __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;
        if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 158, __pyx_L1_error)
        __pyx_t_9 = ((PyArrayObject *)__pyx_t_3);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer);
          __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_6 < 0)) {
            PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_inv_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
          }
          __pyx_pybuffernd_inv_square_root.diminfo[0].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_inv_square_root.diminfo[0].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_inv_square_root.diminfo[1].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_inv_square_root.diminfo[1].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 158, __pyx_L1_error)
        }
        __pyx_t_9 = 0;
        __pyx_v_inv_square_root = ((PyArrayObject *)__pyx_t_3);
        __pyx_t_3 = 0;

        /* "GPy/models/state_space_cython.pyx":160
 *                     inv_square_root = U * 1.0/np.sqrt(S)
 * 
 *                     self.R_square_root[ind] = inv_square_root             # <<<<<<<<<<<<<<
 * 
 *         return inv_square_root
 */
        if (unlikely(__pyx_v_self->R_square_root == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 160, __pyx_L1_error)
        }
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (unlikely(PyDict_SetItem(__pyx_v_self->R_square_root, __pyx_t_3, ((PyObject *)__pyx_v_inv_square_root)) < 0)) __PYX_ERR(0, 160, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __pyx_L7:;
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  /* "GPy/models/state_space_cython.pyx":162
 *                     self.R_square_root[ind] = inv_square_root
 * 
 *         return inv_square_root             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_inv_square_root));
  __pyx_r = ((PyObject *)__pyx_v_inv_square_root);
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":128
 *         return self.dR # the same dirivative on each iteration
 * 
 *     cpdef R_isrk(self, int k):             # <<<<<<<<<<<<<<
 *         """
 *         Function returns the inverse square root of R matrix on step k.
 */

  /* 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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.R_isrk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_R);
  __Pyx_XDECREF((PyObject *)__pyx_v_inv_square_root);
  __Pyx_XDECREF((PyObject *)__pyx_v_U);
  __Pyx_XDECREF((PyObject *)__pyx_v_S);
  __Pyx_XDECREF((PyObject *)__pyx_v_Vh);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_7R_isrk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_17R_handling_Cython_6R_isrk[] = "\n        Function returns the inverse square root of R matrix on step k.\n        ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_7R_isrk(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("R_isrk (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_ERR(0, 128, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.R_isrk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_6R_isrk(((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_6R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k) {
  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("R_isrk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_R_isrk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __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("GPy.models.state_space_cython.R_handling_Cython.R_isrk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_8__reduce_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)__pyx_v_self));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_8__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.R, self.R_square_root, self.R_time_var_index, self.dR, self.index, self.svd_each_time)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->R_time_var_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->svd_each_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->R));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->R));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->R));
  __Pyx_INCREF(__pyx_v_self->R_square_root);
  __Pyx_GIVEREF(__pyx_v_self->R_square_root);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->R_square_root);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dR));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->dR));
  PyTuple_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_v_self->dR));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->index));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->index));
  PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_v_self->index));
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.R, self.R_square_root, self.R_time_var_index, self.dR, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":7
 *     state = (self.R, self.R_square_root, self.R_time_var_index, self.dR, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.R is not None or self.R_square_root is not None or self.dR is not None or self.index is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.R, self.R_square_root, self.R_time_var_index, self.dR, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.R is not None or self.R_square_root is not None or self.dR is not None or self.index is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_R_handling_Cython, (type(self), 0x9e97ca7, None), state
 */
  /*else*/ {
    __pyx_t_4 = (((PyObject *)__pyx_v_self->R) != Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->R_square_root != ((PyObject*)Py_None));
    __pyx_t_4 = (__pyx_t_6 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_4 = (((PyObject *)__pyx_v_self->dR) != Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (((PyObject *)__pyx_v_self->index) != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_5;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.R is not None or self.R_square_root is not None or self.dR is not None or self.index is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_R_handling_Cython, (type(self), 0x9e97ca7, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":13
 *         use_setstate = self.R is not None or self.R_square_root is not None or self.dR is not None or self.index is not None
 *     if use_setstate:
 *         return __pyx_unpickle_R_handling_Cython, (type(self), 0x9e97ca7, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_R_handling_Cython, (type(self), 0x9e97ca7, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle_R_handling_Cython); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_166296743);
    __Pyx_GIVEREF(__pyx_int_166296743);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_166296743);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.R is not None or self.R_square_root is not None or self.dR is not None or self.index is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_R_handling_Cython, (type(self), 0x9e97ca7, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_R_handling_Cython, (type(self), 0x9e97ca7, None), state
 *     else:
 *         return __pyx_unpickle_R_handling_Cython, (type(self), 0x9e97ca7, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_R_handling_Cython__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_R_handling_Cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_166296743);
    __Pyx_GIVEREF(__pyx_int_166296743);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_166296743);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_R_handling_Cython, (type(self), 0x9e97ca7, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_R_handling_Cython__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_10__setstate_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_10__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  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("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_R_handling_Cython, (type(self), 0x9e97ca7, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_R_handling_Cython__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_R_handling_Cython__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_R_handling_Cython, (type(self), 0x9e97ca7, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_R_handling_Cython__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":172
 *         np.ndarray dH
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] H, int H_time_var_index,             # <<<<<<<<<<<<<<
 *                  np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, int R_time_var_index,
 *                  int unique_R_number, np.ndarray[DTYPE_t, ndim=3] dH = None,
 */

/* Python wrapper */
static int __pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_H = 0;
  int __pyx_v_H_time_var_index;
  PyArrayObject *__pyx_v_R = 0;
  PyArrayObject *__pyx_v_index = 0;
  int __pyx_v_R_time_var_index;
  int __pyx_v_unique_R_number;
  PyArrayObject *__pyx_v_dH = 0;
  PyArrayObject *__pyx_v_dR = 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_H,&__pyx_n_s_H_time_var_index,&__pyx_n_s_R,&__pyx_n_s_index,&__pyx_n_s_R_time_var_index,&__pyx_n_s_unique_R_number,&__pyx_n_s_dH,&__pyx_n_s_dR,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};

    /* "GPy/models/state_space_cython.pyx":174
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] H, int H_time_var_index,
 *                  np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, int R_time_var_index,
 *                  int unique_R_number, np.ndarray[DTYPE_t, ndim=3] dH = None,             # <<<<<<<<<<<<<<
 *                  np.ndarray[DTYPE_t, ndim=3] dR=None):
 * 
 */
    values[6] = (PyObject *)((PyArrayObject *)Py_None);

    /* "GPy/models/state_space_cython.pyx":175
 *                  np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, int R_time_var_index,
 *                  int unique_R_number, np.ndarray[DTYPE_t, ndim=3] dH = None,
 *                  np.ndarray[DTYPE_t, ndim=3] dR=None):             # <<<<<<<<<<<<<<
 * 
 *         super(Std_Measurement_Callables_Cython,self).__init__(R, index, R_time_var_index, unique_R_number,dR)
 */
    values[7] = (PyObject *)((PyArrayObject *)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  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_H)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_H_time_var_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 1); __PYX_ERR(0, 172, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_R)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 2); __PYX_ERR(0, 172, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 3); __PYX_ERR(0, 172, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_R_time_var_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 4); __PYX_ERR(0, 172, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unique_R_number)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 5); __PYX_ERR(0, 172, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dH);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dR);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 172, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 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_H = ((PyArrayObject *)values[0]);
    __pyx_v_H_time_var_index = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_H_time_var_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 172, __pyx_L3_error)
    __pyx_v_R = ((PyArrayObject *)values[2]);
    __pyx_v_index = ((PyArrayObject *)values[3]);
    __pyx_v_R_time_var_index = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_R_time_var_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 173, __pyx_L3_error)
    __pyx_v_unique_R_number = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_unique_R_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 174, __pyx_L3_error)
    __pyx_v_dH = ((PyArrayObject *)values[6]);
    __pyx_v_dR = ((PyArrayObject *)values[7]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 172, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_H), __pyx_ptype_5numpy_ndarray, 1, "H", 0))) __PYX_ERR(0, 172, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_R), __pyx_ptype_5numpy_ndarray, 1, "R", 0))) __PYX_ERR(0, 173, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_index), __pyx_ptype_5numpy_ndarray, 1, "index", 0))) __PYX_ERR(0, 173, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dH), __pyx_ptype_5numpy_ndarray, 1, "dH", 0))) __PYX_ERR(0, 174, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dR), __pyx_ptype_5numpy_ndarray, 1, "dR", 0))) __PYX_ERR(0, 175, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython___init__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_H, __pyx_v_H_time_var_index, __pyx_v_R, __pyx_v_index, __pyx_v_R_time_var_index, __pyx_v_unique_R_number, __pyx_v_dH, __pyx_v_dR);

  /* "GPy/models/state_space_cython.pyx":172
 *         np.ndarray dH
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] H, int H_time_var_index,             # <<<<<<<<<<<<<<
 *                  np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, int R_time_var_index,
 *                  int unique_R_number, np.ndarray[DTYPE_t, ndim=3] dH = None,
 */

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

static int __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, PyArrayObject *__pyx_v_H, int __pyx_v_H_time_var_index, PyArrayObject *__pyx_v_R, PyArrayObject *__pyx_v_index, int __pyx_v_R_time_var_index, int __pyx_v_unique_R_number, PyArrayObject *__pyx_v_dH, PyArrayObject *__pyx_v_dR) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_H;
  __Pyx_Buffer __pyx_pybuffer_H;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_R;
  __Pyx_Buffer __pyx_pybuffer_R;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dH;
  __Pyx_Buffer __pyx_pybuffer_dH;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dR;
  __Pyx_Buffer __pyx_pybuffer_dR;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_index;
  __Pyx_Buffer __pyx_pybuffer_index;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __pyx_pybuffer_H.pybuffer.buf = NULL;
  __pyx_pybuffer_H.refcount = 0;
  __pyx_pybuffernd_H.data = NULL;
  __pyx_pybuffernd_H.rcbuffer = &__pyx_pybuffer_H;
  __pyx_pybuffer_R.pybuffer.buf = NULL;
  __pyx_pybuffer_R.refcount = 0;
  __pyx_pybuffernd_R.data = NULL;
  __pyx_pybuffernd_R.rcbuffer = &__pyx_pybuffer_R;
  __pyx_pybuffer_index.pybuffer.buf = NULL;
  __pyx_pybuffer_index.refcount = 0;
  __pyx_pybuffernd_index.data = NULL;
  __pyx_pybuffernd_index.rcbuffer = &__pyx_pybuffer_index;
  __pyx_pybuffer_dH.pybuffer.buf = NULL;
  __pyx_pybuffer_dH.refcount = 0;
  __pyx_pybuffernd_dH.data = NULL;
  __pyx_pybuffernd_dH.rcbuffer = &__pyx_pybuffer_dH;
  __pyx_pybuffer_dR.pybuffer.buf = NULL;
  __pyx_pybuffer_dR.refcount = 0;
  __pyx_pybuffernd_dR.data = NULL;
  __pyx_pybuffernd_dR.rcbuffer = &__pyx_pybuffer_dR;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_H.rcbuffer->pybuffer, (PyObject*)__pyx_v_H, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 172, __pyx_L1_error)
  }
  __pyx_pybuffernd_H.diminfo[0].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_H.diminfo[0].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_H.diminfo[1].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_H.diminfo[1].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_H.diminfo[2].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_H.diminfo[2].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R.rcbuffer->pybuffer, (PyObject*)__pyx_v_R, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 172, __pyx_L1_error)
  }
  __pyx_pybuffernd_R.diminfo[0].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R.diminfo[0].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_R.diminfo[1].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_R.diminfo[1].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_R.diminfo[2].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_R.diminfo[2].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_index.rcbuffer->pybuffer, (PyObject*)__pyx_v_index, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 172, __pyx_L1_error)
  }
  __pyx_pybuffernd_index.diminfo[0].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_index.diminfo[0].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_index.diminfo[1].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_index.diminfo[1].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dH.rcbuffer->pybuffer, (PyObject*)__pyx_v_dH, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 172, __pyx_L1_error)
  }
  __pyx_pybuffernd_dH.diminfo[0].strides = __pyx_pybuffernd_dH.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dH.diminfo[0].shape = __pyx_pybuffernd_dH.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dH.diminfo[1].strides = __pyx_pybuffernd_dH.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dH.diminfo[1].shape = __pyx_pybuffernd_dH.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dH.diminfo[2].strides = __pyx_pybuffernd_dH.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dH.diminfo[2].shape = __pyx_pybuffernd_dH.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR.rcbuffer->pybuffer, (PyObject*)__pyx_v_dR, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 172, __pyx_L1_error)
  }
  __pyx_pybuffernd_dR.diminfo[0].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dR.diminfo[0].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dR.diminfo[1].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dR.diminfo[1].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dR.diminfo[2].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dR.diminfo[2].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[2];

  /* "GPy/models/state_space_cython.pyx":177
 *                  np.ndarray[DTYPE_t, ndim=3] dR=None):
 * 
 *         super(Std_Measurement_Callables_Cython,self).__init__(R, index, R_time_var_index, unique_R_number,dR)             # <<<<<<<<<<<<<<
 * 
 *         self.H = H
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_R_time_var_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_unique_R_number); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && 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);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_R), ((PyObject *)__pyx_v_index), __pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_dR)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_R), ((PyObject *)__pyx_v_index), __pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_dR)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(5+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 177, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_R));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_R));
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_R));
    __Pyx_INCREF(((PyObject *)__pyx_v_index));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_index));
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_index));
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_dR));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dR));
    PyTuple_SET_ITEM(__pyx_t_7, 4+__pyx_t_6, ((PyObject *)__pyx_v_dR));
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":179
 *         super(Std_Measurement_Callables_Cython,self).__init__(R, index, R_time_var_index, unique_R_number,dR)
 * 
 *         self.H = H             # <<<<<<<<<<<<<<
 *         self.H_time_var_index = H_time_var_index
 *         self.dH = dH
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_H));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_H));
  __Pyx_GOTREF(__pyx_v_self->H);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->H));
  __pyx_v_self->H = ((PyArrayObject *)__pyx_v_H);

  /* "GPy/models/state_space_cython.pyx":180
 * 
 *         self.H = H
 *         self.H_time_var_index = H_time_var_index             # <<<<<<<<<<<<<<
 *         self.dH = dH
 * 
 */
  __pyx_v_self->H_time_var_index = __pyx_v_H_time_var_index;

  /* "GPy/models/state_space_cython.pyx":181
 *         self.H = H
 *         self.H_time_var_index = H_time_var_index
 *         self.dH = dH             # <<<<<<<<<<<<<<
 * 
 *     cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] H):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_dH));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dH));
  __Pyx_GOTREF(__pyx_v_self->dH);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->dH));
  __pyx_v_self->dH = ((PyArrayObject *)__pyx_v_dH);

  /* "GPy/models/state_space_cython.pyx":172
 *         np.ndarray dH
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] H, int H_time_var_index,             # <<<<<<<<<<<<<<
 *                  np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, int R_time_var_index,
 *                  int unique_R_number, np.ndarray[DTYPE_t, ndim=3] dH = None,
 */

  /* 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_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":183
 *         self.dH = dH
 * 
 *     cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] H):             # <<<<<<<<<<<<<<
 *         """
 *         function (k, x_{k}, H_{k}). Measurement function.
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_3f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_f_h(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_H, int __pyx_skip_dispatch) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_H;
  __Pyx_Buffer __pyx_pybuffer_H;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("f_h", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __pyx_pybuffer_H.pybuffer.buf = NULL;
  __pyx_pybuffer_H.refcount = 0;
  __pyx_pybuffernd_H.data = NULL;
  __pyx_pybuffernd_H.rcbuffer = &__pyx_pybuffer_H;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 183, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_H.rcbuffer->pybuffer, (PyObject*)__pyx_v_H, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 183, __pyx_L1_error)
  }
  __pyx_pybuffernd_H.diminfo[0].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_H.diminfo[0].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_H.diminfo[1].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_H.diminfo[1].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[1];
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_f_h); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_3f_h)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __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_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_H)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_H)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 183, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(((PyObject *)__pyx_v_m));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_m));
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m));
          __Pyx_INCREF(((PyObject *)__pyx_v_H));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_H));
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_H));
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __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;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":191
 *         """
 * 
 *         return np.dot(H, m)             # <<<<<<<<<<<<<<
 * 
 *     cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && 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_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_H), ((PyObject *)__pyx_v_m)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_H), ((PyObject *)__pyx_v_m)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 191, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_H));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_H));
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_H));
    __Pyx_INCREF(((PyObject *)__pyx_v_m));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_m));
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":183
 *         self.dH = dH
 * 
 *     cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] H):             # <<<<<<<<<<<<<<
 *         """
 *         function (k, x_{k}, H_{k}). Measurement function.
 */

  /* 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_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_3f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_2f_h[] = "\n        function (k, x_{k}, H_{k}). Measurement function.\n            k (iteration number), starts at 0\n            x_{k} state \n            H_{k} Jacobian matrices of f_h. In the linear case it is exactly H_{k}.\n        ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_3f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_m = 0;
  PyArrayObject *__pyx_v_H = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("f_h (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_H,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, 1); __PYX_ERR(0, 183, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_H)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, 2); __PYX_ERR(0, 183, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f_h") < 0)) __PYX_ERR(0, 183, __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_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L3_error)
    __pyx_v_m = ((PyArrayObject *)values[1]);
    __pyx_v_H = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 183, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) __PYX_ERR(0, 183, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_H), __pyx_ptype_5numpy_ndarray, 1, "H", 0))) __PYX_ERR(0, 183, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_2f_h(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __pyx_v_H);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_2f_h(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_H) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_H;
  __Pyx_Buffer __pyx_pybuffer_H;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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("f_h", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __pyx_pybuffer_H.pybuffer.buf = NULL;
  __pyx_pybuffer_H.refcount = 0;
  __pyx_pybuffernd_H.data = NULL;
  __pyx_pybuffernd_H.rcbuffer = &__pyx_pybuffer_H;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 183, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_H.rcbuffer->pybuffer, (PyObject*)__pyx_v_H, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 183, __pyx_L1_error)
  }
  __pyx_pybuffernd_H.diminfo[0].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_H.diminfo[0].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_H.diminfo[1].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_H.diminfo[1].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_f_h(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m), ((PyArrayObject *)__pyx_v_H), 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":193
 *         return np.dot(H, m)
 * 
 *     cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix             # <<<<<<<<<<<<<<
 *         """
 *         function (k, m, P) return Jacobian of measurement function, it is
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_5Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred;
  __Pyx_Buffer __pyx_pybuffer_P_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred;
  __Pyx_Buffer __pyx_pybuffer_m_pred;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Hk", 0);
  __pyx_pybuffer_m_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_m_pred.refcount = 0;
  __pyx_pybuffernd_m_pred.data = NULL;
  __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred;
  __pyx_pybuffer_P_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_P_pred.refcount = 0;
  __pyx_pybuffernd_P_pred.data = NULL;
  __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 193, __pyx_L1_error)
  }
  __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 193, __pyx_L1_error)
  }
  __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1];
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Hk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_5Hk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __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_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m_pred), ((PyObject *)__pyx_v_P_pred)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m_pred), ((PyObject *)__pyx_v_P_pred)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 193, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(((PyObject *)__pyx_v_m_pred));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred));
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m_pred));
          __Pyx_INCREF(((PyObject *)__pyx_v_P_pred));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred));
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_P_pred));
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __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;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":202
 *         """
 * 
 *         return self.H[:,:, <int>self.index[self.H_time_var_index, k]]             # <<<<<<<<<<<<<<
 * 
 *     cpdef dHk(self,int k):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->H_time_var_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->__pyx_base.index), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(((int)__pyx_t_6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__10);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->H), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __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;

  /* "GPy/models/state_space_cython.pyx":193
 *         return np.dot(H, m)
 * 
 *     cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix             # <<<<<<<<<<<<<<
 *         """
 *         function (k, m, P) return Jacobian of measurement function, it is
 */

  /* 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_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_5Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_4Hk[] = "\n        function (k, m, P) return Jacobian of measurement function, it is\n            passed into p_h.\n            k (iteration number), starts at 0\n            m: point where Jacobian is evaluated\n            P: parameter for Jacobian, usually covariance matrix.\n        ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_5Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_m_pred = 0;
  PyArrayObject *__pyx_v_P_pred = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("Hk (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m_pred,&__pyx_n_s_P_pred,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m_pred)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, 1); __PYX_ERR(0, 193, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_P_pred)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, 2); __PYX_ERR(0, 193, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Hk") < 0)) __PYX_ERR(0, 193, __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_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 193, __pyx_L3_error)
    __pyx_v_m_pred = ((PyArrayObject *)values[1]);
    __pyx_v_P_pred = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 193, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m_pred), __pyx_ptype_5numpy_ndarray, 1, "m_pred", 0))) __PYX_ERR(0, 193, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P_pred), __pyx_ptype_5numpy_ndarray, 1, "P_pred", 0))) __PYX_ERR(0, 193, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_4Hk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m_pred, __pyx_v_P_pred);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_4Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred;
  __Pyx_Buffer __pyx_pybuffer_P_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred;
  __Pyx_Buffer __pyx_pybuffer_m_pred;
  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("Hk", 0);
  __pyx_pybuffer_m_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_m_pred.refcount = 0;
  __pyx_pybuffernd_m_pred.data = NULL;
  __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred;
  __pyx_pybuffer_P_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_P_pred.refcount = 0;
  __pyx_pybuffernd_P_pred.data = NULL;
  __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 193, __pyx_L1_error)
  }
  __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 193, __pyx_L1_error)
  }
  __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_Hk(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m_pred), ((PyArrayObject *)__pyx_v_P_pred), 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":204
 *         return self.H[:,:, <int>self.index[self.H_time_var_index, k]]
 * 
 *     cpdef dHk(self,int k):             # <<<<<<<<<<<<<<
 *         if self.dH is None:
 *             raise ValueError("dH derivative is None")
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_7dHk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dHk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dHk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_7dHk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":205
 * 
 *     cpdef dHk(self,int k):
 *         if self.dH is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("dH derivative is None")
 * 
 */
  __pyx_t_6 = (((PyObject *)__pyx_v_self->dH) == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (unlikely(__pyx_t_7)) {

    /* "GPy/models/state_space_cython.pyx":206
 *     cpdef dHk(self,int k):
 *         if self.dH is None:
 *             raise ValueError("dH derivative is None")             # <<<<<<<<<<<<<<
 * 
 *         return self.dH # the same dirivative on each iteration
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 206, __pyx_L1_error)

    /* "GPy/models/state_space_cython.pyx":205
 * 
 *     cpdef dHk(self,int k):
 *         if self.dH is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("dH derivative is None")
 * 
 */
  }

  /* "GPy/models/state_space_cython.pyx":208
 *             raise ValueError("dH derivative is None")
 * 
 *         return self.dH # the same dirivative on each iteration             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dH));
  __pyx_r = ((PyObject *)__pyx_v_self->dH);
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":204
 *         return self.H[:,:, <int>self.index[self.H_time_var_index, k]]
 * 
 *     cpdef dHk(self,int k):             # <<<<<<<<<<<<<<
 *         if self.dH is None:
 *             raise ValueError("dH derivative is None")
 */

  /* 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("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.dHk", __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_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_7dHk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_7dHk(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("dHk (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_ERR(0, 204, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.dHk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_6dHk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_6dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k) {
  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("dHk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_dHk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __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("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.dHk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_8__reduce_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)__pyx_v_self));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_8__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.H, self.H_time_var_index, self.R, self.R_square_root, self.R_time_var_index, self.dH, self.dR, self.index, self.svd_each_time)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->H_time_var_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.R_time_var_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->__pyx_base.svd_each_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->H));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->H));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self->H));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.R));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.R));
  PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_self->__pyx_base.R));
  __Pyx_INCREF(__pyx_v_self->__pyx_base.R_square_root);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.R_square_root);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_self->__pyx_base.R_square_root);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dH));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->dH));
  PyTuple_SET_ITEM(__pyx_t_4, 5, ((PyObject *)__pyx_v_self->dH));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.dR));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.dR));
  PyTuple_SET_ITEM(__pyx_t_4, 6, ((PyObject *)__pyx_v_self->__pyx_base.dR));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.index));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.index));
  PyTuple_SET_ITEM(__pyx_t_4, 7, ((PyObject *)__pyx_v_self->__pyx_base.index));
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 8, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.H, self.H_time_var_index, self.R, self.R_square_root, self.R_time_var_index, self.dH, self.dR, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_4 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v__dict = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":7
 *     state = (self.H, self.H_time_var_index, self.R, self.R_square_root, self.R_time_var_index, self.dH, self.dR, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_5 = (__pyx_v__dict != Py_None);
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v__dict);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.H is not None or self.R is not None or self.R_square_root is not None or self.dH is not None or self.dR is not None or self.index is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.H, self.H_time_var_index, self.R, self.R_square_root, self.R_time_var_index, self.dH, self.dR, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.H is not None or self.R is not None or self.R_square_root is not None or self.dH is not None or self.dR is not None or self.index is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Std_Measurement_Callables_Cython, (type(self), 0x706c35f, None), state
 */
  /*else*/ {
    __pyx_t_5 = (((PyObject *)__pyx_v_self->H) != Py_None);
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_7 = (((PyObject *)__pyx_v_self->__pyx_base.R) != Py_None);
    __pyx_t_5 = (__pyx_t_7 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_6 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->__pyx_base.R_square_root != ((PyObject*)Py_None));
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_7 = (((PyObject *)__pyx_v_self->dH) != Py_None);
    __pyx_t_5 = (__pyx_t_7 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_6 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->__pyx_base.dR) != Py_None);
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_7 = (((PyObject *)__pyx_v_self->__pyx_base.index) != Py_None);
    __pyx_t_5 = (__pyx_t_7 != 0);
    __pyx_t_6 = __pyx_t_5;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_6;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.H is not None or self.R is not None or self.R_square_root is not None or self.dH is not None or self.dR is not None or self.index is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Std_Measurement_Callables_Cython, (type(self), 0x706c35f, None), state
 *     else:
 */
  __pyx_t_6 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":13
 *         use_setstate = self.H is not None or self.R is not None or self.R_square_root is not None or self.dH is not None or self.dR is not None or self.index is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Std_Measurement_Callables_Cython, (type(self), 0x706c35f, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Std_Measurement_Callables_Cython, (type(self), 0x706c35f, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pyx_unpickle_Std_Measurement_C); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_117883743);
    __Pyx_GIVEREF(__pyx_int_117883743);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_117883743);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.H is not None or self.R is not None or self.R_square_root is not None or self.dH is not None or self.dR is not None or self.index is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Std_Measurement_Callables_Cython, (type(self), 0x706c35f, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Std_Measurement_Callables_Cython, (type(self), 0x706c35f, None), state
 *     else:
 *         return __pyx_unpickle_Std_Measurement_Callables_Cython, (type(self), 0x706c35f, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle_Std_Measurement_C); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_117883743);
    __Pyx_GIVEREF(__pyx_int_117883743);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_117883743);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_state);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* 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("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Std_Measurement_Callables_Cython, (type(self), 0x706c35f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_10__setstate_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_10__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  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("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Std_Measurement_Callables_Cython, (type(self), 0x706c35f, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Std_Measurement_Callables_Cython__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Std_Measurement_Callables_Cython, (type(self), 0x706c35f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":222
 *         bint svd_each_time
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] Q, np.ndarray[DTYPE_t, ndim=2] index,             # <<<<<<<<<<<<<<
 *                  int Q_time_var_index, int p_unique_Q_number, np.ndarray[DTYPE_t, ndim=3] dQ = None):
 *         """
 */

/* Python wrapper */
static int __pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__[] = "\n        Input:        \n        ---------------\n        Q - array with noise on various steps. The result of preprocessing\n            the noise input.\n        \n        index - for each step of Kalman filter contains the corresponding index\n                in the array.\n        \n        Q_time_var_index - another index in the array R. Computed earlier and passed here.\n        \n        unique_Q_number - number of unique noise matrices below which square roots\n            are cached and above which they are computed each time.\n            \n        dQ: 3D array[:, :, param_num]\n            derivative of Q. Derivative is supported only when Q do not change over time\n            \n        Output:\n        --------------\n        Object which has three necessary functions:\n            Qk(k)\n            dQk(k)\n            Q_srkt(k)\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__;
#endif
static int __pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_Q = 0;
  PyArrayObject *__pyx_v_index = 0;
  int __pyx_v_Q_time_var_index;
  int __pyx_v_p_unique_Q_number;
  PyArrayObject *__pyx_v_dQ = 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_Q,&__pyx_n_s_index,&__pyx_n_s_Q_time_var_index,&__pyx_n_s_p_unique_Q_number,&__pyx_n_s_dQ,0};
    PyObject* values[5] = {0,0,0,0,0};

    /* "GPy/models/state_space_cython.pyx":223
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] Q, np.ndarray[DTYPE_t, ndim=2] index,
 *                  int Q_time_var_index, int p_unique_Q_number, np.ndarray[DTYPE_t, ndim=3] dQ = None):             # <<<<<<<<<<<<<<
 *         """
 *         Input:
 */
    values[4] = (PyObject *)((PyArrayObject *)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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Q)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); __PYX_ERR(0, 222, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Q_time_var_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); __PYX_ERR(0, 222, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_unique_Q_number)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); __PYX_ERR(0, 222, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dQ);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 222, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 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_Q = ((PyArrayObject *)values[0]);
    __pyx_v_index = ((PyArrayObject *)values[1]);
    __pyx_v_Q_time_var_index = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_Q_time_var_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 223, __pyx_L3_error)
    __pyx_v_p_unique_Q_number = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_p_unique_Q_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 223, __pyx_L3_error)
    __pyx_v_dQ = ((PyArrayObject *)values[4]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 222, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Q), __pyx_ptype_5numpy_ndarray, 1, "Q", 0))) __PYX_ERR(0, 222, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_index), __pyx_ptype_5numpy_ndarray, 1, "index", 0))) __PYX_ERR(0, 222, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dQ), __pyx_ptype_5numpy_ndarray, 1, "dQ", 0))) __PYX_ERR(0, 223, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)__pyx_v_self), __pyx_v_Q, __pyx_v_index, __pyx_v_Q_time_var_index, __pyx_v_p_unique_Q_number, __pyx_v_dQ);

  /* "GPy/models/state_space_cython.pyx":222
 *         bint svd_each_time
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] Q, np.ndarray[DTYPE_t, ndim=2] index,             # <<<<<<<<<<<<<<
 *                  int Q_time_var_index, int p_unique_Q_number, np.ndarray[DTYPE_t, ndim=3] dQ = None):
 *         """
 */

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

static int __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, PyArrayObject *__pyx_v_Q, PyArrayObject *__pyx_v_index, int __pyx_v_Q_time_var_index, int __pyx_v_p_unique_Q_number, PyArrayObject *__pyx_v_dQ) {
  int __pyx_v_unique_len;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Q;
  __Pyx_Buffer __pyx_pybuffer_Q;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dQ;
  __Pyx_Buffer __pyx_pybuffer_dQ;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_index;
  __Pyx_Buffer __pyx_pybuffer_index;
  int __pyx_r;
  __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("__init__", 0);
  __pyx_pybuffer_Q.pybuffer.buf = NULL;
  __pyx_pybuffer_Q.refcount = 0;
  __pyx_pybuffernd_Q.data = NULL;
  __pyx_pybuffernd_Q.rcbuffer = &__pyx_pybuffer_Q;
  __pyx_pybuffer_index.pybuffer.buf = NULL;
  __pyx_pybuffer_index.refcount = 0;
  __pyx_pybuffernd_index.data = NULL;
  __pyx_pybuffernd_index.rcbuffer = &__pyx_pybuffer_index;
  __pyx_pybuffer_dQ.pybuffer.buf = NULL;
  __pyx_pybuffer_dQ.refcount = 0;
  __pyx_pybuffernd_dQ.data = NULL;
  __pyx_pybuffernd_dQ.rcbuffer = &__pyx_pybuffer_dQ;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Q.rcbuffer->pybuffer, (PyObject*)__pyx_v_Q, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 222, __pyx_L1_error)
  }
  __pyx_pybuffernd_Q.diminfo[0].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Q.diminfo[0].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Q.diminfo[1].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Q.diminfo[1].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_Q.diminfo[2].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_Q.diminfo[2].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_index.rcbuffer->pybuffer, (PyObject*)__pyx_v_index, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 222, __pyx_L1_error)
  }
  __pyx_pybuffernd_index.diminfo[0].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_index.diminfo[0].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_index.diminfo[1].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_index.diminfo[1].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer, (PyObject*)__pyx_v_dQ, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 222, __pyx_L1_error)
  }
  __pyx_pybuffernd_dQ.diminfo[0].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dQ.diminfo[0].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dQ.diminfo[1].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dQ.diminfo[1].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dQ.diminfo[2].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dQ.diminfo[2].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[2];

  /* "GPy/models/state_space_cython.pyx":249
 *         """
 * 
 *         self.Q = Q             # <<<<<<<<<<<<<<
 *         self.index = index
 *         self.Q_time_var_index = Q_time_var_index
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_Q));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Q));
  __Pyx_GOTREF(__pyx_v_self->Q);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->Q));
  __pyx_v_self->Q = ((PyArrayObject *)__pyx_v_Q);

  /* "GPy/models/state_space_cython.pyx":250
 * 
 *         self.Q = Q
 *         self.index = index             # <<<<<<<<<<<<<<
 *         self.Q_time_var_index = Q_time_var_index
 *         self.dQ = dQ
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_index));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_index));
  __Pyx_GOTREF(__pyx_v_self->index);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->index));
  __pyx_v_self->index = ((PyArrayObject *)__pyx_v_index);

  /* "GPy/models/state_space_cython.pyx":251
 *         self.Q = Q
 *         self.index = index
 *         self.Q_time_var_index = Q_time_var_index             # <<<<<<<<<<<<<<
 *         self.dQ = dQ
 * 
 */
  __pyx_v_self->Q_time_var_index = __pyx_v_Q_time_var_index;

  /* "GPy/models/state_space_cython.pyx":252
 *         self.index = index
 *         self.Q_time_var_index = Q_time_var_index
 *         self.dQ = dQ             # <<<<<<<<<<<<<<
 * 
 *         cdef int unique_len = len(np.unique(index))
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_dQ));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dQ));
  __Pyx_GOTREF(__pyx_v_self->dQ);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->dQ));
  __pyx_v_self->dQ = ((PyArrayObject *)__pyx_v_dQ);

  /* "GPy/models/state_space_cython.pyx":254
 *         self.dQ = dQ
 * 
 *         cdef int unique_len = len(np.unique(index))             # <<<<<<<<<<<<<<
 * 
 *         if (unique_len > p_unique_Q_number):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_unique); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, ((PyObject *)__pyx_v_index)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_index));
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 254, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_unique_len = __pyx_t_4;

  /* "GPy/models/state_space_cython.pyx":256
 *         cdef int unique_len = len(np.unique(index))
 * 
 *         if (unique_len > p_unique_Q_number):             # <<<<<<<<<<<<<<
 *             self.svd_each_time = True
 *         else:
 */
  __pyx_t_5 = ((__pyx_v_unique_len > __pyx_v_p_unique_Q_number) != 0);
  if (__pyx_t_5) {

    /* "GPy/models/state_space_cython.pyx":257
 * 
 *         if (unique_len > p_unique_Q_number):
 *             self.svd_each_time = True             # <<<<<<<<<<<<<<
 *         else:
 *             self.svd_each_time = False
 */
    __pyx_v_self->svd_each_time = 1;

    /* "GPy/models/state_space_cython.pyx":256
 *         cdef int unique_len = len(np.unique(index))
 * 
 *         if (unique_len > p_unique_Q_number):             # <<<<<<<<<<<<<<
 *             self.svd_each_time = True
 *         else:
 */
    goto __pyx_L3;
  }

  /* "GPy/models/state_space_cython.pyx":259
 *             self.svd_each_time = True
 *         else:
 *             self.svd_each_time = False             # <<<<<<<<<<<<<<
 * 
 *         self.Q_square_root = {}
 */
  /*else*/ {
    __pyx_v_self->svd_each_time = 0;
  }
  __pyx_L3:;

  /* "GPy/models/state_space_cython.pyx":261
 *             self.svd_each_time = False
 * 
 *         self.Q_square_root = {}             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->Q_square_root);
  __Pyx_DECREF(__pyx_v_self->Q_square_root);
  __pyx_v_self->Q_square_root = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":222
 *         bint svd_each_time
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] Q, np.ndarray[DTYPE_t, ndim=2] index,             # <<<<<<<<<<<<<<
 *                  int Q_time_var_index, int p_unique_Q_number, np.ndarray[DTYPE_t, ndim=3] dQ = None):
 *         """
 */

  /* 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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":264
 * 
 * 
 *     cpdef Qk(self, int k):             # <<<<<<<<<<<<<<
 *         """
 *         function (k). Returns noise matrix of dynamic model on iteration k.
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_3Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) {
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Qk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Qk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_3Qk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":269
 *                 k (iteration number). starts at 0
 *         """
 *         return self.Q[:,:, <int>self.index[self.Q_time_var_index, k]]             # <<<<<<<<<<<<<<
 * 
 *     cpdef dQk(self, int k):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->Q_time_var_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->index), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(((int)__pyx_t_6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__10);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->Q), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __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;

  /* "GPy/models/state_space_cython.pyx":264
 * 
 * 
 *     cpdef Qk(self, int k):             # <<<<<<<<<<<<<<
 *         """
 *         function (k). Returns noise matrix of dynamic model on iteration k.
 */

  /* 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("GPy.models.state_space_cython.Q_handling_Cython.Qk", __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_3GPy_6models_18state_space_cython_17Q_handling_Cython_3Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython_2Qk[] = "\n        function (k). Returns noise matrix of dynamic model on iteration k.\n                k (iteration number). starts at 0\n        ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_3Qk(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("Qk (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_ERR(0, 264, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_2Qk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_2Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k) {
  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("Qk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Qk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __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("GPy.models.state_space_cython.Q_handling_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":271
 *         return self.Q[:,:, <int>self.index[self.Q_time_var_index, k]]
 * 
 *     cpdef dQk(self, int k):             # <<<<<<<<<<<<<<
 *         if self.dQ is None:
 *             raise ValueError("dQ derivative is None")
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_5dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dQk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dQk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_5dQk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":272
 * 
 *     cpdef dQk(self, int k):
 *         if self.dQ is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("dQ derivative is None")
 * 
 */
  __pyx_t_6 = (((PyObject *)__pyx_v_self->dQ) == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (unlikely(__pyx_t_7)) {

    /* "GPy/models/state_space_cython.pyx":273
 *     cpdef dQk(self, int k):
 *         if self.dQ is None:
 *             raise ValueError("dQ derivative is None")             # <<<<<<<<<<<<<<
 * 
 *         return self.dQ # the same dirivative on each iteration
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 273, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 273, __pyx_L1_error)

    /* "GPy/models/state_space_cython.pyx":272
 * 
 *     cpdef dQk(self, int k):
 *         if self.dQ is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("dQ derivative is None")
 * 
 */
  }

  /* "GPy/models/state_space_cython.pyx":275
 *             raise ValueError("dQ derivative is None")
 * 
 *         return self.dQ # the same dirivative on each iteration             # <<<<<<<<<<<<<<
 * 
 *     cpdef Q_srk(self, int k):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dQ));
  __pyx_r = ((PyObject *)__pyx_v_self->dQ);
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":271
 *         return self.Q[:,:, <int>self.index[self.Q_time_var_index, k]]
 * 
 *     cpdef dQk(self, int k):             # <<<<<<<<<<<<<<
 *         if self.dQ is None:
 *             raise ValueError("dQ derivative is None")
 */

  /* 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("GPy.models.state_space_cython.Q_handling_Cython.dQk", __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_3GPy_6models_18state_space_cython_17Q_handling_Cython_5dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_5dQk(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("dQk (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_ERR(0, 271, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_4dQk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_4dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k) {
  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("dQk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_dQk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __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("GPy.models.state_space_cython.Q_handling_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":277
 *         return self.dQ # the same dirivative on each iteration
 * 
 *     cpdef Q_srk(self, int k):             # <<<<<<<<<<<<<<
 *         """
 *         function (k). Returns the square root of noise matrix of dynamic model on iteration k.
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_7Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) {
  int __pyx_v_ind;
  PyArrayObject *__pyx_v_Q = 0;
  PyArrayObject *__pyx_v_square_root = 0;
  PyArrayObject *__pyx_v_U = 0;
  PyArrayObject *__pyx_v_S = 0;
  CYTHON_UNUSED PyArrayObject *__pyx_v_Vh = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Q;
  __Pyx_Buffer __pyx_pybuffer_Q;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S;
  __Pyx_Buffer __pyx_pybuffer_S;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_U;
  __Pyx_Buffer __pyx_pybuffer_U;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh;
  __Pyx_Buffer __pyx_pybuffer_Vh;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_square_root;
  __Pyx_Buffer __pyx_pybuffer_square_root;
  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;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyArrayObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyArrayObject *__pyx_t_14 = NULL;
  PyArrayObject *__pyx_t_15 = NULL;
  PyArrayObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Q_srk", 0);
  __pyx_pybuffer_Q.pybuffer.buf = NULL;
  __pyx_pybuffer_Q.refcount = 0;
  __pyx_pybuffernd_Q.data = NULL;
  __pyx_pybuffernd_Q.rcbuffer = &__pyx_pybuffer_Q;
  __pyx_pybuffer_square_root.pybuffer.buf = NULL;
  __pyx_pybuffer_square_root.refcount = 0;
  __pyx_pybuffernd_square_root.data = NULL;
  __pyx_pybuffernd_square_root.rcbuffer = &__pyx_pybuffer_square_root;
  __pyx_pybuffer_U.pybuffer.buf = NULL;
  __pyx_pybuffer_U.refcount = 0;
  __pyx_pybuffernd_U.data = NULL;
  __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U;
  __pyx_pybuffer_S.pybuffer.buf = NULL;
  __pyx_pybuffer_S.refcount = 0;
  __pyx_pybuffernd_S.data = NULL;
  __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S;
  __pyx_pybuffer_Vh.pybuffer.buf = NULL;
  __pyx_pybuffer_Vh.refcount = 0;
  __pyx_pybuffernd_Vh.data = NULL;
  __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh;
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_srk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_7Q_srk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 277, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":284
 *         This function is implemented to use SVD prediction step.
 *         """
 *         cdef int ind = <int>self.index[self.Q_time_var_index, k]             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE_t, ndim=2] Q = self.Q[:,:, ind]
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->Q_time_var_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->index), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_ind = ((int)__pyx_t_6);

  /* "GPy/models/state_space_cython.pyx":285
 *         """
 *         cdef int ind = <int>self.index[self.Q_time_var_index, k]
 *         cdef np.ndarray[DTYPE_t, ndim=2] Q = self.Q[:,:, ind]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__10);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->Q), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __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_ERR(0, 285, __pyx_L1_error)
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Q.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_Q = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Q.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 285, __pyx_L1_error)
    } else {__pyx_pybuffernd_Q.diminfo[0].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Q.diminfo[0].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Q.diminfo[1].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Q.diminfo[1].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_7 = 0;
  __pyx_v_Q = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "GPy/models/state_space_cython.pyx":294
 *         cdef np.ndarray[DTYPE_t, ndim=2] Vh
 * 
 *         if (Q.shape[0] == 1): # 1-D case handle simplier. No storage             # <<<<<<<<<<<<<<
 *         # of the result, just compute it each time.
 *             square_root = np.sqrt( Q )
 */
  __pyx_t_8 = (((__pyx_v_Q->dimensions[0]) == 1) != 0);
  if (__pyx_t_8) {

    /* "GPy/models/state_space_cython.pyx":296
 *         if (Q.shape[0] == 1): # 1-D case handle simplier. No storage
 *         # of the result, just compute it each time.
 *             square_root = np.sqrt( Q )             # <<<<<<<<<<<<<<
 *         else:
 *             if self.svd_each_time:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, ((PyObject *)__pyx_v_Q)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_Q));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __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_ERR(0, 296, __pyx_L1_error)
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_2);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer);
      __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_6 < 0)) {
        PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
      }
      __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 296, __pyx_L1_error)
    }
    __pyx_t_9 = 0;
    __pyx_v_square_root = ((PyArrayObject *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "GPy/models/state_space_cython.pyx":294
 *         cdef np.ndarray[DTYPE_t, ndim=2] Vh
 * 
 *         if (Q.shape[0] == 1): # 1-D case handle simplier. No storage             # <<<<<<<<<<<<<<
 *         # of the result, just compute it each time.
 *             square_root = np.sqrt( Q )
 */
    goto __pyx_L3;
  }

  /* "GPy/models/state_space_cython.pyx":298
 *             square_root = np.sqrt( Q )
 *         else:
 *             if self.svd_each_time:             # <<<<<<<<<<<<<<
 * 
 *                 U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True,
 */
  /*else*/ {
    __pyx_t_8 = (__pyx_v_self->svd_each_time != 0);
    if (__pyx_t_8) {

      /* "GPy/models/state_space_cython.pyx":300
 *             if self.svd_each_time:
 * 
 *                 U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                           overwrite_a=False,check_finite=True)
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_sp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_svd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __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_ERR(0, 300, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_Q));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Q));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_Q));
      __pyx_t_4 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 300, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_full_matrices, Py_False) < 0) __PYX_ERR(0, 300, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_compute_uv, Py_True) < 0) __PYX_ERR(0, 300, __pyx_L1_error)

      /* "GPy/models/state_space_cython.pyx":301
 * 
 *                 U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True,
 *                           overwrite_a=False,check_finite=True)             # <<<<<<<<<<<<<<
 * 
 *                 square_root = U * np.sqrt(S)
 */
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_overwrite_a, Py_False) < 0) __PYX_ERR(0, 300, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_check_finite, Py_True) < 0) __PYX_ERR(0, 300, __pyx_L1_error)

      /* "GPy/models/state_space_cython.pyx":300
 *             if self.svd_each_time:
 * 
 *                 U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                           overwrite_a=False,check_finite=True)
 * 
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 300, __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_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 300, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 300, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __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_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 300, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_1 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        index = 2; __pyx_t_2 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_5), 3) < 0) __PYX_ERR(0, 300, __pyx_L1_error)
        __pyx_t_13 = NULL;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L6_unpacking_done;
        __pyx_L5_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_13 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 300, __pyx_L1_error)
        __pyx_L6_unpacking_done:;
      }
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 300, __pyx_L1_error)
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 300, __pyx_L1_error)
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 300, __pyx_L1_error)
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
        }
        __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 300, __pyx_L1_error)
      }
      __pyx_t_14 = 0;
      __pyx_v_U = ((PyArrayObject *)__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_15 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
        }
        __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 300, __pyx_L1_error)
      }
      __pyx_t_15 = 0;
      __pyx_v_S = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_16 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
        }
        __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 300, __pyx_L1_error)
      }
      __pyx_t_16 = 0;
      __pyx_v_Vh = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "GPy/models/state_space_cython.pyx":303
 *                           overwrite_a=False,check_finite=True)
 * 
 *                 square_root = U * np.sqrt(S)             # <<<<<<<<<<<<<<
 *             else:
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, ((PyObject *)__pyx_v_S)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_S));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_U), __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __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_5numpy_ndarray))))) __PYX_ERR(0, 303, __pyx_L1_error)
      __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
        }
        __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 303, __pyx_L1_error)
      }
      __pyx_t_9 = 0;
      __pyx_v_square_root = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "GPy/models/state_space_cython.pyx":298
 *             square_root = np.sqrt( Q )
 *         else:
 *             if self.svd_each_time:             # <<<<<<<<<<<<<<
 * 
 *                 U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True,
 */
      goto __pyx_L4;
    }

    /* "GPy/models/state_space_cython.pyx":306
 *             else:
 * 
 *                 if ind in self.Q_square_root:             # <<<<<<<<<<<<<<
 *                     square_root = self.Q_square_root[ind]
 *                 else:
 */
    /*else*/ {
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(__pyx_v_self->Q_square_root == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 306, __pyx_L1_error)
      }
      __pyx_t_8 = (__Pyx_PyDict_ContainsTF(__pyx_t_1, __pyx_v_self->Q_square_root, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 306, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_17 = (__pyx_t_8 != 0);
      if (__pyx_t_17) {

        /* "GPy/models/state_space_cython.pyx":307
 * 
 *                 if ind in self.Q_square_root:
 *                     square_root = self.Q_square_root[ind]             # <<<<<<<<<<<<<<
 *                 else:
 *                     U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True,
 */
        if (unlikely(__pyx_v_self->Q_square_root == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 307, __pyx_L1_error)
        }
        __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_self->Q_square_root, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 307, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 307, __pyx_L1_error)
        __pyx_t_9 = ((PyArrayObject *)__pyx_t_3);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer);
          __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_6 < 0)) {
            PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
          }
          __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 307, __pyx_L1_error)
        }
        __pyx_t_9 = 0;
        __pyx_v_square_root = ((PyArrayObject *)__pyx_t_3);
        __pyx_t_3 = 0;

        /* "GPy/models/state_space_cython.pyx":306
 *             else:
 * 
 *                 if ind in self.Q_square_root:             # <<<<<<<<<<<<<<
 *                     square_root = self.Q_square_root[ind]
 *                 else:
 */
        goto __pyx_L7;
      }

      /* "GPy/models/state_space_cython.pyx":309
 *                     square_root = self.Q_square_root[ind]
 *                 else:
 *                     U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                               overwrite_a=False,check_finite=True)
 * 
 */
      /*else*/ {
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_sp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 309, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_linalg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_svd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 309, __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_ERR(0, 309, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(((PyObject *)__pyx_v_Q));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_Q));
        PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_Q));
        __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_full_matrices, Py_False) < 0) __PYX_ERR(0, 309, __pyx_L1_error)
        if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_compute_uv, Py_True) < 0) __PYX_ERR(0, 309, __pyx_L1_error)

        /* "GPy/models/state_space_cython.pyx":310
 *                 else:
 *                     U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True,
 *                               overwrite_a=False,check_finite=True)             # <<<<<<<<<<<<<<
 * 
 *                     square_root = U * np.sqrt(S)
 */
        if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_overwrite_a, Py_False) < 0) __PYX_ERR(0, 309, __pyx_L1_error)
        if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_check_finite, Py_True) < 0) __PYX_ERR(0, 309, __pyx_L1_error)

        /* "GPy/models/state_space_cython.pyx":309
 *                     square_root = self.Q_square_root[ind]
 *                 else:
 *                     U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                               overwrite_a=False,check_finite=True)
 * 
 */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 309, __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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
          PyObject* sequence = __pyx_t_4;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 3)) {
            if (size > 3) __Pyx_RaiseTooManyValuesError(3);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 309, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
            __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
          } else {
            __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
            __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
          }
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_3);
          #else
          __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 309, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 309, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext;
          index = 0; __pyx_t_2 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L8_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_2);
          index = 1; __pyx_t_1 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L8_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_1);
          index = 2; __pyx_t_3 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L8_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_3);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_5), 3) < 0) __PYX_ERR(0, 309, __pyx_L1_error)
          __pyx_t_13 = NULL;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L9_unpacking_done;
          __pyx_L8_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_13 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 309, __pyx_L1_error)
          __pyx_L9_unpacking_done:;
        }
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 309, __pyx_L1_error)
        if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 309, __pyx_L1_error)
        if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 309, __pyx_L1_error)
        __pyx_t_14 = ((PyArrayObject *)__pyx_t_2);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
          __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_6 < 0)) {
            PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
          }
          __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 309, __pyx_L1_error)
        }
        __pyx_t_14 = 0;
        __pyx_v_U = ((PyArrayObject *)__pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_15 = ((PyArrayObject *)__pyx_t_1);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
          __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
          if (unlikely(__pyx_t_6 < 0)) {
            PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
          }
          __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0];
          if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 309, __pyx_L1_error)
        }
        __pyx_t_15 = 0;
        __pyx_v_S = ((PyArrayObject *)__pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_16 = ((PyArrayObject *)__pyx_t_3);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
          __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_6 < 0)) {
            PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
          }
          __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 309, __pyx_L1_error)
        }
        __pyx_t_16 = 0;
        __pyx_v_Vh = ((PyArrayObject *)__pyx_t_3);
        __pyx_t_3 = 0;

        /* "GPy/models/state_space_cython.pyx":312
 *                               overwrite_a=False,check_finite=True)
 * 
 *                     square_root = U * np.sqrt(S)             # <<<<<<<<<<<<<<
 * 
 *                     self.Q_square_root[ind] = square_root
 */
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 312, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, ((PyObject *)__pyx_v_S)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_S));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 312, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_U), __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __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_ERR(0, 312, __pyx_L1_error)
        __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer);
          __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_6 < 0)) {
            PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
          }
          __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 312, __pyx_L1_error)
        }
        __pyx_t_9 = 0;
        __pyx_v_square_root = ((PyArrayObject *)__pyx_t_1);
        __pyx_t_1 = 0;

        /* "GPy/models/state_space_cython.pyx":314
 *                     square_root = U * np.sqrt(S)
 * 
 *                     self.Q_square_root[ind] = square_root             # <<<<<<<<<<<<<<
 * 
 *         return square_root
 */
        if (unlikely(__pyx_v_self->Q_square_root == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 314, __pyx_L1_error)
        }
        __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 314, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (unlikely(PyDict_SetItem(__pyx_v_self->Q_square_root, __pyx_t_1, ((PyObject *)__pyx_v_square_root)) < 0)) __PYX_ERR(0, 314, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __pyx_L7:;
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  /* "GPy/models/state_space_cython.pyx":316
 *                     self.Q_square_root[ind] = square_root
 * 
 *         return square_root             # <<<<<<<<<<<<<<
 * 
 * cdef class Std_Dynamic_Callables_Cython(Q_handling_Cython):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_square_root));
  __pyx_r = ((PyObject *)__pyx_v_square_root);
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":277
 *         return self.dQ # the same dirivative on each iteration
 * 
 *     cpdef Q_srk(self, int k):             # <<<<<<<<<<<<<<
 *         """
 *         function (k). Returns the square root of noise matrix of dynamic model on iteration k.
 */

  /* 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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_Q);
  __Pyx_XDECREF((PyObject *)__pyx_v_square_root);
  __Pyx_XDECREF((PyObject *)__pyx_v_U);
  __Pyx_XDECREF((PyObject *)__pyx_v_S);
  __Pyx_XDECREF((PyObject *)__pyx_v_Vh);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_7Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython_6Q_srk[] = "\n        function (k). Returns the square root of noise matrix of dynamic model on iteration k.\n                k (iteration number). starts at 0\n                \n        This function is implemented to use SVD prediction step.\n        ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_7Q_srk(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("Q_srk (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_ERR(0, 277, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_6Q_srk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_6Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k) {
  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("Q_srk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Q_srk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __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("GPy.models.state_space_cython.Q_handling_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_8__reduce_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)__pyx_v_self));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_8__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.Q, self.Q_square_root, self.Q_time_var_index, self.dQ, self.index, self.svd_each_time)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->Q_time_var_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->svd_each_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->Q));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->Q));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->Q));
  __Pyx_INCREF(__pyx_v_self->Q_square_root);
  __Pyx_GIVEREF(__pyx_v_self->Q_square_root);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->Q_square_root);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dQ));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->dQ));
  PyTuple_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_v_self->dQ));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->index));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->index));
  PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_v_self->index));
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.Q, self.Q_square_root, self.Q_time_var_index, self.dQ, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":7
 *     state = (self.Q, self.Q_square_root, self.Q_time_var_index, self.dQ, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.Q is not None or self.Q_square_root is not None or self.dQ is not None or self.index is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.Q, self.Q_square_root, self.Q_time_var_index, self.dQ, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.Q is not None or self.Q_square_root is not None or self.dQ is not None or self.index is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Q_handling_Cython, (type(self), 0x77b5360, None), state
 */
  /*else*/ {
    __pyx_t_4 = (((PyObject *)__pyx_v_self->Q) != Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->Q_square_root != ((PyObject*)Py_None));
    __pyx_t_4 = (__pyx_t_6 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_4 = (((PyObject *)__pyx_v_self->dQ) != Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (((PyObject *)__pyx_v_self->index) != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_5;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.Q is not None or self.Q_square_root is not None or self.dQ is not None or self.index is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Q_handling_Cython, (type(self), 0x77b5360, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":13
 *         use_setstate = self.Q is not None or self.Q_square_root is not None or self.dQ is not None or self.index is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Q_handling_Cython, (type(self), 0x77b5360, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Q_handling_Cython, (type(self), 0x77b5360, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle_Q_handling_Cython); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_125522784);
    __Pyx_GIVEREF(__pyx_int_125522784);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_125522784);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.Q is not None or self.Q_square_root is not None or self.dQ is not None or self.index is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Q_handling_Cython, (type(self), 0x77b5360, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Q_handling_Cython, (type(self), 0x77b5360, None), state
 *     else:
 *         return __pyx_unpickle_Q_handling_Cython, (type(self), 0x77b5360, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Q_handling_Cython__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_Q_handling_Cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_125522784);
    __Pyx_GIVEREF(__pyx_int_125522784);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_125522784);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Q_handling_Cython, (type(self), 0x77b5360, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Q_handling_Cython__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_10__setstate_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_10__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  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("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Q_handling_Cython, (type(self), 0x77b5360, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Q_handling_Cython__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Q_handling_Cython__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Q_handling_Cython, (type(self), 0x77b5360, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Q_handling_Cython__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":324
 *         np.ndarray  dA
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] A, int A_time_var_index,             # <<<<<<<<<<<<<<
 *                  np.ndarray[DTYPE_t, ndim=3] Q,
 *                  np.ndarray[DTYPE_t, ndim=2] index,
 */

/* Python wrapper */
static int __pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_A = 0;
  int __pyx_v_A_time_var_index;
  PyArrayObject *__pyx_v_Q = 0;
  PyArrayObject *__pyx_v_index = 0;
  int __pyx_v_Q_time_var_index;
  int __pyx_v_unique_Q_number;
  PyArrayObject *__pyx_v_dA = 0;
  PyArrayObject *__pyx_v_dQ = 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_A,&__pyx_n_s_A_time_var_index,&__pyx_n_s_Q,&__pyx_n_s_index,&__pyx_n_s_Q_time_var_index,&__pyx_n_s_unique_Q_number,&__pyx_n_s_dA,&__pyx_n_s_dQ,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};

    /* "GPy/models/state_space_cython.pyx":328
 *                  np.ndarray[DTYPE_t, ndim=2] index,
 *                  int Q_time_var_index, int unique_Q_number,
 *                  np.ndarray[DTYPE_t, ndim=3] dA = None,             # <<<<<<<<<<<<<<
 *                  np.ndarray[DTYPE_t, ndim=3] dQ=None):
 * 
 */
    values[6] = (PyObject *)((PyArrayObject *)Py_None);

    /* "GPy/models/state_space_cython.pyx":329
 *                  int Q_time_var_index, int unique_Q_number,
 *                  np.ndarray[DTYPE_t, ndim=3] dA = None,
 *                  np.ndarray[DTYPE_t, ndim=3] dQ=None):             # <<<<<<<<<<<<<<
 * 
 *         super(Std_Dynamic_Callables_Cython,self).__init__(Q, index, Q_time_var_index, unique_Q_number,dQ)
 */
    values[7] = (PyObject *)((PyArrayObject *)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  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_A_time_var_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 1); __PYX_ERR(0, 324, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Q)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 2); __PYX_ERR(0, 324, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 3); __PYX_ERR(0, 324, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Q_time_var_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 4); __PYX_ERR(0, 324, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unique_Q_number)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 5); __PYX_ERR(0, 324, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dA);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dQ);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 324, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 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_A = ((PyArrayObject *)values[0]);
    __pyx_v_A_time_var_index = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_A_time_var_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 324, __pyx_L3_error)
    __pyx_v_Q = ((PyArrayObject *)values[2]);
    __pyx_v_index = ((PyArrayObject *)values[3]);
    __pyx_v_Q_time_var_index = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_Q_time_var_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 327, __pyx_L3_error)
    __pyx_v_unique_Q_number = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_unique_Q_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 327, __pyx_L3_error)
    __pyx_v_dA = ((PyArrayObject *)values[6]);
    __pyx_v_dQ = ((PyArrayObject *)values[7]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 324, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_A), __pyx_ptype_5numpy_ndarray, 1, "A", 0))) __PYX_ERR(0, 324, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Q), __pyx_ptype_5numpy_ndarray, 1, "Q", 0))) __PYX_ERR(0, 325, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_index), __pyx_ptype_5numpy_ndarray, 1, "index", 0))) __PYX_ERR(0, 326, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dA), __pyx_ptype_5numpy_ndarray, 1, "dA", 0))) __PYX_ERR(0, 328, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dQ), __pyx_ptype_5numpy_ndarray, 1, "dQ", 0))) __PYX_ERR(0, 329, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython___init__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_A, __pyx_v_A_time_var_index, __pyx_v_Q, __pyx_v_index, __pyx_v_Q_time_var_index, __pyx_v_unique_Q_number, __pyx_v_dA, __pyx_v_dQ);

  /* "GPy/models/state_space_cython.pyx":324
 *         np.ndarray  dA
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] A, int A_time_var_index,             # <<<<<<<<<<<<<<
 *                  np.ndarray[DTYPE_t, ndim=3] Q,
 *                  np.ndarray[DTYPE_t, ndim=2] index,
 */

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

static int __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, PyArrayObject *__pyx_v_A, int __pyx_v_A_time_var_index, PyArrayObject *__pyx_v_Q, PyArrayObject *__pyx_v_index, int __pyx_v_Q_time_var_index, int __pyx_v_unique_Q_number, PyArrayObject *__pyx_v_dA, PyArrayObject *__pyx_v_dQ) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_A;
  __Pyx_Buffer __pyx_pybuffer_A;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Q;
  __Pyx_Buffer __pyx_pybuffer_Q;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dA;
  __Pyx_Buffer __pyx_pybuffer_dA;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dQ;
  __Pyx_Buffer __pyx_pybuffer_dQ;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_index;
  __Pyx_Buffer __pyx_pybuffer_index;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 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_pybuffer_Q.pybuffer.buf = NULL;
  __pyx_pybuffer_Q.refcount = 0;
  __pyx_pybuffernd_Q.data = NULL;
  __pyx_pybuffernd_Q.rcbuffer = &__pyx_pybuffer_Q;
  __pyx_pybuffer_index.pybuffer.buf = NULL;
  __pyx_pybuffer_index.refcount = 0;
  __pyx_pybuffernd_index.data = NULL;
  __pyx_pybuffernd_index.rcbuffer = &__pyx_pybuffer_index;
  __pyx_pybuffer_dA.pybuffer.buf = NULL;
  __pyx_pybuffer_dA.refcount = 0;
  __pyx_pybuffernd_dA.data = NULL;
  __pyx_pybuffernd_dA.rcbuffer = &__pyx_pybuffer_dA;
  __pyx_pybuffer_dQ.pybuffer.buf = NULL;
  __pyx_pybuffer_dQ.refcount = 0;
  __pyx_pybuffernd_dQ.data = NULL;
  __pyx_pybuffernd_dQ.rcbuffer = &__pyx_pybuffer_dQ;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 324, __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]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_A.diminfo[2].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_A.diminfo[2].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Q.rcbuffer->pybuffer, (PyObject*)__pyx_v_Q, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 324, __pyx_L1_error)
  }
  __pyx_pybuffernd_Q.diminfo[0].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Q.diminfo[0].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Q.diminfo[1].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Q.diminfo[1].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_Q.diminfo[2].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_Q.diminfo[2].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_index.rcbuffer->pybuffer, (PyObject*)__pyx_v_index, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 324, __pyx_L1_error)
  }
  __pyx_pybuffernd_index.diminfo[0].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_index.diminfo[0].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_index.diminfo[1].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_index.diminfo[1].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dA.rcbuffer->pybuffer, (PyObject*)__pyx_v_dA, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 324, __pyx_L1_error)
  }
  __pyx_pybuffernd_dA.diminfo[0].strides = __pyx_pybuffernd_dA.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dA.diminfo[0].shape = __pyx_pybuffernd_dA.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dA.diminfo[1].strides = __pyx_pybuffernd_dA.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dA.diminfo[1].shape = __pyx_pybuffernd_dA.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dA.diminfo[2].strides = __pyx_pybuffernd_dA.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dA.diminfo[2].shape = __pyx_pybuffernd_dA.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer, (PyObject*)__pyx_v_dQ, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 324, __pyx_L1_error)
  }
  __pyx_pybuffernd_dQ.diminfo[0].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dQ.diminfo[0].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dQ.diminfo[1].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dQ.diminfo[1].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dQ.diminfo[2].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dQ.diminfo[2].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[2];

  /* "GPy/models/state_space_cython.pyx":331
 *                  np.ndarray[DTYPE_t, ndim=3] dQ=None):
 * 
 *         super(Std_Dynamic_Callables_Cython,self).__init__(Q, index, Q_time_var_index, unique_Q_number,dQ)             # <<<<<<<<<<<<<<
 * 
 *         self.A = A
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_Q_time_var_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_unique_Q_number); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && 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);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_Q), ((PyObject *)__pyx_v_index), __pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_dQ)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_Q), ((PyObject *)__pyx_v_index), __pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_dQ)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(5+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 331, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_Q));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_Q));
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_Q));
    __Pyx_INCREF(((PyObject *)__pyx_v_index));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_index));
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_index));
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_dQ));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dQ));
    PyTuple_SET_ITEM(__pyx_t_7, 4+__pyx_t_6, ((PyObject *)__pyx_v_dQ));
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":333
 *         super(Std_Dynamic_Callables_Cython,self).__init__(Q, index, Q_time_var_index, unique_Q_number,dQ)
 * 
 *         self.A = A             # <<<<<<<<<<<<<<
 *         self.A_time_var_index = A_time_var_index
 *         self.dA = dA
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_A));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_A));
  __Pyx_GOTREF(__pyx_v_self->A);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->A));
  __pyx_v_self->A = ((PyArrayObject *)__pyx_v_A);

  /* "GPy/models/state_space_cython.pyx":334
 * 
 *         self.A = A
 *         self.A_time_var_index = A_time_var_index             # <<<<<<<<<<<<<<
 *         self.dA = dA
 * 
 */
  __pyx_v_self->A_time_var_index = __pyx_v_A_time_var_index;

  /* "GPy/models/state_space_cython.pyx":335
 *         self.A = A
 *         self.A_time_var_index = A_time_var_index
 *         self.dA = dA             # <<<<<<<<<<<<<<
 * 
 *     cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_dA));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dA));
  __Pyx_GOTREF(__pyx_v_self->dA);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->dA));
  __pyx_v_self->dA = ((PyArrayObject *)__pyx_v_dA);

  /* "GPy/models/state_space_cython.pyx":324
 *         np.ndarray  dA
 * 
 *     def __init__(self, np.ndarray[DTYPE_t, ndim=3] A, int A_time_var_index,             # <<<<<<<<<<<<<<
 *                  np.ndarray[DTYPE_t, ndim=3] Q,
 *                  np.ndarray[DTYPE_t, ndim=2] index,
 */

  /* 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_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":337
 *         self.dA = dA
 * 
 *     cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A):             # <<<<<<<<<<<<<<
 *         """
 *             f_a: function (k, x_{k-1}, A_{k}). Dynamic function.
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_A;
  __Pyx_Buffer __pyx_pybuffer_A;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("f_a", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __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_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 337, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 337, __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]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1];
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_f_a); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_3f_a)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __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_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_A)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_A)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 337, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(((PyObject *)__pyx_v_m));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_m));
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m));
          __Pyx_INCREF(((PyObject *)__pyx_v_A));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_A));
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_A));
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __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;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":345
 *         """
 * 
 *         return np.dot(A,m)             # <<<<<<<<<<<<<<
 * 
 *     cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && 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_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_A), ((PyObject *)__pyx_v_m)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_A), ((PyObject *)__pyx_v_m)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 345, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_A));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_A));
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_A));
    __Pyx_INCREF(((PyObject *)__pyx_v_m));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_m));
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":337
 *         self.dA = dA
 * 
 *     cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A):             # <<<<<<<<<<<<<<
 *         """
 *             f_a: function (k, x_{k-1}, A_{k}). Dynamic function.
 */

  /* 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_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_2f_a[] = "\n            f_a: function (k, x_{k-1}, A_{k}). Dynamic function.        \n            k (iteration number), starts at 0\n            x_{k-1} State from the previous step\n            A_{k} Jacobian matrices of f_a. In the linear case it is exactly A_{k}.\n        ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_m = 0;
  PyArrayObject *__pyx_v_A = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("f_a (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_A,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 1); __PYX_ERR(0, 337, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 2); __PYX_ERR(0, 337, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f_a") < 0)) __PYX_ERR(0, 337, __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_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 337, __pyx_L3_error)
    __pyx_v_m = ((PyArrayObject *)values[1]);
    __pyx_v_A = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 337, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) __PYX_ERR(0, 337, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_A), __pyx_ptype_5numpy_ndarray, 1, "A", 0))) __PYX_ERR(0, 337, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_2f_a(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __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_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_2f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_A;
  __Pyx_Buffer __pyx_pybuffer_A;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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("f_a", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __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_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 337, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 337, __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]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_f_a(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m), ((PyArrayObject *)__pyx_v_A), 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":347
 *         return np.dot(A,m)
 * 
 *     cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix             # <<<<<<<<<<<<<<
 *         """
 *         function (k, m, P) return Jacobian of measurement function, it is
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_5Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred;
  __Pyx_Buffer __pyx_pybuffer_P_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred;
  __Pyx_Buffer __pyx_pybuffer_m_pred;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Ak", 0);
  __pyx_pybuffer_m_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_m_pred.refcount = 0;
  __pyx_pybuffernd_m_pred.data = NULL;
  __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred;
  __pyx_pybuffer_P_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_P_pred.refcount = 0;
  __pyx_pybuffernd_P_pred.data = NULL;
  __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 347, __pyx_L1_error)
  }
  __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 347, __pyx_L1_error)
  }
  __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1];
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Ak); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_5Ak)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __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_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m_pred), ((PyObject *)__pyx_v_P_pred)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m_pred), ((PyObject *)__pyx_v_P_pred)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 347, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(((PyObject *)__pyx_v_m_pred));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred));
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m_pred));
          __Pyx_INCREF(((PyObject *)__pyx_v_P_pred));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred));
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_P_pred));
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __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;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":356
 *         """
 * 
 *         return self.A[:,:, <int>self.index[self.A_time_var_index, k]]             # <<<<<<<<<<<<<<
 * 
 *     cpdef dAk(self, int k):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->A_time_var_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 356, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 356, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->__pyx_base.index), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 356, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 356, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(((int)__pyx_t_6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 356, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 356, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__10);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->A), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 356, __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;

  /* "GPy/models/state_space_cython.pyx":347
 *         return np.dot(A,m)
 * 
 *     cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix             # <<<<<<<<<<<<<<
 *         """
 *         function (k, m, P) return Jacobian of measurement function, it is
 */

  /* 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_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_5Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_4Ak[] = "\n        function (k, m, P) return Jacobian of measurement function, it is\n            passed into p_h.\n            k (iteration number), starts at 0\n            m: point where Jacobian is evaluated\n            P: parameter for Jacobian, usually covariance matrix.\n        ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_5Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_m_pred = 0;
  PyArrayObject *__pyx_v_P_pred = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("Ak (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m_pred,&__pyx_n_s_P_pred,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m_pred)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 1); __PYX_ERR(0, 347, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_P_pred)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 2); __PYX_ERR(0, 347, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Ak") < 0)) __PYX_ERR(0, 347, __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_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 347, __pyx_L3_error)
    __pyx_v_m_pred = ((PyArrayObject *)values[1]);
    __pyx_v_P_pred = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 347, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m_pred), __pyx_ptype_5numpy_ndarray, 1, "m_pred", 0))) __PYX_ERR(0, 347, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P_pred), __pyx_ptype_5numpy_ndarray, 1, "P_pred", 0))) __PYX_ERR(0, 347, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_4Ak(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m_pred, __pyx_v_P_pred);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_4Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred;
  __Pyx_Buffer __pyx_pybuffer_P_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred;
  __Pyx_Buffer __pyx_pybuffer_m_pred;
  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("Ak", 0);
  __pyx_pybuffer_m_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_m_pred.refcount = 0;
  __pyx_pybuffernd_m_pred.data = NULL;
  __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred;
  __pyx_pybuffer_P_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_P_pred.refcount = 0;
  __pyx_pybuffernd_P_pred.data = NULL;
  __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 347, __pyx_L1_error)
  }
  __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 347, __pyx_L1_error)
  }
  __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_Ak(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m_pred), ((PyArrayObject *)__pyx_v_P_pred), 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":358
 *         return self.A[:,:, <int>self.index[self.A_time_var_index, k]]
 * 
 *     cpdef dAk(self, int k):             # <<<<<<<<<<<<<<
 *         if self.dA is None:
 *             raise ValueError("dA derivative is None")
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_7dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) {
  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;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dAk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dAk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_7dAk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 358, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":359
 * 
 *     cpdef dAk(self, int k):
 *         if self.dA is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("dA derivative is None")
 * 
 */
  __pyx_t_6 = (((PyObject *)__pyx_v_self->dA) == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (unlikely(__pyx_t_7)) {

    /* "GPy/models/state_space_cython.pyx":360
 *     cpdef dAk(self, int k):
 *         if self.dA is None:
 *             raise ValueError("dA derivative is None")             # <<<<<<<<<<<<<<
 * 
 *         return self.dA # the same dirivative on each iteration
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 360, __pyx_L1_error)

    /* "GPy/models/state_space_cython.pyx":359
 * 
 *     cpdef dAk(self, int k):
 *         if self.dA is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("dA derivative is None")
 * 
 */
  }

  /* "GPy/models/state_space_cython.pyx":362
 *             raise ValueError("dA derivative is None")
 * 
 *         return self.dA # the same dirivative on each iteration             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dA));
  __pyx_r = ((PyObject *)__pyx_v_self->dA);
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":358
 *         return self.A[:,:, <int>self.index[self.A_time_var_index, k]]
 * 
 *     cpdef dAk(self, int k):             # <<<<<<<<<<<<<<
 *         if self.dA is None:
 *             raise ValueError("dA derivative is None")
 */

  /* 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("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.dAk", __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_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_7dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_7dAk(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("dAk (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_ERR(0, 358, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_6dAk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_6dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k) {
  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("dAk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_dAk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __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("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":365
 * 
 * 
 *     cpdef reset(self, bint compute_derivatives=False):             # <<<<<<<<<<<<<<
 *         """
 *         For reusing this object e.g. in smoother computation. It makes sence
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_9reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset *__pyx_optional_args) {
  int __pyx_v_compute_derivatives = ((int)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("reset", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_compute_derivatives = __pyx_optional_args->compute_derivatives;
    }
  }
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_9reset)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_compute_derivatives); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":371
 *         time steps.
 *         """
 *         return self             # <<<<<<<<<<<<<<
 * 
 * cdef class AQcompute_batch_Cython(Q_handling_Cython):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":365
 * 
 * 
 *     cpdef reset(self, bint compute_derivatives=False):             # <<<<<<<<<<<<<<
 *         """
 *         For reusing this object e.g. in smoother computation. It makes sence
 */

  /* 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("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.reset", __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_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_9reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_8reset[] = "\n        For reusing this object e.g. in smoother computation. It makes sence\n        because necessary matrices have been already computed for all\n        time steps.\n        ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_9reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_compute_derivatives;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compute_derivatives,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);
        CYTHON_FALLTHROUGH;
        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 = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_compute_derivatives);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reset") < 0)) __PYX_ERR(0, 365, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_compute_derivatives = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_compute_derivatives == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 365, __pyx_L3_error)
    } else {
      __pyx_v_compute_derivatives = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("reset", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 365, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_8reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_compute_derivatives);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_8reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_compute_derivatives) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reset", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.compute_derivatives = __pyx_v_compute_derivatives;
  __pyx_t_1 = __pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython->__pyx_base.__pyx_base.reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __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("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_10__reduce_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_10__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.A, self.A_time_var_index, self.Q, self.Q_square_root, self.Q_time_var_index, self.dA, self.dQ, self.index, self.svd_each_time)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->A_time_var_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.Q_time_var_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->__pyx_base.svd_each_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->A));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->A));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self->A));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.Q));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.Q));
  PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_self->__pyx_base.Q));
  __Pyx_INCREF(__pyx_v_self->__pyx_base.Q_square_root);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.Q_square_root);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_self->__pyx_base.Q_square_root);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dA));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->dA));
  PyTuple_SET_ITEM(__pyx_t_4, 5, ((PyObject *)__pyx_v_self->dA));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.dQ));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.dQ));
  PyTuple_SET_ITEM(__pyx_t_4, 6, ((PyObject *)__pyx_v_self->__pyx_base.dQ));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.index));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.index));
  PyTuple_SET_ITEM(__pyx_t_4, 7, ((PyObject *)__pyx_v_self->__pyx_base.index));
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 8, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.A, self.A_time_var_index, self.Q, self.Q_square_root, self.Q_time_var_index, self.dA, self.dQ, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_4 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v__dict = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":7
 *     state = (self.A, self.A_time_var_index, self.Q, self.Q_square_root, self.Q_time_var_index, self.dA, self.dQ, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_5 = (__pyx_v__dict != Py_None);
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v__dict);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.A is not None or self.Q is not None or self.Q_square_root is not None or self.dA is not None or self.dQ is not None or self.index is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.A, self.A_time_var_index, self.Q, self.Q_square_root, self.Q_time_var_index, self.dA, self.dQ, self.index, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.A is not None or self.Q is not None or self.Q_square_root is not None or self.dA is not None or self.dQ is not None or self.index is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Std_Dynamic_Callables_Cython, (type(self), 0xdff0f56, None), state
 */
  /*else*/ {
    __pyx_t_5 = (((PyObject *)__pyx_v_self->A) != Py_None);
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_7 = (((PyObject *)__pyx_v_self->__pyx_base.Q) != Py_None);
    __pyx_t_5 = (__pyx_t_7 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_6 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->__pyx_base.Q_square_root != ((PyObject*)Py_None));
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_7 = (((PyObject *)__pyx_v_self->dA) != Py_None);
    __pyx_t_5 = (__pyx_t_7 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_6 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->__pyx_base.dQ) != Py_None);
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_7 = (((PyObject *)__pyx_v_self->__pyx_base.index) != Py_None);
    __pyx_t_5 = (__pyx_t_7 != 0);
    __pyx_t_6 = __pyx_t_5;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_6;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.A is not None or self.Q is not None or self.Q_square_root is not None or self.dA is not None or self.dQ is not None or self.index is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Std_Dynamic_Callables_Cython, (type(self), 0xdff0f56, None), state
 *     else:
 */
  __pyx_t_6 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":13
 *         use_setstate = self.A is not None or self.Q is not None or self.Q_square_root is not None or self.dA is not None or self.dQ is not None or self.index is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Std_Dynamic_Callables_Cython, (type(self), 0xdff0f56, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Std_Dynamic_Callables_Cython, (type(self), 0xdff0f56, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pyx_unpickle_Std_Dynamic_Calla); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_234819414);
    __Pyx_GIVEREF(__pyx_int_234819414);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_234819414);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.A is not None or self.Q is not None or self.Q_square_root is not None or self.dA is not None or self.dQ is not None or self.index is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Std_Dynamic_Callables_Cython, (type(self), 0xdff0f56, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Std_Dynamic_Callables_Cython, (type(self), 0xdff0f56, None), state
 *     else:
 *         return __pyx_unpickle_Std_Dynamic_Callables_Cython, (type(self), 0xdff0f56, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle_Std_Dynamic_Calla); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_234819414);
    __Pyx_GIVEREF(__pyx_int_234819414);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_234819414);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_state);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* 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("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Std_Dynamic_Callables_Cython, (type(self), 0xdff0f56, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_12__setstate_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_12__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  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("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Std_Dynamic_Callables_Cython, (type(self), 0xdff0f56, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Std_Dynamic_Callables_Cython, (type(self), 0xdff0f56, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":399
 *             int last_k
 * 
 *         def __init__(self, np.ndarray[DTYPE_t, ndim=3] As, np.ndarray[DTYPE_t, ndim=3] Qs,             # <<<<<<<<<<<<<<
 *                      np.ndarray[DTYPE_int_t, ndim=1] reconstruct_indices,
 *                      np.ndarray[DTYPE_t, ndim=4] dAs=None,
 */

/* Python wrapper */
static int __pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__[] = "\n            Constructor. All necessary parameters are passed here and stored \n            in the opject.            \n            \n            Input:\n            -------------------\n                F, L, Qc, P_inf : matrices\n                    Parameters of corresponding continuous state model\n                dt: array\n                    All time steps\n                compute_derivatives: bool\n                    Whether to calculate derivatives\n                    \n                dP_inf, dF, dQc: 3D array\n                    Derivatives if they are required\n            \n            Output:\n            -------------------\n            \n            ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__;
#endif
static int __pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_As = 0;
  PyArrayObject *__pyx_v_Qs = 0;
  PyArrayObject *__pyx_v_reconstruct_indices = 0;
  PyArrayObject *__pyx_v_dAs = 0;
  PyArrayObject *__pyx_v_dQs = 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_As,&__pyx_n_s_Qs,&__pyx_n_s_reconstruct_indices,&__pyx_n_s_dAs,&__pyx_n_s_dQs,0};
    PyObject* values[5] = {0,0,0,0,0};

    /* "GPy/models/state_space_cython.pyx":401
 *         def __init__(self, np.ndarray[DTYPE_t, ndim=3] As, np.ndarray[DTYPE_t, ndim=3] Qs,
 *                      np.ndarray[DTYPE_int_t, ndim=1] reconstruct_indices,
 *                      np.ndarray[DTYPE_t, ndim=4] dAs=None,             # <<<<<<<<<<<<<<
 *                      np.ndarray[DTYPE_t, ndim=4] dQs=None):
 *             """
 */
    values[3] = (PyObject *)((PyArrayObject *)Py_None);

    /* "GPy/models/state_space_cython.pyx":402
 *                      np.ndarray[DTYPE_int_t, ndim=1] reconstruct_indices,
 *                      np.ndarray[DTYPE_t, ndim=4] dAs=None,
 *                      np.ndarray[DTYPE_t, ndim=4] dQs=None):             # <<<<<<<<<<<<<<
 *             """
 *             Constructor. All necessary parameters are passed here and stored
 */
    values[4] = (PyObject *)((PyArrayObject *)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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_As)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Qs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 1); __PYX_ERR(0, 399, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reconstruct_indices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 2); __PYX_ERR(0, 399, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dAs);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dQs);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 399, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        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_As = ((PyArrayObject *)values[0]);
    __pyx_v_Qs = ((PyArrayObject *)values[1]);
    __pyx_v_reconstruct_indices = ((PyArrayObject *)values[2]);
    __pyx_v_dAs = ((PyArrayObject *)values[3]);
    __pyx_v_dQs = ((PyArrayObject *)values[4]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 399, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_As), __pyx_ptype_5numpy_ndarray, 1, "As", 0))) __PYX_ERR(0, 399, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Qs), __pyx_ptype_5numpy_ndarray, 1, "Qs", 0))) __PYX_ERR(0, 399, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reconstruct_indices), __pyx_ptype_5numpy_ndarray, 1, "reconstruct_indices", 0))) __PYX_ERR(0, 400, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dAs), __pyx_ptype_5numpy_ndarray, 1, "dAs", 0))) __PYX_ERR(0, 401, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dQs), __pyx_ptype_5numpy_ndarray, 1, "dQs", 0))) __PYX_ERR(0, 402, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), __pyx_v_As, __pyx_v_Qs, __pyx_v_reconstruct_indices, __pyx_v_dAs, __pyx_v_dQs);

  /* "GPy/models/state_space_cython.pyx":399
 *             int last_k
 * 
 *         def __init__(self, np.ndarray[DTYPE_t, ndim=3] As, np.ndarray[DTYPE_t, ndim=3] Qs,             # <<<<<<<<<<<<<<
 *                      np.ndarray[DTYPE_int_t, ndim=1] reconstruct_indices,
 *                      np.ndarray[DTYPE_t, ndim=4] dAs=None,
 */

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

static int __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, PyArrayObject *__pyx_v_As, PyArrayObject *__pyx_v_Qs, PyArrayObject *__pyx_v_reconstruct_indices, PyArrayObject *__pyx_v_dAs, PyArrayObject *__pyx_v_dQs) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_As;
  __Pyx_Buffer __pyx_pybuffer_As;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Qs;
  __Pyx_Buffer __pyx_pybuffer_Qs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dAs;
  __Pyx_Buffer __pyx_pybuffer_dAs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dQs;
  __Pyx_Buffer __pyx_pybuffer_dQs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_reconstruct_indices;
  __Pyx_Buffer __pyx_pybuffer_reconstruct_indices;
  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("__init__", 0);
  __pyx_pybuffer_As.pybuffer.buf = NULL;
  __pyx_pybuffer_As.refcount = 0;
  __pyx_pybuffernd_As.data = NULL;
  __pyx_pybuffernd_As.rcbuffer = &__pyx_pybuffer_As;
  __pyx_pybuffer_Qs.pybuffer.buf = NULL;
  __pyx_pybuffer_Qs.refcount = 0;
  __pyx_pybuffernd_Qs.data = NULL;
  __pyx_pybuffernd_Qs.rcbuffer = &__pyx_pybuffer_Qs;
  __pyx_pybuffer_reconstruct_indices.pybuffer.buf = NULL;
  __pyx_pybuffer_reconstruct_indices.refcount = 0;
  __pyx_pybuffernd_reconstruct_indices.data = NULL;
  __pyx_pybuffernd_reconstruct_indices.rcbuffer = &__pyx_pybuffer_reconstruct_indices;
  __pyx_pybuffer_dAs.pybuffer.buf = NULL;
  __pyx_pybuffer_dAs.refcount = 0;
  __pyx_pybuffernd_dAs.data = NULL;
  __pyx_pybuffernd_dAs.rcbuffer = &__pyx_pybuffer_dAs;
  __pyx_pybuffer_dQs.pybuffer.buf = NULL;
  __pyx_pybuffer_dQs.refcount = 0;
  __pyx_pybuffernd_dQs.data = NULL;
  __pyx_pybuffernd_dQs.rcbuffer = &__pyx_pybuffer_dQs;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_As.rcbuffer->pybuffer, (PyObject*)__pyx_v_As, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 399, __pyx_L1_error)
  }
  __pyx_pybuffernd_As.diminfo[0].strides = __pyx_pybuffernd_As.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_As.diminfo[0].shape = __pyx_pybuffernd_As.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_As.diminfo[1].strides = __pyx_pybuffernd_As.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_As.diminfo[1].shape = __pyx_pybuffernd_As.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_As.diminfo[2].strides = __pyx_pybuffernd_As.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_As.diminfo[2].shape = __pyx_pybuffernd_As.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Qs.rcbuffer->pybuffer, (PyObject*)__pyx_v_Qs, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 399, __pyx_L1_error)
  }
  __pyx_pybuffernd_Qs.diminfo[0].strides = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Qs.diminfo[0].shape = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Qs.diminfo[1].strides = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Qs.diminfo[1].shape = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_Qs.diminfo[2].strides = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_Qs.diminfo[2].shape = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_reconstruct_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_reconstruct_indices, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 399, __pyx_L1_error)
  }
  __pyx_pybuffernd_reconstruct_indices.diminfo[0].strides = __pyx_pybuffernd_reconstruct_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_reconstruct_indices.diminfo[0].shape = __pyx_pybuffernd_reconstruct_indices.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dAs.rcbuffer->pybuffer, (PyObject*)__pyx_v_dAs, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 4, 0, __pyx_stack) == -1)) __PYX_ERR(0, 399, __pyx_L1_error)
  }
  __pyx_pybuffernd_dAs.diminfo[0].strides = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dAs.diminfo[0].shape = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dAs.diminfo[1].strides = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dAs.diminfo[1].shape = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dAs.diminfo[2].strides = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dAs.diminfo[2].shape = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.shape[2]; __pyx_pybuffernd_dAs.diminfo[3].strides = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.strides[3]; __pyx_pybuffernd_dAs.diminfo[3].shape = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.shape[3];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQs.rcbuffer->pybuffer, (PyObject*)__pyx_v_dQs, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 4, 0, __pyx_stack) == -1)) __PYX_ERR(0, 399, __pyx_L1_error)
  }
  __pyx_pybuffernd_dQs.diminfo[0].strides = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dQs.diminfo[0].shape = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dQs.diminfo[1].strides = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dQs.diminfo[1].shape = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dQs.diminfo[2].strides = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dQs.diminfo[2].shape = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.shape[2]; __pyx_pybuffernd_dQs.diminfo[3].strides = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.strides[3]; __pyx_pybuffernd_dQs.diminfo[3].shape = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.shape[3];

  /* "GPy/models/state_space_cython.pyx":424
 *             """
 * 
 *             self.As = As             # <<<<<<<<<<<<<<
 *             self.Qs = Qs
 *             self.dAs = dAs
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_As));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_As));
  __Pyx_GOTREF(__pyx_v_self->As);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->As));
  __pyx_v_self->As = ((PyArrayObject *)__pyx_v_As);

  /* "GPy/models/state_space_cython.pyx":425
 * 
 *             self.As = As
 *             self.Qs = Qs             # <<<<<<<<<<<<<<
 *             self.dAs = dAs
 *             self.dQs = dQs
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_Qs));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Qs));
  __Pyx_GOTREF(__pyx_v_self->Qs);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->Qs));
  __pyx_v_self->Qs = ((PyArrayObject *)__pyx_v_Qs);

  /* "GPy/models/state_space_cython.pyx":426
 *             self.As = As
 *             self.Qs = Qs
 *             self.dAs = dAs             # <<<<<<<<<<<<<<
 *             self.dQs = dQs
 *             self.reconstruct_indices = reconstruct_indices
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_dAs));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dAs));
  __Pyx_GOTREF(__pyx_v_self->dAs);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->dAs));
  __pyx_v_self->dAs = ((PyArrayObject *)__pyx_v_dAs);

  /* "GPy/models/state_space_cython.pyx":427
 *             self.Qs = Qs
 *             self.dAs = dAs
 *             self.dQs = dQs             # <<<<<<<<<<<<<<
 *             self.reconstruct_indices = reconstruct_indices
 *             self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_dQs));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dQs));
  __Pyx_GOTREF(__pyx_v_self->dQs);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->dQs));
  __pyx_v_self->dQs = ((PyArrayObject *)__pyx_v_dQs);

  /* "GPy/models/state_space_cython.pyx":428
 *             self.dAs = dAs
 *             self.dQs = dQs
 *             self.reconstruct_indices = reconstruct_indices             # <<<<<<<<<<<<<<
 *             self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\
 *                             (self.dAs.nbytes if (self.dAs is not None) else 0) +\
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_reconstruct_indices));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_reconstruct_indices));
  __Pyx_GOTREF(__pyx_v_self->reconstruct_indices);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->reconstruct_indices));
  __pyx_v_self->reconstruct_indices = ((PyArrayObject *)__pyx_v_reconstruct_indices);

  /* "GPy/models/state_space_cython.pyx":429
 *             self.dQs = dQs
 *             self.reconstruct_indices = reconstruct_indices
 *             self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\             # <<<<<<<<<<<<<<
 *                             (self.dAs.nbytes if (self.dAs is not None) else 0) +\
 *                             (self.dQs.nbytes if (self.dQs is not None) else 0) +\
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->As), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->Qs), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 429, __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;

  /* "GPy/models/state_space_cython.pyx":430
 *             self.reconstruct_indices = reconstruct_indices
 *             self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\
 *                             (self.dAs.nbytes if (self.dAs is not None) else 0) +\             # <<<<<<<<<<<<<<
 *                             (self.dQs.nbytes if (self.dQs is not None) else 0) +\
 *                             (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0)
 */
  __pyx_t_4 = (((PyObject *)__pyx_v_self->dAs) != Py_None);
  if ((__pyx_t_4 != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->dAs), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_t_1;
    __pyx_t_1 = 0;
  } else {
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_2 = __pyx_int_0;
  }

  /* "GPy/models/state_space_cython.pyx":429
 *             self.dQs = dQs
 *             self.reconstruct_indices = reconstruct_indices
 *             self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\             # <<<<<<<<<<<<<<
 *                             (self.dAs.nbytes if (self.dAs is not None) else 0) +\
 *                             (self.dQs.nbytes if (self.dQs is not None) else 0) +\
 */
  __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __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;

  /* "GPy/models/state_space_cython.pyx":431
 *             self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\
 *                             (self.dAs.nbytes if (self.dAs is not None) else 0) +\
 *                             (self.dQs.nbytes if (self.dQs is not None) else 0) +\             # <<<<<<<<<<<<<<
 *                             (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0)
 * 
 */
  __pyx_t_4 = (((PyObject *)__pyx_v_self->dQs) != Py_None);
  if ((__pyx_t_4 != 0)) {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->dQs), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __pyx_t_3;
    __pyx_t_3 = 0;
  } else {
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_2 = __pyx_int_0;
  }

  /* "GPy/models/state_space_cython.pyx":430
 *             self.reconstruct_indices = reconstruct_indices
 *             self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\
 *                             (self.dAs.nbytes if (self.dAs is not None) else 0) +\             # <<<<<<<<<<<<<<
 *                             (self.dQs.nbytes if (self.dQs is not None) else 0) +\
 *                             (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0)
 */
  __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __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;

  /* "GPy/models/state_space_cython.pyx":432
 *                             (self.dAs.nbytes if (self.dAs is not None) else 0) +\
 *                             (self.dQs.nbytes if (self.dQs is not None) else 0) +\
 *                             (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0)             # <<<<<<<<<<<<<<
 * 
 *             self.Q_svd_dict = {}
 */
  __pyx_t_4 = (((PyObject *)__pyx_v_self->reconstruct_indices) != Py_None);
  if ((__pyx_t_4 != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 432, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_t_1;
    __pyx_t_1 = 0;
  } else {
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_2 = __pyx_int_0;
  }

  /* "GPy/models/state_space_cython.pyx":431
 *             self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\
 *                             (self.dAs.nbytes if (self.dAs is not None) else 0) +\
 *                             (self.dQs.nbytes if (self.dQs is not None) else 0) +\             # <<<<<<<<<<<<<<
 *                             (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0)
 * 
 */
  __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __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;

  /* "GPy/models/state_space_cython.pyx":429
 *             self.dQs = dQs
 *             self.reconstruct_indices = reconstruct_indices
 *             self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\             # <<<<<<<<<<<<<<
 *                             (self.dAs.nbytes if (self.dAs is not None) else 0) +\
 *                             (self.dQs.nbytes if (self.dQs is not None) else 0) +\
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_total_size_of_data, __pyx_t_1) < 0) __PYX_ERR(0, 429, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":434
 *                             (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0)
 * 
 *             self.Q_svd_dict = {}             # <<<<<<<<<<<<<<
 *             self.Q_square_root_dict = {}
 *             self.Q_inverse_dict = {}
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->Q_svd_dict);
  __Pyx_DECREF(__pyx_v_self->Q_svd_dict);
  __pyx_v_self->Q_svd_dict = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":435
 * 
 *             self.Q_svd_dict = {}
 *             self.Q_square_root_dict = {}             # <<<<<<<<<<<<<<
 *             self.Q_inverse_dict = {}
 *             self.last_k = 0
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_square_root_dict, __pyx_t_1) < 0) __PYX_ERR(0, 435, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":436
 *             self.Q_svd_dict = {}
 *             self.Q_square_root_dict = {}
 *             self.Q_inverse_dict = {}             # <<<<<<<<<<<<<<
 *             self.last_k = 0
 *              # !!!Print statistics! Which object is created
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_inverse_dict, __pyx_t_1) < 0) __PYX_ERR(0, 436, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":437
 *             self.Q_square_root_dict = {}
 *             self.Q_inverse_dict = {}
 *             self.last_k = 0             # <<<<<<<<<<<<<<
 *              # !!!Print statistics! Which object is created
 *             # !!!Print statistics! Print sizes of matrices
 */
  __pyx_v_self->last_k = 0;

  /* "GPy/models/state_space_cython.pyx":399
 *             int last_k
 * 
 *         def __init__(self, np.ndarray[DTYPE_t, ndim=3] As, np.ndarray[DTYPE_t, ndim=3] Qs,             # <<<<<<<<<<<<<<
 *                      np.ndarray[DTYPE_int_t, ndim=1] reconstruct_indices,
 *                      np.ndarray[DTYPE_t, ndim=4] dAs=None,
 */

  /* 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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_As.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Qs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dAs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_reconstruct_indices.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_As.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Qs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dAs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_reconstruct_indices.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":440
 *              # !!!Print statistics! Which object is created
 *             # !!!Print statistics! Print sizes of matrices
 *         cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A):             # <<<<<<<<<<<<<<
 *             """
 *             Dynamic model
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_A;
  __Pyx_Buffer __pyx_pybuffer_A;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("f_a", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __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_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 440, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 440, __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]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1];
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_f_a); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_3f_a)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 440, __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_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_A)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_A)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 440, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(((PyObject *)__pyx_v_m));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_m));
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m));
          __Pyx_INCREF(((PyObject *)__pyx_v_A));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_A));
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_A));
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __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;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":444
 *             Dynamic model
 *             """
 *             return np.dot(A, m) # default dynamic model             # <<<<<<<<<<<<<<
 * 
 *         cpdef reset(self, bint compute_derivatives=False):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && 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_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_A), ((PyObject *)__pyx_v_m)};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 444, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_A), ((PyObject *)__pyx_v_m)};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 444, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 444, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_A));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_A));
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_A));
    __Pyx_INCREF(((PyObject *)__pyx_v_m));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_m));
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 444, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":440
 *              # !!!Print statistics! Which object is created
 *             # !!!Print statistics! Print sizes of matrices
 *         cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A):             # <<<<<<<<<<<<<<
 *             """
 *             Dynamic model
 */

  /* 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_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_2f_a[] = "\n            Dynamic model\n            ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_m = 0;
  PyArrayObject *__pyx_v_A = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("f_a (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_A,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 1); __PYX_ERR(0, 440, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 2); __PYX_ERR(0, 440, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f_a") < 0)) __PYX_ERR(0, 440, __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_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 440, __pyx_L3_error)
    __pyx_v_m = ((PyArrayObject *)values[1]);
    __pyx_v_A = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 440, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) __PYX_ERR(0, 440, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_A), __pyx_ptype_5numpy_ndarray, 1, "A", 0))) __PYX_ERR(0, 440, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_2f_a(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __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_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_2f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_A;
  __Pyx_Buffer __pyx_pybuffer_A;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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("f_a", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __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_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 440, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 440, __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]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_f_a(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m), ((PyArrayObject *)__pyx_v_A), 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":446
 *             return np.dot(A, m) # default dynamic model
 * 
 *         cpdef reset(self, bint compute_derivatives=False):             # <<<<<<<<<<<<<<
 *             """
 *             For reusing this object e.g. in smoother computation. It makes sence
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_5reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset *__pyx_optional_args) {
  int __pyx_v_compute_derivatives = ((int)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("reset", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_compute_derivatives = __pyx_optional_args->compute_derivatives;
    }
  }
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_5reset)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_compute_derivatives); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 446, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 446, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":452
 *             time steps.
 *             """
 *             return self             # <<<<<<<<<<<<<<
 * 
 *         cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":446
 *             return np.dot(A, m) # default dynamic model
 * 
 *         cpdef reset(self, bint compute_derivatives=False):             # <<<<<<<<<<<<<<
 *             """
 *             For reusing this object e.g. in smoother computation. It makes sence
 */

  /* 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("GPy.models.state_space_cython.AQcompute_batch_Cython.reset", __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_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_5reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_4reset[] = "\n            For reusing this object e.g. in smoother computation. It makes sence\n            because necessary matrices have been already computed for all\n            time steps.\n            ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_5reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_compute_derivatives;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compute_derivatives,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);
        CYTHON_FALLTHROUGH;
        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 = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_compute_derivatives);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reset") < 0)) __PYX_ERR(0, 446, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_compute_derivatives = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_compute_derivatives == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 446, __pyx_L3_error)
    } else {
      __pyx_v_compute_derivatives = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("reset", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 446, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_4reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), __pyx_v_compute_derivatives);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_4reset(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_compute_derivatives) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reset", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.compute_derivatives = __pyx_v_compute_derivatives;
  __pyx_t_1 = __pyx_vtabptr_3GPy_6models_18state_space_cython_AQcompute_batch_Cython->__pyx_base.__pyx_base.reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __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("GPy.models.state_space_cython.AQcompute_batch_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":454
 *             return self
 * 
 *         cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P):             # <<<<<<<<<<<<<<
 *             self.last_k = k
 *             return self.As[:,:, <int>self.reconstruct_indices[k]]
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_7Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_P, int __pyx_skip_dispatch) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P;
  __Pyx_Buffer __pyx_pybuffer_P;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Ak", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __pyx_pybuffer_P.pybuffer.buf = NULL;
  __pyx_pybuffer_P.refcount = 0;
  __pyx_pybuffernd_P.data = NULL;
  __pyx_pybuffernd_P.rcbuffer = &__pyx_pybuffer_P;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 454, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P.rcbuffer->pybuffer, (PyObject*)__pyx_v_P, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 454, __pyx_L1_error)
  }
  __pyx_pybuffernd_P.diminfo[0].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P.diminfo[0].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P.diminfo[1].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P.diminfo[1].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[1];
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Ak); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_7Ak)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 454, __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_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_P)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 454, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_P)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 454, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 454, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(((PyObject *)__pyx_v_m));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_m));
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m));
          __Pyx_INCREF(((PyObject *)__pyx_v_P));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_P));
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_P));
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 454, __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;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":455
 * 
 *         cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P):
 *             self.last_k = k             # <<<<<<<<<<<<<<
 *             return self.As[:,:, <int>self.reconstruct_indices[k]]
 * 
 */
  __pyx_v_self->last_k = __pyx_v_k;

  /* "GPy/models/state_space_cython.pyx":456
 *         cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P):
 *             self.last_k = k
 *             return self.As[:,:, <int>self.reconstruct_indices[k]]             # <<<<<<<<<<<<<<
 * 
 *         cpdef Qk(self,int k):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 456, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_t_6)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_slice__10);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->As), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __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;

  /* "GPy/models/state_space_cython.pyx":454
 *             return self
 * 
 *         cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P):             # <<<<<<<<<<<<<<
 *             self.last_k = k
 *             return self.As[:,:, <int>self.reconstruct_indices[k]]
 */

  /* 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_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_7Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_7Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  PyArrayObject *__pyx_v_m = 0;
  PyArrayObject *__pyx_v_P = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("Ak (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_P,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 1); __PYX_ERR(0, 454, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_P)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 2); __PYX_ERR(0, 454, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Ak") < 0)) __PYX_ERR(0, 454, __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_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 454, __pyx_L3_error)
    __pyx_v_m = ((PyArrayObject *)values[1]);
    __pyx_v_P = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 454, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) __PYX_ERR(0, 454, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P), __pyx_ptype_5numpy_ndarray, 1, "P", 0))) __PYX_ERR(0, 454, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_6Ak(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __pyx_v_P);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_6Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_P) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P;
  __Pyx_Buffer __pyx_pybuffer_P;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m;
  __Pyx_Buffer __pyx_pybuffer_m;
  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("Ak", 0);
  __pyx_pybuffer_m.pybuffer.buf = NULL;
  __pyx_pybuffer_m.refcount = 0;
  __pyx_pybuffernd_m.data = NULL;
  __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m;
  __pyx_pybuffer_P.pybuffer.buf = NULL;
  __pyx_pybuffer_P.refcount = 0;
  __pyx_pybuffernd_P.data = NULL;
  __pyx_pybuffernd_P.rcbuffer = &__pyx_pybuffer_P;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 454, __pyx_L1_error)
  }
  __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P.rcbuffer->pybuffer, (PyObject*)__pyx_v_P, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 454, __pyx_L1_error)
  }
  __pyx_pybuffernd_P.diminfo[0].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P.diminfo[0].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P.diminfo[1].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P.diminfo[1].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[1];
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Ak(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m), ((PyArrayObject *)__pyx_v_P), 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 454, __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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":458
 *             return self.As[:,:, <int>self.reconstruct_indices[k]]
 * 
 *         cpdef Qk(self,int k):             # <<<<<<<<<<<<<<
 *             self.last_k = k
 *             return self.Qs[:,:, <int>self.reconstruct_indices[k]]
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_9Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) {
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Qk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Qk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_9Qk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 458, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 458, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":459
 * 
 *         cpdef Qk(self,int k):
 *             self.last_k = k             # <<<<<<<<<<<<<<
 *             return self.Qs[:,:, <int>self.reconstruct_indices[k]]
 * 
 */
  __pyx_v_self->last_k = __pyx_v_k;

  /* "GPy/models/state_space_cython.pyx":460
 *         cpdef Qk(self,int k):
 *             self.last_k = k
 *             return self.Qs[:,:, <int>self.reconstruct_indices[k]]             # <<<<<<<<<<<<<<
 * 
 *         cpdef dAk(self, int k):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 460, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_t_6)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_slice__10);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->Qs), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 460, __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;

  /* "GPy/models/state_space_cython.pyx":458
 *             return self.As[:,:, <int>self.reconstruct_indices[k]]
 * 
 *         cpdef Qk(self,int k):             # <<<<<<<<<<<<<<
 *             self.last_k = k
 *             return self.Qs[:,:, <int>self.reconstruct_indices[k]]
 */

  /* 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("GPy.models.state_space_cython.AQcompute_batch_Cython.Qk", __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_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_9Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_9Qk(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("Qk (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_ERR(0, 458, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_8Qk(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_8Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k) {
  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("Qk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Qk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __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("GPy.models.state_space_cython.AQcompute_batch_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":462
 *             return self.Qs[:,:, <int>self.reconstruct_indices[k]]
 * 
 *         cpdef dAk(self, int k):             # <<<<<<<<<<<<<<
 *             self.last_k = k
 *             return self.dAs[:,:, :, <int>self.reconstruct_indices[k]]
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_11dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) {
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dAk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dAk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_11dAk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 462, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 462, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":463
 * 
 *         cpdef dAk(self, int k):
 *             self.last_k = k             # <<<<<<<<<<<<<<
 *             return self.dAs[:,:, :, <int>self.reconstruct_indices[k]]
 * 
 */
  __pyx_v_self->last_k = __pyx_v_k;

  /* "GPy/models/state_space_cython.pyx":464
 *         cpdef dAk(self, int k):
 *             self.last_k = k
 *             return self.dAs[:,:, :, <int>self.reconstruct_indices[k]]             # <<<<<<<<<<<<<<
 * 
 *         cpdef dQk(self, int k):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_t_6)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_slice__10);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->dAs), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __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;

  /* "GPy/models/state_space_cython.pyx":462
 *             return self.Qs[:,:, <int>self.reconstruct_indices[k]]
 * 
 *         cpdef dAk(self, int k):             # <<<<<<<<<<<<<<
 *             self.last_k = k
 *             return self.dAs[:,:, :, <int>self.reconstruct_indices[k]]
 */

  /* 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("GPy.models.state_space_cython.AQcompute_batch_Cython.dAk", __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_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_11dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_11dAk(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("dAk (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_ERR(0, 462, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_10dAk(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_10dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k) {
  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("dAk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dAk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 462, __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("GPy.models.state_space_cython.AQcompute_batch_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":466
 *             return self.dAs[:,:, :, <int>self.reconstruct_indices[k]]
 * 
 *         cpdef dQk(self, int k):             # <<<<<<<<<<<<<<
 *             self.last_k = k
 *             return self.dQs[:,:, :, <int>self.reconstruct_indices[k]]
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_13dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) {
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dQk", 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dQk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_13dQk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 466, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 466, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":467
 * 
 *         cpdef dQk(self, int k):
 *             self.last_k = k             # <<<<<<<<<<<<<<
 *             return self.dQs[:,:, :, <int>self.reconstruct_indices[k]]
 * 
 */
  __pyx_v_self->last_k = __pyx_v_k;

  /* "GPy/models/state_space_cython.pyx":468
 *         cpdef dQk(self, int k):
 *             self.last_k = k
 *             return self.dQs[:,:, :, <int>self.reconstruct_indices[k]]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_t_6)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_slice__10);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_slice__10);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->dQs), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __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;

  /* "GPy/models/state_space_cython.pyx":466
 *             return self.dAs[:,:, :, <int>self.reconstruct_indices[k]]
 * 
 *         cpdef dQk(self, int k):             # <<<<<<<<<<<<<<
 *             self.last_k = k
 *             return self.dQs[:,:, :, <int>self.reconstruct_indices[k]]
 */

  /* 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("GPy.models.state_space_cython.AQcompute_batch_Cython.dQk", __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_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_13dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_13dQk(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("dQk (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_ERR(0, 466, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_12dQk(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_12dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k) {
  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("dQk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dQk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __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("GPy.models.state_space_cython.AQcompute_batch_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":471
 * 
 * 
 *         cpdef Q_srk(self, int k):             # <<<<<<<<<<<<<<
 *             """
 *             Square root of the noise matrix Q
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_15Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) {
  int __pyx_v_matrix_index;
  PyArrayObject *__pyx_v_square_root = 0;
  PyArrayObject *__pyx_v_U = 0;
  PyArrayObject *__pyx_v_S = 0;
  PyArrayObject *__pyx_v_Vh = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S;
  __Pyx_Buffer __pyx_pybuffer_S;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_U;
  __Pyx_Buffer __pyx_pybuffer_U;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh;
  __Pyx_Buffer __pyx_pybuffer_Vh;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_square_root;
  __Pyx_Buffer __pyx_pybuffer_square_root;
  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;
  int __pyx_t_7;
  int __pyx_t_8;
  PyArrayObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyArrayObject *__pyx_t_14 = NULL;
  PyArrayObject *__pyx_t_15 = NULL;
  PyArrayObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Q_srk", 0);
  __pyx_pybuffer_square_root.pybuffer.buf = NULL;
  __pyx_pybuffer_square_root.refcount = 0;
  __pyx_pybuffernd_square_root.data = NULL;
  __pyx_pybuffernd_square_root.rcbuffer = &__pyx_pybuffer_square_root;
  __pyx_pybuffer_U.pybuffer.buf = NULL;
  __pyx_pybuffer_U.refcount = 0;
  __pyx_pybuffernd_U.data = NULL;
  __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U;
  __pyx_pybuffer_S.pybuffer.buf = NULL;
  __pyx_pybuffer_S.refcount = 0;
  __pyx_pybuffernd_S.data = NULL;
  __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S;
  __pyx_pybuffer_Vh.pybuffer.buf = NULL;
  __pyx_pybuffer_Vh.refcount = 0;
  __pyx_pybuffernd_Vh.data = NULL;
  __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh;
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_srk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_15Q_srk)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 471, __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_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __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;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":476
 *             """
 * 
 *             cdef int matrix_index = <int>self.reconstruct_indices[k]             # <<<<<<<<<<<<<<
 *             cdef np.ndarray[DTYPE_t, ndim=2] square_root
 * 
 */
  __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 476, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_matrix_index = ((int)__pyx_t_6);

  /* "GPy/models/state_space_cython.pyx":484
 * 
 * 
 *             if matrix_index in self.Q_square_root_dict:             # <<<<<<<<<<<<<<
 *                 square_root = self.Q_square_root_dict[matrix_index]
 *             else:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_square_root_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "GPy/models/state_space_cython.pyx":485
 * 
 *             if matrix_index in self.Q_square_root_dict:
 *                 square_root = self.Q_square_root_dict[matrix_index]             # <<<<<<<<<<<<<<
 *             else:
 *                 if matrix_index not in self.Q_svd_dict:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_square_root_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 485, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_matrix_index, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 485, __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_ERR(0, 485, __pyx_L1_error)
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer);
      __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_6 < 0)) {
        PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
      }
      __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 485, __pyx_L1_error)
    }
    __pyx_t_9 = 0;
    __pyx_v_square_root = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "GPy/models/state_space_cython.pyx":484
 * 
 * 
 *             if matrix_index in self.Q_square_root_dict:             # <<<<<<<<<<<<<<
 *                 square_root = self.Q_square_root_dict[matrix_index]
 *             else:
 */
    goto __pyx_L3;
  }

  /* "GPy/models/state_space_cython.pyx":487
 *                 square_root = self.Q_square_root_dict[matrix_index]
 *             else:
 *                 if matrix_index not in self.Q_svd_dict:             # <<<<<<<<<<<<<<
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],
 *                                         full_matrices=False, compute_uv=True,
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 487, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__pyx_v_self->Q_svd_dict == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 487, __pyx_L1_error)
    }
    __pyx_t_8 = (__Pyx_PyDict_ContainsTF(__pyx_t_1, __pyx_v_self->Q_svd_dict, Py_NE)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 487, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = (__pyx_t_8 != 0);
    if (__pyx_t_7) {

      /* "GPy/models/state_space_cython.pyx":488
 *             else:
 *                 if matrix_index not in self.Q_svd_dict:
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],             # <<<<<<<<<<<<<<
 *                                         full_matrices=False, compute_uv=True,
 *                                         overwrite_a=False, check_finite=False)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_sp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_linalg); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 488, __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_svd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->Qs), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "GPy/models/state_space_cython.pyx":489
 *                 if matrix_index not in self.Q_svd_dict:
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],
 *                                         full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                                         overwrite_a=False, check_finite=False)
 *                     self.Q_svd_dict[matrix_index] = (U,S,Vh)
 */
      __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 489, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_full_matrices, Py_False) < 0) __PYX_ERR(0, 489, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_compute_uv, Py_True) < 0) __PYX_ERR(0, 489, __pyx_L1_error)

      /* "GPy/models/state_space_cython.pyx":490
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],
 *                                         full_matrices=False, compute_uv=True,
 *                                         overwrite_a=False, check_finite=False)             # <<<<<<<<<<<<<<
 *                     self.Q_svd_dict[matrix_index] = (U,S,Vh)
 *                 else:
 */
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_overwrite_a, Py_False) < 0) __PYX_ERR(0, 489, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_check_finite, Py_False) < 0) __PYX_ERR(0, 489, __pyx_L1_error)

      /* "GPy/models/state_space_cython.pyx":488
 *             else:
 *                 if matrix_index not in self.Q_svd_dict:
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],             # <<<<<<<<<<<<<<
 *                                         full_matrices=False, compute_uv=True,
 *                                         overwrite_a=False, check_finite=False)
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 488, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 488, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 488, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 488, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 488, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_4 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 2; __pyx_t_1 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_5), 3) < 0) __PYX_ERR(0, 488, __pyx_L1_error)
        __pyx_t_13 = NULL;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L6_unpacking_done;
        __pyx_L5_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_13 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 488, __pyx_L1_error)
        __pyx_L6_unpacking_done:;
      }
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 488, __pyx_L1_error)
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 488, __pyx_L1_error)
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 488, __pyx_L1_error)
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
        }
        __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 488, __pyx_L1_error)
      }
      __pyx_t_14 = 0;
      __pyx_v_U = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_15 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
        }
        __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 488, __pyx_L1_error)
      }
      __pyx_t_15 = 0;
      __pyx_v_S = ((PyArrayObject *)__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_16 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
        }
        __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 488, __pyx_L1_error)
      }
      __pyx_t_16 = 0;
      __pyx_v_Vh = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "GPy/models/state_space_cython.pyx":491
 *                                         full_matrices=False, compute_uv=True,
 *                                         overwrite_a=False, check_finite=False)
 *                     self.Q_svd_dict[matrix_index] = (U,S,Vh)             # <<<<<<<<<<<<<<
 *                 else:
 *                     U,S,Vh = self.Q_svd_dict[matrix_index]
 */
      __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 491, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_U));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_U));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_U));
      __Pyx_INCREF(((PyObject *)__pyx_v_S));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_S));
      PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_S));
      __Pyx_INCREF(((PyObject *)__pyx_v_Vh));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Vh));
      PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_v_Vh));
      if (unlikely(__pyx_v_self->Q_svd_dict == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 491, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 491, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PyDict_SetItem(__pyx_v_self->Q_svd_dict, __pyx_t_1, __pyx_t_3) < 0)) __PYX_ERR(0, 491, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "GPy/models/state_space_cython.pyx":487
 *                 square_root = self.Q_square_root_dict[matrix_index]
 *             else:
 *                 if matrix_index not in self.Q_svd_dict:             # <<<<<<<<<<<<<<
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],
 *                                         full_matrices=False, compute_uv=True,
 */
      goto __pyx_L4;
    }

    /* "GPy/models/state_space_cython.pyx":493
 *                     self.Q_svd_dict[matrix_index] = (U,S,Vh)
 *                 else:
 *                     U,S,Vh = self.Q_svd_dict[matrix_index]             # <<<<<<<<<<<<<<
 * 
 *                 square_root = U * np.sqrt(S)
 */
    /*else*/ {
      if (unlikely(__pyx_v_self->Q_svd_dict == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 493, __pyx_L1_error)
      }
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 493, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_self->Q_svd_dict, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 493, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 493, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 493, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 493, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 493, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 493, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_4 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 2; __pyx_t_2 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_5), 3) < 0) __PYX_ERR(0, 493, __pyx_L1_error)
        __pyx_t_13 = NULL;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_13 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 493, __pyx_L1_error)
        __pyx_L8_unpacking_done:;
      }
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 493, __pyx_L1_error)
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 493, __pyx_L1_error)
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 493, __pyx_L1_error)
      __pyx_t_14 = ((PyArrayObject *)__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
        }
        __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 493, __pyx_L1_error)
      }
      __pyx_t_14 = 0;
      __pyx_v_U = ((PyArrayObject *)__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_15 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
        }
        __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 493, __pyx_L1_error)
      }
      __pyx_t_15 = 0;
      __pyx_v_S = ((PyArrayObject *)__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_16 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
        __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_6 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_10 = __pyx_t_11 = __pyx_t_12 = 0;
        }
        __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 493, __pyx_L1_error)
      }
      __pyx_t_16 = 0;
      __pyx_v_Vh = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
    }
    __pyx_L4:;

    /* "GPy/models/state_space_cython.pyx":495
 *                     U,S,Vh = self.Q_svd_dict[matrix_index]
 * 
 *                 square_root = U * np.sqrt(S)             # <<<<<<<<<<<<<<
 *                 self.Q_square_root_dict[matrix_index] = square_root
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 495, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 495, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, ((PyObject *)__pyx_v_S)) : __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_S));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Multiply(((PyObject *)__pyx_v_U), __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 495, __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_5numpy_ndarray))))) __PYX_ERR(0, 495, __pyx_L1_error)
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer);
      __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_6 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_12 = __pyx_t_11 = __pyx_t_10 = 0;
      }
      __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 495, __pyx_L1_error)
    }
    __pyx_t_9 = 0;
    __pyx_v_square_root = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "GPy/models/state_space_cython.pyx":496
 * 
 *                 square_root = U * np.sqrt(S)
 *                 self.Q_square_root_dict[matrix_index] = square_root             # <<<<<<<<<<<<<<
 * 
 *             return square_root
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_square_root_dict); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__Pyx_SetItemInt(__pyx_t_4, __pyx_v_matrix_index, ((PyObject *)__pyx_v_square_root), int, 1, __Pyx_PyInt_From_int, 0, 1, 1) < 0)) __PYX_ERR(0, 496, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "GPy/models/state_space_cython.pyx":498
 *                 self.Q_square_root_dict[matrix_index] = square_root
 * 
 *             return square_root             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_square_root));
  __pyx_r = ((PyObject *)__pyx_v_square_root);
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":471
 * 
 * 
 *         cpdef Q_srk(self, int k):             # <<<<<<<<<<<<<<
 *             """
 *             Square root of the noise matrix Q
 */

  /* 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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_square_root);
  __Pyx_XDECREF((PyObject *)__pyx_v_U);
  __Pyx_XDECREF((PyObject *)__pyx_v_S);
  __Pyx_XDECREF((PyObject *)__pyx_v_Vh);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_15Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_14Q_srk[] = "\n            Square root of the noise matrix Q\n            ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_15Q_srk(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("Q_srk (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_ERR(0, 471, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_14Q_srk(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), ((int)__pyx_v_k));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_14Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k) {
  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("Q_srk", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_srk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __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("GPy.models.state_space_cython.AQcompute_batch_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":501
 * 
 * 
 *         cpdef Q_inverse(self, int k, float jitter=0.0):             # <<<<<<<<<<<<<<
 *             """
 *             Square root of the noise matrix Q
 */

static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_17Q_inverse(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_inverse(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_inverse *__pyx_optional_args) {
  float __pyx_v_jitter = ((float)0.0);
  int __pyx_v_matrix_index;
  PyArrayObject *__pyx_v_U = 0;
  PyArrayObject *__pyx_v_S = 0;
  PyArrayObject *__pyx_v_Vh = 0;
  PyObject *__pyx_v_Q_inverse = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S;
  __Pyx_Buffer __pyx_pybuffer_S;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_U;
  __Pyx_Buffer __pyx_pybuffer_U;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh;
  __Pyx_Buffer __pyx_pybuffer_Vh;
  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;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyArrayObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyArrayObject *__pyx_t_16 = NULL;
  PyArrayObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Q_inverse", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_jitter = __pyx_optional_args->jitter;
    }
  }
  __pyx_pybuffer_U.pybuffer.buf = NULL;
  __pyx_pybuffer_U.refcount = 0;
  __pyx_pybuffernd_U.data = NULL;
  __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U;
  __pyx_pybuffer_S.pybuffer.buf = NULL;
  __pyx_pybuffer_S.refcount = 0;
  __pyx_pybuffernd_S.data = NULL;
  __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S;
  __pyx_pybuffer_Vh.pybuffer.buf = NULL;
  __pyx_pybuffer_Vh.refcount = 0;
  __pyx_pybuffernd_Vh.data = NULL;
  __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh;
  /* 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) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_inverse); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 501, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_17Q_inverse)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 501, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyFloat_FromDouble(__pyx_v_jitter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 501, __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_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_4};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 501, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_4};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 501, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 501, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          if (__pyx_t_6) {
            __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __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_ERR(0, 501, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "GPy/models/state_space_cython.pyx":506
 *             """
 * 
 *             cdef int matrix_index = <int>self.reconstruct_indices[k]             # <<<<<<<<<<<<<<
 *             cdef np.ndarray[DTYPE_t, ndim=2] square_root
 * 
 */
  __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 506, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_matrix_index = ((int)__pyx_t_7);

  /* "GPy/models/state_space_cython.pyx":514
 * 
 * 
 *             if matrix_index in self.Q_inverse_dict:             # <<<<<<<<<<<<<<
 *                 Q_inverse = self.Q_inverse_dict[matrix_index]
 *             else:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_inverse_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_10 = (__pyx_t_9 != 0);
  if (__pyx_t_10) {

    /* "GPy/models/state_space_cython.pyx":515
 * 
 *             if matrix_index in self.Q_inverse_dict:
 *                 Q_inverse = self.Q_inverse_dict[matrix_index]             # <<<<<<<<<<<<<<
 *             else:
 *                 if matrix_index not in self.Q_svd_dict:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_inverse_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_matrix_index, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_Q_inverse = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "GPy/models/state_space_cython.pyx":514
 * 
 * 
 *             if matrix_index in self.Q_inverse_dict:             # <<<<<<<<<<<<<<
 *                 Q_inverse = self.Q_inverse_dict[matrix_index]
 *             else:
 */
    goto __pyx_L3;
  }

  /* "GPy/models/state_space_cython.pyx":517
 *                 Q_inverse = self.Q_inverse_dict[matrix_index]
 *             else:
 *                 if matrix_index not in self.Q_svd_dict:             # <<<<<<<<<<<<<<
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],
 *                                         full_matrices=False, compute_uv=True,
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__pyx_v_self->Q_svd_dict == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 517, __pyx_L1_error)
    }
    __pyx_t_10 = (__Pyx_PyDict_ContainsTF(__pyx_t_1, __pyx_v_self->Q_svd_dict, Py_NE)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_9 = (__pyx_t_10 != 0);
    if (__pyx_t_9) {

      /* "GPy/models/state_space_cython.pyx":518
 *             else:
 *                 if matrix_index not in self.Q_svd_dict:
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],             # <<<<<<<<<<<<<<
 *                                         full_matrices=False, compute_uv=True,
 *                                         overwrite_a=False, check_finite=False)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_sp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_linalg); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __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_svd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->Qs), __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "GPy/models/state_space_cython.pyx":519
 *                 if matrix_index not in self.Q_svd_dict:
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],
 *                                         full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                                         overwrite_a=False, check_finite=False)
 *                     self.Q_svd_dict[matrix_index] = (U,S,Vh)
 */
      __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 519, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_full_matrices, Py_False) < 0) __PYX_ERR(0, 519, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_compute_uv, Py_True) < 0) __PYX_ERR(0, 519, __pyx_L1_error)

      /* "GPy/models/state_space_cython.pyx":520
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],
 *                                         full_matrices=False, compute_uv=True,
 *                                         overwrite_a=False, check_finite=False)             # <<<<<<<<<<<<<<
 *                     self.Q_svd_dict[matrix_index] = (U,S,Vh)
 *                 else:
 */
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_overwrite_a, Py_False) < 0) __PYX_ERR(0, 519, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_check_finite, Py_False) < 0) __PYX_ERR(0, 519, __pyx_L1_error)

      /* "GPy/models/state_space_cython.pyx":518
 *             else:
 *                 if matrix_index not in self.Q_svd_dict:
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],             # <<<<<<<<<<<<<<
 *                                         full_matrices=False, compute_uv=True,
 *                                         overwrite_a=False, check_finite=False)
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
        PyObject* sequence = __pyx_t_8;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 518, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 518, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 518, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_11(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_5 = __pyx_t_11(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 2; __pyx_t_1 = __pyx_t_11(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_4), 3) < 0) __PYX_ERR(0, 518, __pyx_L1_error)
        __pyx_t_11 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L6_unpacking_done;
        __pyx_L5_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_11 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 518, __pyx_L1_error)
        __pyx_L6_unpacking_done:;
      }
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 518, __pyx_L1_error)
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 518, __pyx_L1_error)
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 518, __pyx_L1_error)
      __pyx_t_12 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_13 = __pyx_t_14 = __pyx_t_15 = 0;
        }
        __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 518, __pyx_L1_error)
      }
      __pyx_t_12 = 0;
      __pyx_v_U = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_16 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
          }
          __pyx_t_15 = __pyx_t_14 = __pyx_t_13 = 0;
        }
        __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 518, __pyx_L1_error)
      }
      __pyx_t_16 = 0;
      __pyx_v_S = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_17 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_13 = __pyx_t_14 = __pyx_t_15 = 0;
        }
        __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 518, __pyx_L1_error)
      }
      __pyx_t_17 = 0;
      __pyx_v_Vh = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "GPy/models/state_space_cython.pyx":521
 *                                         full_matrices=False, compute_uv=True,
 *                                         overwrite_a=False, check_finite=False)
 *                     self.Q_svd_dict[matrix_index] = (U,S,Vh)             # <<<<<<<<<<<<<<
 *                 else:
 *                     U,S,Vh = self.Q_svd_dict[matrix_index]
 */
      __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 521, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(((PyObject *)__pyx_v_U));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_U));
      PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_U));
      __Pyx_INCREF(((PyObject *)__pyx_v_S));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_S));
      PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_v_S));
      __Pyx_INCREF(((PyObject *)__pyx_v_Vh));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Vh));
      PyTuple_SET_ITEM(__pyx_t_8, 2, ((PyObject *)__pyx_v_Vh));
      if (unlikely(__pyx_v_self->Q_svd_dict == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 521, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 521, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PyDict_SetItem(__pyx_v_self->Q_svd_dict, __pyx_t_1, __pyx_t_8) < 0)) __PYX_ERR(0, 521, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "GPy/models/state_space_cython.pyx":517
 *                 Q_inverse = self.Q_inverse_dict[matrix_index]
 *             else:
 *                 if matrix_index not in self.Q_svd_dict:             # <<<<<<<<<<<<<<
 *                     U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index],
 *                                         full_matrices=False, compute_uv=True,
 */
      goto __pyx_L4;
    }

    /* "GPy/models/state_space_cython.pyx":523
 *                     self.Q_svd_dict[matrix_index] = (U,S,Vh)
 *                 else:
 *                     U,S,Vh = self.Q_svd_dict[matrix_index]             # <<<<<<<<<<<<<<
 * 
 *                 Q_inverse = Q_inverse = np.dot( Vh.T * ( 1.0/(S + jitter)) , U.T )
 */
    /*else*/ {
      if (unlikely(__pyx_v_self->Q_svd_dict == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 523, __pyx_L1_error)
      }
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 523, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_self->Q_svd_dict, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 523, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 523, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 523, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 523, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 523, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 523, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_8 = __pyx_t_11(__pyx_t_4); if (unlikely(!__pyx_t_8)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        index = 1; __pyx_t_5 = __pyx_t_11(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 2; __pyx_t_2 = __pyx_t_11(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_4), 3) < 0) __PYX_ERR(0, 523, __pyx_L1_error)
        __pyx_t_11 = 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_11 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 523, __pyx_L1_error)
        __pyx_L8_unpacking_done:;
      }
      if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 523, __pyx_L1_error)
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 523, __pyx_L1_error)
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 523, __pyx_L1_error)
      __pyx_t_12 = ((PyArrayObject *)__pyx_t_8);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
          }
          __pyx_t_15 = __pyx_t_14 = __pyx_t_13 = 0;
        }
        __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 523, __pyx_L1_error)
      }
      __pyx_t_12 = 0;
      __pyx_v_U = ((PyArrayObject *)__pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_16 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 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_t_13 = __pyx_t_14 = __pyx_t_15 = 0;
        }
        __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 523, __pyx_L1_error)
      }
      __pyx_t_16 = 0;
      __pyx_v_S = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_17 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
        __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_7 < 0)) {
          PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
          }
          __pyx_t_15 = __pyx_t_14 = __pyx_t_13 = 0;
        }
        __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 523, __pyx_L1_error)
      }
      __pyx_t_17 = 0;
      __pyx_v_Vh = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
    }
    __pyx_L4:;

    /* "GPy/models/state_space_cython.pyx":525
 *                     U,S,Vh = self.Q_svd_dict[matrix_index]
 * 
 *                 Q_inverse = Q_inverse = np.dot( Vh.T * ( 1.0/(S + jitter)) , U.T )             # <<<<<<<<<<<<<<
 *                 self.Q_inverse_dict[matrix_index] = Q_inverse
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Vh), __pyx_n_s_T); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = PyFloat_FromDouble(__pyx_v_jitter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_v_S), __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyFloat_DivideCObj(__pyx_float_1_0, __pyx_t_4, 1.0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_U), __pyx_n_s_T); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_4, __pyx_t_8};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_4, __pyx_t_8};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 525, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_t_8);
      __pyx_t_4 = 0;
      __pyx_t_8 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v_Q_inverse = __pyx_t_1;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_Q_inverse, __pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "GPy/models/state_space_cython.pyx":526
 * 
 *                 Q_inverse = Q_inverse = np.dot( Vh.T * ( 1.0/(S + jitter)) , U.T )
 *                 self.Q_inverse_dict[matrix_index] = Q_inverse             # <<<<<<<<<<<<<<
 * 
 *             return Q_inverse
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_inverse_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__Pyx_SetItemInt(__pyx_t_1, __pyx_v_matrix_index, __pyx_v_Q_inverse, int, 1, __Pyx_PyInt_From_int, 0, 1, 1) < 0)) __PYX_ERR(0, 526, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "GPy/models/state_space_cython.pyx":528
 *                 self.Q_inverse_dict[matrix_index] = Q_inverse
 * 
 *             return Q_inverse             # <<<<<<<<<<<<<<
 * 
 * #        def return_last(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_Q_inverse);
  __pyx_r = __pyx_v_Q_inverse;
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":501
 * 
 * 
 *         cpdef Q_inverse(self, int k, float jitter=0.0):             # <<<<<<<<<<<<<<
 *             """
 *             Square root of the noise matrix Q
 */

  /* 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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Q_inverse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_U);
  __Pyx_XDECREF((PyObject *)__pyx_v_S);
  __Pyx_XDECREF((PyObject *)__pyx_v_Vh);
  __Pyx_XDECREF(__pyx_v_Q_inverse);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_17Q_inverse(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_16Q_inverse[] = "\n            Square root of the noise matrix Q\n            ";
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_17Q_inverse(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_k;
  float __pyx_v_jitter;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("Q_inverse (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_jitter,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_jitter);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Q_inverse") < 0)) __PYX_ERR(0, 501, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 501, __pyx_L3_error)
    if (values[1]) {
      __pyx_v_jitter = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_jitter == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 501, __pyx_L3_error)
    } else {
      __pyx_v_jitter = ((float)0.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("Q_inverse", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 501, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Q_inverse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_16Q_inverse(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_jitter);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_16Q_inverse(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, float __pyx_v_jitter) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_inverse __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Q_inverse", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.jitter = __pyx_v_jitter;
  __pyx_t_1 = __pyx_vtabptr_3GPy_6models_18state_space_cython_AQcompute_batch_Cython->Q_inverse(__pyx_v_self, __pyx_v_k, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 501, __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("GPy.models.state_space_cython.AQcompute_batch_Cython.Q_inverse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_19__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_19__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_18__reduce_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_18__reduce_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.As, self.Q, self.Q_square_root, self.Q_svd_dict, self.Q_time_var_index, self.Qs, self.dAs, self.dQ, self.dQs, self.index, self.last_k, self.reconstruct_indices, self.svd_each_time)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.Q_time_var_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->last_k); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->__pyx_base.svd_each_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(13); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->As));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->As));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self->As));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.Q));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.Q));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_self->__pyx_base.Q));
  __Pyx_INCREF(__pyx_v_self->__pyx_base.Q_square_root);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.Q_square_root);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_self->__pyx_base.Q_square_root);
  __Pyx_INCREF(__pyx_v_self->Q_svd_dict);
  __Pyx_GIVEREF(__pyx_v_self->Q_svd_dict);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_self->Q_svd_dict);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->Qs));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->Qs));
  PyTuple_SET_ITEM(__pyx_t_4, 5, ((PyObject *)__pyx_v_self->Qs));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dAs));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->dAs));
  PyTuple_SET_ITEM(__pyx_t_4, 6, ((PyObject *)__pyx_v_self->dAs));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.dQ));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.dQ));
  PyTuple_SET_ITEM(__pyx_t_4, 7, ((PyObject *)__pyx_v_self->__pyx_base.dQ));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dQs));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->dQs));
  PyTuple_SET_ITEM(__pyx_t_4, 8, ((PyObject *)__pyx_v_self->dQs));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.index));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.index));
  PyTuple_SET_ITEM(__pyx_t_4, 9, ((PyObject *)__pyx_v_self->__pyx_base.index));
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 10, __pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->reconstruct_indices));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->reconstruct_indices));
  PyTuple_SET_ITEM(__pyx_t_4, 11, ((PyObject *)__pyx_v_self->reconstruct_indices));
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 12, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.As, self.Q, self.Q_square_root, self.Q_svd_dict, self.Q_time_var_index, self.Qs, self.dAs, self.dQ, self.dQs, self.index, self.last_k, self.reconstruct_indices, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_4 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v__dict = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":7
 *     state = (self.As, self.Q, self.Q_square_root, self.Q_svd_dict, self.Q_time_var_index, self.Qs, self.dAs, self.dQ, self.dQs, self.index, self.last_k, self.reconstruct_indices, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_5 = (__pyx_v__dict != Py_None);
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v__dict);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.As is not None or self.Q is not None or self.Q_square_root is not None or self.Q_svd_dict is not None or self.Qs is not None or self.dAs is not None or self.dQ is not None or self.dQs is not None or self.index is not None or self.reconstruct_indices is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.As, self.Q, self.Q_square_root, self.Q_svd_dict, self.Q_time_var_index, self.Qs, self.dAs, self.dQ, self.dQs, self.index, self.last_k, self.reconstruct_indices, self.svd_each_time)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.As is not None or self.Q is not None or self.Q_square_root is not None or self.Q_svd_dict is not None or self.Qs is not None or self.dAs is not None or self.dQ is not None or self.dQs is not None or self.index is not None or self.reconstruct_indices is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_AQcompute_batch_Cython, (type(self), 0x146e1f7, None), state
 */
  /*else*/ {
    __pyx_t_5 = (((PyObject *)__pyx_v_self->As) != Py_None);
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_7 = (((PyObject *)__pyx_v_self->__pyx_base.Q) != Py_None);
    __pyx_t_5 = (__pyx_t_7 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_6 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->__pyx_base.Q_square_root != ((PyObject*)Py_None));
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_7 = (__pyx_v_self->Q_svd_dict != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_7 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_6 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->Qs) != Py_None);
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_7 = (((PyObject *)__pyx_v_self->dAs) != Py_None);
    __pyx_t_5 = (__pyx_t_7 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_6 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->__pyx_base.dQ) != Py_None);
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_7 = (((PyObject *)__pyx_v_self->dQs) != Py_None);
    __pyx_t_5 = (__pyx_t_7 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_6 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->__pyx_base.index) != Py_None);
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_7 = (((PyObject *)__pyx_v_self->reconstruct_indices) != Py_None);
    __pyx_t_5 = (__pyx_t_7 != 0);
    __pyx_t_6 = __pyx_t_5;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_6;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.As is not None or self.Q is not None or self.Q_square_root is not None or self.Q_svd_dict is not None or self.Qs is not None or self.dAs is not None or self.dQ is not None or self.dQs is not None or self.index is not None or self.reconstruct_indices is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_AQcompute_batch_Cython, (type(self), 0x146e1f7, None), state
 *     else:
 */
  __pyx_t_6 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":13
 *         use_setstate = self.As is not None or self.Q is not None or self.Q_square_root is not None or self.Q_svd_dict is not None or self.Qs is not None or self.dAs is not None or self.dQ is not None or self.dQs is not None or self.index is not None or self.reconstruct_indices is not None
 *     if use_setstate:
 *         return __pyx_unpickle_AQcompute_batch_Cython, (type(self), 0x146e1f7, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_AQcompute_batch_Cython, (type(self), 0x146e1f7, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pyx_unpickle_AQcompute_batch_C); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_21422583);
    __Pyx_GIVEREF(__pyx_int_21422583);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_21422583);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.As is not None or self.Q is not None or self.Q_square_root is not None or self.Q_svd_dict is not None or self.Qs is not None or self.dAs is not None or self.dQ is not None or self.dQs is not None or self.index is not None or self.reconstruct_indices is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_AQcompute_batch_Cython, (type(self), 0x146e1f7, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_AQcompute_batch_Cython, (type(self), 0x146e1f7, None), state
 *     else:
 *         return __pyx_unpickle_AQcompute_batch_Cython, (type(self), 0x146e1f7, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_AQcompute_batch_Cython__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle_AQcompute_batch_C); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_21422583);
    __Pyx_GIVEREF(__pyx_int_21422583);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_21422583);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_state);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* 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("GPy.models.state_space_cython.AQcompute_batch_Cython.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_AQcompute_batch_Cython, (type(self), 0x146e1f7, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_AQcompute_batch_Cython__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_21__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_21__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_20__setstate_cython__(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_20__setstate_cython__(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  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("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_AQcompute_batch_Cython, (type(self), 0x146e1f7, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_AQcompute_batch_Cython__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_AQcompute_batch_Cython__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_AQcompute_batch_Cython, (type(self), 0x146e1f7, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_AQcompute_batch_Cython__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":547
 * 
 * @cython.boundscheck(False)
 * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P,             # <<<<<<<<<<<<<<
 *                                 Dynamic_Callables_Cython p_dynamic_callables,
 *                                 bint calc_grad_log_likelihood=False,
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_1_kalman_prediction_step_SVD_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython__kalman_prediction_step_SVD_Cython[] = "\n    Desctrete prediction function        \n    \n    Input:\n        k:int\n            Iteration No. Starts at 0. Total number of iterations equal to the \n            number of measurements.\n          \n        p_m: matrix of size (state_dim, time_series_no)\n            Mean value from the previous step. For \"multiple time series mode\" \n            it is matrix, second dimension of which correspond to different\n            time series.\n            \n        p_P: tuple (Prev_cov, S, V)\n            Covariance matrix from the previous step and its SVD decomposition.\n            Prev_cov = V * S * V.T The tuple is (Prev_cov, S, V)                \n            \n        p_a: function (k, x_{k-1}, A_{k}). Dynamic function.        \n            k (iteration number), starts at 0\n            x_{k-1} State from the previous step\n            A_{k} Jacobian matrices of f_a. In the linear case it is exactly A_{k}.\n        \n        p_f_A: function (k, m, P) return Jacobian of dynamic function, it is\n            passed into p_a.\n            k (iteration number), starts at 0\n            m: point where Jacobian is evaluated\n            P: parameter for Jacobian, usually covariance matrix.\n    \n        p_f_Q: function (k). Returns noise matrix of dynamic model on iteration k.\n            k (iteration number). starts at 0\n        \n        p_f_Qsr: function (k). Returns square root of noise matrix of the \n            dynamic model on iteration k. k (iteration number). starts at 0\n            \n        calc_grad_log_likelihood: boolean\n            Whether to calculate gradient of the marginal likelihood \n            of the state-space model. If true then the next parameter must \n            provide the extra parameters for gradient calculation.\n            \n        p_dm: 3D array (state_dim, time_series_no, parameters_no)\n            Mean derivatives from the previous step. For \"multiple time series mode\" \n            it is 3D array, second dimension"" of which correspond to different\n            time series.\n            \n        p_dP: 3D array (state_dim, state_dim, parameters_no)\n            Mean derivatives from the previous step\n            \n        grad_calc_params_1: List or None\n        List with derivatives. The first component is 'f_dA' - function(k)\n        which returns the derivative of A. The second element is 'f_dQ'\n         - function(k). Function which returns the derivative of Q.\n         \n    Output:\n    ----------------------------\n    m_pred, P_pred, dm_pred, dP_pred: metrices, 3D objects\n        Results of the prediction steps.        \n        \n    ";
static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_1_kalman_prediction_step_SVD_Cython = {"_kalman_prediction_step_SVD_Cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_1_kalman_prediction_step_SVD_Cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython__kalman_prediction_step_SVD_Cython};
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_1_kalman_prediction_step_SVD_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  long __pyx_v_k;
  PyArrayObject *__pyx_v_p_m = 0;
  PyObject *__pyx_v_p_P = 0;
  struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables = 0;
  int __pyx_v_calc_grad_log_likelihood;
  PyArrayObject *__pyx_v_p_dm = 0;
  PyArrayObject *__pyx_v_p_dP = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_kalman_prediction_step_SVD_Cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_p_m,&__pyx_n_s_p_P,&__pyx_n_s_p_dynamic_callables,&__pyx_n_s_calc_grad_log_likelihood,&__pyx_n_s_p_dm,&__pyx_n_s_p_dP,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};

    /* "GPy/models/state_space_cython.pyx":550
 *                                 Dynamic_Callables_Cython p_dynamic_callables,
 *                                 bint calc_grad_log_likelihood=False,
 *                                 np.ndarray[DTYPE_t, ndim=3] p_dm = None,             # <<<<<<<<<<<<<<
 *                                 np.ndarray[DTYPE_t, ndim=3] p_dP = None):
 *     """
 */
    values[5] = (PyObject *)((PyArrayObject *)Py_None);

    /* "GPy/models/state_space_cython.pyx":551
 *                                 bint calc_grad_log_likelihood=False,
 *                                 np.ndarray[DTYPE_t, ndim=3] p_dm = None,
 *                                 np.ndarray[DTYPE_t, ndim=3] p_dP = None):             # <<<<<<<<<<<<<<
 *     """
 *     Desctrete prediction function
 */
    values[6] = (PyObject *)((PyArrayObject *)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  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_m)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_kalman_prediction_step_SVD_Cython", 0, 4, 7, 1); __PYX_ERR(0, 547, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_P)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_kalman_prediction_step_SVD_Cython", 0, 4, 7, 2); __PYX_ERR(0, 547, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_dynamic_callables)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_kalman_prediction_step_SVD_Cython", 0, 4, 7, 3); __PYX_ERR(0, 547, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_calc_grad_log_likelihood);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_dm);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_dP);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_kalman_prediction_step_SVD_Cython") < 0)) __PYX_ERR(0, 547, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 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_k = __Pyx_PyInt_As_long(values[0]); if (unlikely((__pyx_v_k == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 547, __pyx_L3_error)
    __pyx_v_p_m = ((PyArrayObject *)values[1]);
    __pyx_v_p_P = ((PyObject*)values[2]);
    __pyx_v_p_dynamic_callables = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)values[3]);
    if (values[4]) {
      __pyx_v_calc_grad_log_likelihood = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_calc_grad_log_likelihood == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 549, __pyx_L3_error)
    } else {

      /* "GPy/models/state_space_cython.pyx":549
 * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P,
 *                                 Dynamic_Callables_Cython p_dynamic_callables,
 *                                 bint calc_grad_log_likelihood=False,             # <<<<<<<<<<<<<<
 *                                 np.ndarray[DTYPE_t, ndim=3] p_dm = None,
 *                                 np.ndarray[DTYPE_t, ndim=3] p_dP = None):
 */
      __pyx_v_calc_grad_log_likelihood = ((int)0);
    }
    __pyx_v_p_dm = ((PyArrayObject *)values[5]);
    __pyx_v_p_dP = ((PyArrayObject *)values[6]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_kalman_prediction_step_SVD_Cython", 0, 4, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 547, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython._kalman_prediction_step_SVD_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_m), __pyx_ptype_5numpy_ndarray, 1, "p_m", 0))) __PYX_ERR(0, 547, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_P), (&PyTuple_Type), 1, "p_P", 1))) __PYX_ERR(0, 547, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dynamic_callables), __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython, 1, "p_dynamic_callables", 0))) __PYX_ERR(0, 548, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dm), __pyx_ptype_5numpy_ndarray, 1, "p_dm", 0))) __PYX_ERR(0, 550, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dP), __pyx_ptype_5numpy_ndarray, 1, "p_dP", 0))) __PYX_ERR(0, 551, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython__kalman_prediction_step_SVD_Cython(__pyx_self, __pyx_v_k, __pyx_v_p_m, __pyx_v_p_P, __pyx_v_p_dynamic_callables, __pyx_v_calc_grad_log_likelihood, __pyx_v_p_dm, __pyx_v_p_dP);

  /* "GPy/models/state_space_cython.pyx":547
 * 
 * @cython.boundscheck(False)
 * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P,             # <<<<<<<<<<<<<<
 *                                 Dynamic_Callables_Cython p_dynamic_callables,
 *                                 bint calc_grad_log_likelihood=False,
 */

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython__kalman_prediction_step_SVD_Cython(CYTHON_UNUSED PyObject *__pyx_self, long __pyx_v_k, PyArrayObject *__pyx_v_p_m, PyObject *__pyx_v_p_P, struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables, int __pyx_v_calc_grad_log_likelihood, PyArrayObject *__pyx_v_p_dm, PyArrayObject *__pyx_v_p_dP) {
  PyArrayObject *__pyx_v_Prev_cov = 0;
  PyArrayObject *__pyx_v_S_old = 0;
  PyArrayObject *__pyx_v_V_old = 0;
  PyArrayObject *__pyx_v_A = 0;
  CYTHON_UNUSED PyArrayObject *__pyx_v_Q = 0;
  PyArrayObject *__pyx_v_Q_sr = 0;
  PyArrayObject *__pyx_v_m_pred = 0;
  PyArrayObject *__pyx_v_svd_1_matr = 0;
  PyObject *__pyx_v_res = NULL;
  CYTHON_UNUSED PyArrayObject *__pyx_v_U = 0;
  PyArrayObject *__pyx_v_S = 0;
  PyArrayObject *__pyx_v_Vh = 0;
  PyArrayObject *__pyx_v_V_new = 0;
  PyArrayObject *__pyx_v_S_new = 0;
  PyArrayObject *__pyx_v_P_pred = 0;
  PyArrayObject *__pyx_v_dA_all_params = 0;
  PyArrayObject *__pyx_v_dQ_all_params = 0;
  PyArrayObject *__pyx_v_dm_pred = 0;
  PyArrayObject *__pyx_v_dP_pred = 0;
  int __pyx_v_param_number;
  int __pyx_v_j;
  PyObject *__pyx_v_ret = 0;
  PyArrayObject *__pyx_v_dA = 0;
  PyArrayObject *__pyx_v_dQ = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_A;
  __Pyx_Buffer __pyx_pybuffer_A;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred;
  __Pyx_Buffer __pyx_pybuffer_P_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Prev_cov;
  __Pyx_Buffer __pyx_pybuffer_Prev_cov;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Q;
  __Pyx_Buffer __pyx_pybuffer_Q;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Q_sr;
  __Pyx_Buffer __pyx_pybuffer_Q_sr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S;
  __Pyx_Buffer __pyx_pybuffer_S;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S_new;
  __Pyx_Buffer __pyx_pybuffer_S_new;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S_old;
  __Pyx_Buffer __pyx_pybuffer_S_old;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_U;
  __Pyx_Buffer __pyx_pybuffer_U;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_V_new;
  __Pyx_Buffer __pyx_pybuffer_V_new;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_V_old;
  __Pyx_Buffer __pyx_pybuffer_V_old;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh;
  __Pyx_Buffer __pyx_pybuffer_Vh;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dA;
  __Pyx_Buffer __pyx_pybuffer_dA;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dA_all_params;
  __Pyx_Buffer __pyx_pybuffer_dA_all_params;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_pred;
  __Pyx_Buffer __pyx_pybuffer_dP_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dQ;
  __Pyx_Buffer __pyx_pybuffer_dQ;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dQ_all_params;
  __Pyx_Buffer __pyx_pybuffer_dQ_all_params;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_pred;
  __Pyx_Buffer __pyx_pybuffer_dm_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred;
  __Pyx_Buffer __pyx_pybuffer_m_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_p_dP;
  __Pyx_Buffer __pyx_pybuffer_p_dP;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_p_dm;
  __Pyx_Buffer __pyx_pybuffer_p_dm;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_p_m;
  __Pyx_Buffer __pyx_pybuffer_p_m;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_svd_1_matr;
  __Pyx_Buffer __pyx_pybuffer_svd_1_matr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyArrayObject *__pyx_t_2 = NULL;
  PyArrayObject *__pyx_t_3 = NULL;
  PyArrayObject *__pyx_t_4 = NULL;
  PyArrayObject *__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 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyArrayObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  PyArrayObject *__pyx_t_15 = NULL;
  PyArrayObject *__pyx_t_16 = NULL;
  PyArrayObject *__pyx_t_17 = NULL;
  PyArrayObject *__pyx_t_18 = NULL;
  PyArrayObject *__pyx_t_19 = NULL;
  int __pyx_t_20;
  PyArrayObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyArrayObject *__pyx_t_25 = NULL;
  PyArrayObject *__pyx_t_26 = NULL;
  PyArrayObject *__pyx_t_27 = NULL;
  int __pyx_t_28;
  int __pyx_t_29;
  PyArrayObject *__pyx_t_30 = NULL;
  int __pyx_t_31;
  PyArrayObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  PyObject *__pyx_t_34 = NULL;
  PyObject *__pyx_t_35 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_kalman_prediction_step_SVD_Cython", 0);
  __pyx_pybuffer_Prev_cov.pybuffer.buf = NULL;
  __pyx_pybuffer_Prev_cov.refcount = 0;
  __pyx_pybuffernd_Prev_cov.data = NULL;
  __pyx_pybuffernd_Prev_cov.rcbuffer = &__pyx_pybuffer_Prev_cov;
  __pyx_pybuffer_S_old.pybuffer.buf = NULL;
  __pyx_pybuffer_S_old.refcount = 0;
  __pyx_pybuffernd_S_old.data = NULL;
  __pyx_pybuffernd_S_old.rcbuffer = &__pyx_pybuffer_S_old;
  __pyx_pybuffer_V_old.pybuffer.buf = NULL;
  __pyx_pybuffer_V_old.refcount = 0;
  __pyx_pybuffernd_V_old.data = NULL;
  __pyx_pybuffernd_V_old.rcbuffer = &__pyx_pybuffer_V_old;
  __pyx_pybuffer_A.pybuffer.buf = NULL;
  __pyx_pybuffer_A.refcount = 0;
  __pyx_pybuffernd_A.data = NULL;
  __pyx_pybuffernd_A.rcbuffer = &__pyx_pybuffer_A;
  __pyx_pybuffer_Q.pybuffer.buf = NULL;
  __pyx_pybuffer_Q.refcount = 0;
  __pyx_pybuffernd_Q.data = NULL;
  __pyx_pybuffernd_Q.rcbuffer = &__pyx_pybuffer_Q;
  __pyx_pybuffer_Q_sr.pybuffer.buf = NULL;
  __pyx_pybuffer_Q_sr.refcount = 0;
  __pyx_pybuffernd_Q_sr.data = NULL;
  __pyx_pybuffernd_Q_sr.rcbuffer = &__pyx_pybuffer_Q_sr;
  __pyx_pybuffer_m_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_m_pred.refcount = 0;
  __pyx_pybuffernd_m_pred.data = NULL;
  __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred;
  __pyx_pybuffer_svd_1_matr.pybuffer.buf = NULL;
  __pyx_pybuffer_svd_1_matr.refcount = 0;
  __pyx_pybuffernd_svd_1_matr.data = NULL;
  __pyx_pybuffernd_svd_1_matr.rcbuffer = &__pyx_pybuffer_svd_1_matr;
  __pyx_pybuffer_U.pybuffer.buf = NULL;
  __pyx_pybuffer_U.refcount = 0;
  __pyx_pybuffernd_U.data = NULL;
  __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U;
  __pyx_pybuffer_S.pybuffer.buf = NULL;
  __pyx_pybuffer_S.refcount = 0;
  __pyx_pybuffernd_S.data = NULL;
  __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S;
  __pyx_pybuffer_Vh.pybuffer.buf = NULL;
  __pyx_pybuffer_Vh.refcount = 0;
  __pyx_pybuffernd_Vh.data = NULL;
  __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh;
  __pyx_pybuffer_V_new.pybuffer.buf = NULL;
  __pyx_pybuffer_V_new.refcount = 0;
  __pyx_pybuffernd_V_new.data = NULL;
  __pyx_pybuffernd_V_new.rcbuffer = &__pyx_pybuffer_V_new;
  __pyx_pybuffer_S_new.pybuffer.buf = NULL;
  __pyx_pybuffer_S_new.refcount = 0;
  __pyx_pybuffernd_S_new.data = NULL;
  __pyx_pybuffernd_S_new.rcbuffer = &__pyx_pybuffer_S_new;
  __pyx_pybuffer_P_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_P_pred.refcount = 0;
  __pyx_pybuffernd_P_pred.data = NULL;
  __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred;
  __pyx_pybuffer_dA_all_params.pybuffer.buf = NULL;
  __pyx_pybuffer_dA_all_params.refcount = 0;
  __pyx_pybuffernd_dA_all_params.data = NULL;
  __pyx_pybuffernd_dA_all_params.rcbuffer = &__pyx_pybuffer_dA_all_params;
  __pyx_pybuffer_dQ_all_params.pybuffer.buf = NULL;
  __pyx_pybuffer_dQ_all_params.refcount = 0;
  __pyx_pybuffernd_dQ_all_params.data = NULL;
  __pyx_pybuffernd_dQ_all_params.rcbuffer = &__pyx_pybuffer_dQ_all_params;
  __pyx_pybuffer_dm_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_dm_pred.refcount = 0;
  __pyx_pybuffernd_dm_pred.data = NULL;
  __pyx_pybuffernd_dm_pred.rcbuffer = &__pyx_pybuffer_dm_pred;
  __pyx_pybuffer_dP_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_dP_pred.refcount = 0;
  __pyx_pybuffernd_dP_pred.data = NULL;
  __pyx_pybuffernd_dP_pred.rcbuffer = &__pyx_pybuffer_dP_pred;
  __pyx_pybuffer_dA.pybuffer.buf = NULL;
  __pyx_pybuffer_dA.refcount = 0;
  __pyx_pybuffernd_dA.data = NULL;
  __pyx_pybuffernd_dA.rcbuffer = &__pyx_pybuffer_dA;
  __pyx_pybuffer_dQ.pybuffer.buf = NULL;
  __pyx_pybuffer_dQ.refcount = 0;
  __pyx_pybuffernd_dQ.data = NULL;
  __pyx_pybuffernd_dQ.rcbuffer = &__pyx_pybuffer_dQ;
  __pyx_pybuffer_p_m.pybuffer.buf = NULL;
  __pyx_pybuffer_p_m.refcount = 0;
  __pyx_pybuffernd_p_m.data = NULL;
  __pyx_pybuffernd_p_m.rcbuffer = &__pyx_pybuffer_p_m;
  __pyx_pybuffer_p_dm.pybuffer.buf = NULL;
  __pyx_pybuffer_p_dm.refcount = 0;
  __pyx_pybuffernd_p_dm.data = NULL;
  __pyx_pybuffernd_p_dm.rcbuffer = &__pyx_pybuffer_p_dm;
  __pyx_pybuffer_p_dP.pybuffer.buf = NULL;
  __pyx_pybuffer_p_dP.refcount = 0;
  __pyx_pybuffernd_p_dP.data = NULL;
  __pyx_pybuffernd_p_dP.rcbuffer = &__pyx_pybuffer_p_dP;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 547, __pyx_L1_error)
  }
  __pyx_pybuffernd_p_m.diminfo[0].strides = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_m.diminfo[0].shape = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_m.diminfo[1].strides = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_m.diminfo[1].shape = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_dm, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 547, __pyx_L1_error)
  }
  __pyx_pybuffernd_p_dm.diminfo[0].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_dm.diminfo[0].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_dm.diminfo[1].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_dm.diminfo[1].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_p_dm.diminfo[2].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_p_dm.diminfo[2].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_dP, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 547, __pyx_L1_error)
  }
  __pyx_pybuffernd_p_dP.diminfo[0].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_dP.diminfo[0].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_dP.diminfo[1].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_dP.diminfo[1].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_p_dP.diminfo[2].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_p_dP.diminfo[2].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[2];

  /* "GPy/models/state_space_cython.pyx":612
 * 
 *     # covariance from the previous step# p_prev_cov = v * S * V.T
 *     cdef np.ndarray[DTYPE_t, ndim=2] Prev_cov = p_P[0]             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_old = p_P[1]
 *     cdef np.ndarray[DTYPE_t, ndim=2] V_old = p_P[2]
 */
  if (unlikely(__pyx_v_p_P == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 612, __pyx_L1_error)
  }
  if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 0)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 0), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 612, __pyx_L1_error)
  __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 0);
  __Pyx_INCREF(__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_Prev_cov = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 612, __pyx_L1_error)
    } else {__pyx_pybuffernd_Prev_cov.diminfo[0].strides = __pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Prev_cov.diminfo[0].shape = __pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Prev_cov.diminfo[1].strides = __pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Prev_cov.diminfo[1].shape = __pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_v_Prev_cov = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":613
 *     # covariance from the previous step# p_prev_cov = v * S * V.T
 *     cdef np.ndarray[DTYPE_t, ndim=2] Prev_cov = p_P[0]
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_old = p_P[1]             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=2] V_old = p_P[2]
 *     #p_prev_cov_tst = np.dot(p_V, (p_S * p_V).T) # reconstructed covariance from the previous step
 */
  if (unlikely(__pyx_v_p_P == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 613, __pyx_L1_error)
  }
  if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 1)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 1), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 613, __pyx_L1_error)
  __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 1);
  __Pyx_INCREF(__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S_old.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_S_old = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S_old.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 613, __pyx_L1_error)
    } else {__pyx_pybuffernd_S_old.diminfo[0].strides = __pyx_pybuffernd_S_old.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S_old.diminfo[0].shape = __pyx_pybuffernd_S_old.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_v_S_old = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":614
 *     cdef np.ndarray[DTYPE_t, ndim=2] Prev_cov = p_P[0]
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_old = p_P[1]
 *     cdef np.ndarray[DTYPE_t, ndim=2] V_old = p_P[2]             # <<<<<<<<<<<<<<
 *     #p_prev_cov_tst = np.dot(p_V, (p_S * p_V).T) # reconstructed covariance from the previous step
 * 
 */
  if (unlikely(__pyx_v_p_P == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 614, __pyx_L1_error)
  }
  if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 2)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 2), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 614, __pyx_L1_error)
  __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 2);
  __Pyx_INCREF(__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_V_old.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_V_old = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_V_old.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 614, __pyx_L1_error)
    } else {__pyx_pybuffernd_V_old.diminfo[0].strides = __pyx_pybuffernd_V_old.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_V_old.diminfo[0].shape = __pyx_pybuffernd_V_old.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_V_old.diminfo[1].strides = __pyx_pybuffernd_V_old.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_V_old.diminfo[1].shape = __pyx_pybuffernd_V_old.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_v_V_old = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":618
 * 
 *     # index correspond to values from previous iteration.
 *     cdef np.ndarray[DTYPE_t, ndim=2] A = p_dynamic_callables.Ak(k,p_m,Prev_cov) # state transition matrix (or Jacobian)             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=2] Q = p_dynamic_callables.Qk(k) # state noise matrx. This is necessary for the square root calculation (next step)
 *     cdef np.ndarray[DTYPE_t, ndim=2] Q_sr = p_dynamic_callables.Q_srk(k)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->Ak(__pyx_v_p_dynamic_callables, __pyx_v_k, ((PyArrayObject *)__pyx_v_p_m), ((PyArrayObject *)__pyx_v_Prev_cov), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 618, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 618, __pyx_L1_error)
  __pyx_t_2 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_t_2, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_A = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_A.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 618, __pyx_L1_error)
    } else {__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]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_2 = 0;
  __pyx_v_A = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":619
 *     # index correspond to values from previous iteration.
 *     cdef np.ndarray[DTYPE_t, ndim=2] A = p_dynamic_callables.Ak(k,p_m,Prev_cov) # state transition matrix (or Jacobian)
 *     cdef np.ndarray[DTYPE_t, ndim=2] Q = p_dynamic_callables.Qk(k) # state noise matrx. This is necessary for the square root calculation (next step)             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=2] Q_sr = p_dynamic_callables.Q_srk(k)
 *     # Prediction step ->
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->Qk(__pyx_v_p_dynamic_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 619, __pyx_L1_error)
  __pyx_t_3 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Q.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_Q = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Q.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 619, __pyx_L1_error)
    } else {__pyx_pybuffernd_Q.diminfo[0].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Q.diminfo[0].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Q.diminfo[1].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Q.diminfo[1].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_3 = 0;
  __pyx_v_Q = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":620
 *     cdef np.ndarray[DTYPE_t, ndim=2] A = p_dynamic_callables.Ak(k,p_m,Prev_cov) # state transition matrix (or Jacobian)
 *     cdef np.ndarray[DTYPE_t, ndim=2] Q = p_dynamic_callables.Qk(k) # state noise matrx. This is necessary for the square root calculation (next step)
 *     cdef np.ndarray[DTYPE_t, ndim=2] Q_sr = p_dynamic_callables.Q_srk(k)             # <<<<<<<<<<<<<<
 *     # Prediction step ->
 *     cdef np.ndarray[DTYPE_t, ndim=2] m_pred = p_dynamic_callables.f_a(k, p_m, A) # predicted mean
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->Q_srk(__pyx_v_p_dynamic_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 620, __pyx_L1_error)
  __pyx_t_4 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Q_sr.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_Q_sr = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Q_sr.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 620, __pyx_L1_error)
    } else {__pyx_pybuffernd_Q_sr.diminfo[0].strides = __pyx_pybuffernd_Q_sr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Q_sr.diminfo[0].shape = __pyx_pybuffernd_Q_sr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Q_sr.diminfo[1].strides = __pyx_pybuffernd_Q_sr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Q_sr.diminfo[1].shape = __pyx_pybuffernd_Q_sr.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_4 = 0;
  __pyx_v_Q_sr = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":622
 *     cdef np.ndarray[DTYPE_t, ndim=2] Q_sr = p_dynamic_callables.Q_srk(k)
 *     # Prediction step ->
 *     cdef np.ndarray[DTYPE_t, ndim=2] m_pred = p_dynamic_callables.f_a(k, p_m, A) # predicted mean             # <<<<<<<<<<<<<<
 * 
 *     # coavariance prediction have changed:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->f_a(__pyx_v_p_dynamic_callables, __pyx_v_k, ((PyArrayObject *)__pyx_v_p_m), ((PyArrayObject *)__pyx_v_A), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 622, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 622, __pyx_L1_error)
  __pyx_t_5 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_m_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 622, __pyx_L1_error)
    } else {__pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_5 = 0;
  __pyx_v_m_pred = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":625
 * 
 *     # coavariance prediction have changed:
 *     cdef np.ndarray[DTYPE_t, ndim=2] svd_1_matr = np.vstack( ( (np.sqrt(S_old)* np.dot(A,V_old)).T , Q_sr.T) )             # <<<<<<<<<<<<<<
 *     res = sp.linalg.svd( svd_1_matr,full_matrices=False, compute_uv=True,
 *                   overwrite_a=False,check_finite=True)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_vstack); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  __pyx_t_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_8, ((PyObject *)__pyx_v_S_old)) : __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)__pyx_v_S_old));
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dot); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_A), ((PyObject *)__pyx_v_V_old)};
    __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 625, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_A), ((PyObject *)__pyx_v_V_old)};
    __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 625, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 625, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_A));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_A));
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, ((PyObject *)__pyx_v_A));
    __Pyx_INCREF(((PyObject *)__pyx_v_V_old));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_V_old));
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, ((PyObject *)__pyx_v_V_old));
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 625, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = PyNumber_Multiply(__pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_T); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Q_sr), __pyx_n_s_T); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_10);
  __pyx_t_9 = 0;
  __pyx_t_10 = 0;
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_10, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 625, __pyx_L1_error)
  __pyx_t_13 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_svd_1_matr = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 625, __pyx_L1_error)
    } else {__pyx_pybuffernd_svd_1_matr.diminfo[0].strides = __pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_svd_1_matr.diminfo[0].shape = __pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_svd_1_matr.diminfo[1].strides = __pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_svd_1_matr.diminfo[1].shape = __pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_13 = 0;
  __pyx_v_svd_1_matr = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":626
 *     # coavariance prediction have changed:
 *     cdef np.ndarray[DTYPE_t, ndim=2] svd_1_matr = np.vstack( ( (np.sqrt(S_old)* np.dot(A,V_old)).T , Q_sr.T) )
 *     res = sp.linalg.svd( svd_1_matr,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                   overwrite_a=False,check_finite=True)
 *     # (U,S,Vh)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_sp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_linalg); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_svd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_svd_1_matr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_svd_1_matr));
  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_svd_1_matr));
  __pyx_t_6 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_full_matrices, Py_False) < 0) __PYX_ERR(0, 626, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_compute_uv, Py_True) < 0) __PYX_ERR(0, 626, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":627
 *     cdef np.ndarray[DTYPE_t, ndim=2] svd_1_matr = np.vstack( ( (np.sqrt(S_old)* np.dot(A,V_old)).T , Q_sr.T) )
 *     res = sp.linalg.svd( svd_1_matr,full_matrices=False, compute_uv=True,
 *                   overwrite_a=False,check_finite=True)             # <<<<<<<<<<<<<<
 *     # (U,S,Vh)
 *     cdef np.ndarray[DTYPE_t, ndim=2] U = res[0]
 */
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_overwrite_a, Py_False) < 0) __PYX_ERR(0, 626, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_check_finite, Py_True) < 0) __PYX_ERR(0, 626, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":626
 *     # coavariance prediction have changed:
 *     cdef np.ndarray[DTYPE_t, ndim=2] svd_1_matr = np.vstack( ( (np.sqrt(S_old)* np.dot(A,V_old)).T , Q_sr.T) )
 *     res = sp.linalg.svd( svd_1_matr,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                   overwrite_a=False,check_finite=True)
 *     # (U,S,Vh)
 */
  __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_res = __pyx_t_10;
  __pyx_t_10 = 0;

  /* "GPy/models/state_space_cython.pyx":629
 *                   overwrite_a=False,check_finite=True)
 *     # (U,S,Vh)
 *     cdef np.ndarray[DTYPE_t, ndim=2] U = res[0]             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=1] S = res[1]
 *     cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2]
 */
  __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_res, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 629, __pyx_L1_error)
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_10);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_U = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_U.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 629, __pyx_L1_error)
    } else {__pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_14 = 0;
  __pyx_v_U = ((PyArrayObject *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "GPy/models/state_space_cython.pyx":630
 *     # (U,S,Vh)
 *     cdef np.ndarray[DTYPE_t, ndim=2] U = res[0]
 *     cdef np.ndarray[DTYPE_t, ndim=1] S = res[1]             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2]
 *     # predicted variance computed by the regular method. For testing
 */
  __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_res, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 630, __pyx_L1_error)
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_10);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_S = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 630, __pyx_L1_error)
    } else {__pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_15 = 0;
  __pyx_v_S = ((PyArrayObject *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "GPy/models/state_space_cython.pyx":631
 *     cdef np.ndarray[DTYPE_t, ndim=2] U = res[0]
 *     cdef np.ndarray[DTYPE_t, ndim=1] S = res[1]
 *     cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2]             # <<<<<<<<<<<<<<
 *     # predicted variance computed by the regular method. For testing
 *     #P_pred_tst = A.dot(Prev_cov).dot(A.T) + Q
 */
  __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_res, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 631, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 631, __pyx_L1_error)
  __pyx_t_16 = ((PyArrayObject *)__pyx_t_10);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_Vh = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Vh.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 631, __pyx_L1_error)
    } else {__pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_16 = 0;
  __pyx_v_Vh = ((PyArrayObject *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "GPy/models/state_space_cython.pyx":634
 *     # predicted variance computed by the regular method. For testing
 *     #P_pred_tst = A.dot(Prev_cov).dot(A.T) + Q
 *     cdef np.ndarray[DTYPE_t, ndim=2]  V_new = Vh.T             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=1]  S_new = S**2
 * 
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Vh), __pyx_n_s_T); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 634, __pyx_L1_error)
  __pyx_t_17 = ((PyArrayObject *)__pyx_t_10);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_V_new.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_V_new = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_V_new.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 634, __pyx_L1_error)
    } else {__pyx_pybuffernd_V_new.diminfo[0].strides = __pyx_pybuffernd_V_new.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_V_new.diminfo[0].shape = __pyx_pybuffernd_V_new.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_V_new.diminfo[1].strides = __pyx_pybuffernd_V_new.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_V_new.diminfo[1].shape = __pyx_pybuffernd_V_new.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_17 = 0;
  __pyx_v_V_new = ((PyArrayObject *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "GPy/models/state_space_cython.pyx":635
 *     #P_pred_tst = A.dot(Prev_cov).dot(A.T) + Q
 *     cdef np.ndarray[DTYPE_t, ndim=2]  V_new = Vh.T
 *     cdef np.ndarray[DTYPE_t, ndim=1]  S_new = S**2             # <<<<<<<<<<<<<<
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] P_pred = np.dot(V_new * S_new, V_new.T) # prediction covariance
 */
  __pyx_t_10 = PyNumber_Power(((PyObject *)__pyx_v_S), __pyx_int_2, Py_None); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 635, __pyx_L1_error)
  __pyx_t_18 = ((PyArrayObject *)__pyx_t_10);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S_new.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_S_new = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S_new.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 635, __pyx_L1_error)
    } else {__pyx_pybuffernd_S_new.diminfo[0].strides = __pyx_pybuffernd_S_new.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S_new.diminfo[0].shape = __pyx_pybuffernd_S_new.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_18 = 0;
  __pyx_v_S_new = ((PyArrayObject *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "GPy/models/state_space_cython.pyx":637
 *     cdef np.ndarray[DTYPE_t, ndim=1]  S_new = S**2
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] P_pred = np.dot(V_new * S_new, V_new.T) # prediction covariance             # <<<<<<<<<<<<<<
 *     #tuple P_pred = (P_pred, S_new, Vh.T)
 *     # Prediction step <-
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 637, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 637, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Multiply(((PyObject *)__pyx_v_V_new), ((PyObject *)__pyx_v_S_new)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 637, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_V_new), __pyx_n_s_T); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_6, __pyx_t_1};
    __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_6, __pyx_t_1};
    __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 637, __pyx_L1_error)
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_10);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_P_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 637, __pyx_L1_error)
    } else {__pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_19 = 0;
  __pyx_v_P_pred = ((PyArrayObject *)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "GPy/models/state_space_cython.pyx":654
 *     cdef np.ndarray[DTYPE_t, ndim=2] dA
 *     cdef np.ndarray[DTYPE_t, ndim=2] dQ
 *     if calc_grad_log_likelihood:             # <<<<<<<<<<<<<<
 *         dA_all_params = p_dynamic_callables.dAk(k) # derivatives of A wrt parameters
 *         dQ_all_params = p_dynamic_callables.dQk(k) # derivatives of Q wrt parameters
 */
  __pyx_t_20 = (__pyx_v_calc_grad_log_likelihood != 0);
  if (__pyx_t_20) {

    /* "GPy/models/state_space_cython.pyx":655
 *     cdef np.ndarray[DTYPE_t, ndim=2] dQ
 *     if calc_grad_log_likelihood:
 *         dA_all_params = p_dynamic_callables.dAk(k) # derivatives of A wrt parameters             # <<<<<<<<<<<<<<
 *         dQ_all_params = p_dynamic_callables.dQk(k) # derivatives of Q wrt parameters
 * 
 */
    __pyx_t_10 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->dAk(__pyx_v_p_dynamic_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 655, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 655, __pyx_L1_error)
    __pyx_t_21 = ((PyArrayObject *)__pyx_t_10);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_t_21, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dA_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
        }
        __pyx_t_22 = __pyx_t_23 = __pyx_t_24 = 0;
      }
      __pyx_pybuffernd_dA_all_params.diminfo[0].strides = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dA_all_params.diminfo[0].shape = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dA_all_params.diminfo[1].strides = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dA_all_params.diminfo[1].shape = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dA_all_params.diminfo[2].strides = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dA_all_params.diminfo[2].shape = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 655, __pyx_L1_error)
    }
    __pyx_t_21 = 0;
    __pyx_v_dA_all_params = ((PyArrayObject *)__pyx_t_10);
    __pyx_t_10 = 0;

    /* "GPy/models/state_space_cython.pyx":656
 *     if calc_grad_log_likelihood:
 *         dA_all_params = p_dynamic_callables.dAk(k) # derivatives of A wrt parameters
 *         dQ_all_params = p_dynamic_callables.dQk(k) # derivatives of Q wrt parameters             # <<<<<<<<<<<<<<
 * 
 *         param_number = p_dP.shape[2]
 */
    __pyx_t_10 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->dQk(__pyx_v_p_dynamic_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 656, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 656, __pyx_L1_error)
    __pyx_t_25 = ((PyArrayObject *)__pyx_t_10);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dQ_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
        }
        __pyx_t_24 = __pyx_t_23 = __pyx_t_22 = 0;
      }
      __pyx_pybuffernd_dQ_all_params.diminfo[0].strides = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dQ_all_params.diminfo[0].shape = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dQ_all_params.diminfo[1].strides = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dQ_all_params.diminfo[1].shape = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dQ_all_params.diminfo[2].strides = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dQ_all_params.diminfo[2].shape = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 656, __pyx_L1_error)
    }
    __pyx_t_25 = 0;
    __pyx_v_dQ_all_params = ((PyArrayObject *)__pyx_t_10);
    __pyx_t_10 = 0;

    /* "GPy/models/state_space_cython.pyx":658
 *         dQ_all_params = p_dynamic_callables.dQk(k) # derivatives of Q wrt parameters
 * 
 *         param_number = p_dP.shape[2]             # <<<<<<<<<<<<<<
 * 
 *         # p_dm, p_dP - derivatives form the previoius step
 */
    __pyx_v_param_number = (__pyx_v_p_dP->dimensions[2]);

    /* "GPy/models/state_space_cython.pyx":661
 * 
 *         # p_dm, p_dP - derivatives form the previoius step
 *         dm_pred = np.empty((p_dm.shape[0], p_dm.shape[1], p_dm.shape[2]), dtype = DTYPE)             # <<<<<<<<<<<<<<
 *         dP_pred = np.empty((p_dP.shape[0], p_dP.shape[1], p_dP.shape[2]), dtype = DTYPE)
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_empty); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dm->dimensions[0])); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_12 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dm->dimensions[1])); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_1 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dm->dimensions[2])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
    __pyx_t_10 = 0;
    __pyx_t_12 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_12) < 0) __PYX_ERR(0, 661, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 661, __pyx_L1_error)
    __pyx_t_26 = ((PyArrayObject *)__pyx_t_12);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_26, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
        }
        __pyx_t_22 = __pyx_t_23 = __pyx_t_24 = 0;
      }
      __pyx_pybuffernd_dm_pred.diminfo[0].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_pred.diminfo[0].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_pred.diminfo[1].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_pred.diminfo[1].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_pred.diminfo[2].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_pred.diminfo[2].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 661, __pyx_L1_error)
    }
    __pyx_t_26 = 0;
    __pyx_v_dm_pred = ((PyArrayObject *)__pyx_t_12);
    __pyx_t_12 = 0;

    /* "GPy/models/state_space_cython.pyx":662
 *         # p_dm, p_dP - derivatives form the previoius step
 *         dm_pred = np.empty((p_dm.shape[0], p_dm.shape[1], p_dm.shape[2]), dtype = DTYPE)
 *         dP_pred = np.empty((p_dP.shape[0], p_dP.shape[1], p_dP.shape[2]), dtype = DTYPE)             # <<<<<<<<<<<<<<
 * 
 *         for j in range(param_number):
 */
    __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_empty); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dP->dimensions[0])); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_1 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dP->dimensions[1])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dP->dimensions[2])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_7);
    __pyx_t_12 = 0;
    __pyx_t_1 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 662, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 662, __pyx_L1_error)
    __pyx_t_27 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_27, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
        }
        __pyx_t_24 = __pyx_t_23 = __pyx_t_22 = 0;
      }
      __pyx_pybuffernd_dP_pred.diminfo[0].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_pred.diminfo[0].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_pred.diminfo[1].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_pred.diminfo[1].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_pred.diminfo[2].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_pred.diminfo[2].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 662, __pyx_L1_error)
    }
    __pyx_t_27 = 0;
    __pyx_v_dP_pred = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "GPy/models/state_space_cython.pyx":664
 *         dP_pred = np.empty((p_dP.shape[0], p_dP.shape[1], p_dP.shape[2]), dtype = DTYPE)
 * 
 *         for j in range(param_number):             # <<<<<<<<<<<<<<
 *             dA = dA_all_params[:,:,j]
 *             dQ = dQ_all_params[:,:,j]
 */
    __pyx_t_11 = __pyx_v_param_number;
    __pyx_t_28 = __pyx_t_11;
    for (__pyx_t_29 = 0; __pyx_t_29 < __pyx_t_28; __pyx_t_29+=1) {
      __pyx_v_j = __pyx_t_29;

      /* "GPy/models/state_space_cython.pyx":665
 * 
 *         for j in range(param_number):
 *             dA = dA_all_params[:,:,j]             # <<<<<<<<<<<<<<
 *             dQ = dQ_all_params[:,:,j]
 * 
 */
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 665, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 665, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dA_all_params), __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 665, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 665, __pyx_L1_error)
      __pyx_t_30 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA.rcbuffer->pybuffer);
        __pyx_t_31 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dA.rcbuffer->pybuffer, (PyObject*)__pyx_t_30, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_31 < 0)) {
          PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dA.rcbuffer->pybuffer, (PyObject*)__pyx_v_dA, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
          }
          __pyx_t_22 = __pyx_t_23 = __pyx_t_24 = 0;
        }
        __pyx_pybuffernd_dA.diminfo[0].strides = __pyx_pybuffernd_dA.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dA.diminfo[0].shape = __pyx_pybuffernd_dA.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dA.diminfo[1].strides = __pyx_pybuffernd_dA.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dA.diminfo[1].shape = __pyx_pybuffernd_dA.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_31 < 0)) __PYX_ERR(0, 665, __pyx_L1_error)
      }
      __pyx_t_30 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dA, ((PyArrayObject *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "GPy/models/state_space_cython.pyx":666
 *         for j in range(param_number):
 *             dA = dA_all_params[:,:,j]
 *             dQ = dQ_all_params[:,:,j]             # <<<<<<<<<<<<<<
 * 
 *             dm_pred[:,:,j] = np.dot(dA, p_m) + np.dot(A, p_dm[:,:,j])
 */
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 666, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 666, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dQ_all_params), __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 666, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 666, __pyx_L1_error)
      __pyx_t_32 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer);
        __pyx_t_31 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer, (PyObject*)__pyx_t_32, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_31 < 0)) {
          PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer, (PyObject*)__pyx_v_dQ, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
          }
          __pyx_t_24 = __pyx_t_23 = __pyx_t_22 = 0;
        }
        __pyx_pybuffernd_dQ.diminfo[0].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dQ.diminfo[0].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dQ.diminfo[1].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dQ.diminfo[1].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_31 < 0)) __PYX_ERR(0, 666, __pyx_L1_error)
      }
      __pyx_t_32 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dQ, ((PyArrayObject *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "GPy/models/state_space_cython.pyx":668
 *             dQ = dQ_all_params[:,:,j]
 * 
 *             dm_pred[:,:,j] = np.dot(dA, p_m) + np.dot(A, p_dm[:,:,j])             # <<<<<<<<<<<<<<
 *             # prediction step derivatives for current parameter:
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 668, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 668, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      __pyx_t_31 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_31 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_dA), ((PyObject *)__pyx_v_p_m)};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 668, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_dA), ((PyObject *)__pyx_v_p_m)};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 668, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(2+__pyx_t_31); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 668, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dA));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dA));
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_31, ((PyObject *)__pyx_v_dA));
        __Pyx_INCREF(((PyObject *)__pyx_v_p_m));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_p_m));
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_31, ((PyObject *)__pyx_v_p_m));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 668, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 668, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dot); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 668, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 668, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 668, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_p_dm), __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 668, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      __pyx_t_31 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
          __pyx_t_31 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_A), __pyx_t_6};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 668, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_A), __pyx_t_6};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 668, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(2+__pyx_t_31); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 668, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (__pyx_t_12) {
          __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12); __pyx_t_12 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_A));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_A));
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_31, ((PyObject *)__pyx_v_A));
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_31, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 668, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyNumber_Add(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 668, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 668, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 668, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_7);
      __pyx_t_7 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dm_pred), __pyx_t_1, __pyx_t_10) < 0)) __PYX_ERR(0, 668, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "GPy/models/state_space_cython.pyx":671
 *             # prediction step derivatives for current parameter:
 * 
 *             dP_pred[:,:,j] = np.dot( dA ,np.dot(Prev_cov, A.T))             # <<<<<<<<<<<<<<
 *             dP_pred[:,:,j] += dP_pred[:,:,j].T
 *             dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_A), __pyx_n_s_T); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_12 = NULL;
      __pyx_t_31 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_31 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_Prev_cov), __pyx_t_9};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 671, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_Prev_cov), __pyx_t_9};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 671, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(2+__pyx_t_31); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 671, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        if (__pyx_t_12) {
          __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_12); __pyx_t_12 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_Prev_cov));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_Prev_cov));
        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_31, ((PyObject *)__pyx_v_Prev_cov));
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_31, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 671, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      __pyx_t_31 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_31 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_dA), __pyx_t_1};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 671, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_dA), __pyx_t_1};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 671, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(2+__pyx_t_31); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 671, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        if (__pyx_t_6) {
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dA));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dA));
        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_31, ((PyObject *)__pyx_v_dA));
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_31, __pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 671, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
      __pyx_t_7 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_8, __pyx_t_10) < 0)) __PYX_ERR(0, 671, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "GPy/models/state_space_cython.pyx":672
 * 
 *             dP_pred[:,:,j] = np.dot( dA ,np.dot(Prev_cov, A.T))
 *             dP_pred[:,:,j] += dP_pred[:,:,j].T             # <<<<<<<<<<<<<<
 *             dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ
 * 
 */
      __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_T); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_10, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_8, __pyx_t_7) < 0)) __PYX_ERR(0, 672, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "GPy/models/state_space_cython.pyx":673
 *             dP_pred[:,:,j] = np.dot( dA ,np.dot(Prev_cov, A.T))
 *             dP_pred[:,:,j] += dP_pred[:,:,j].T
 *             dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ             # <<<<<<<<<<<<<<
 * 
 *             dP_pred[:,:,j] = 0.5*(dP_pred[:,:,j] + dP_pred[:,:,j].T) #symmetrize
 */
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dot); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_33 = PyTuple_New(3); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_33, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_33, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_33, 2, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_p_dP), __pyx_t_33); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      __pyx_t_33 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_A), __pyx_n_s_T); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __pyx_t_34 = NULL;
      __pyx_t_31 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_34)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_34);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
          __pyx_t_31 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[3] = {__pyx_t_34, __pyx_t_9, __pyx_t_33};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 673, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[3] = {__pyx_t_34, __pyx_t_9, __pyx_t_33};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 673, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      } else
      #endif
      {
        __pyx_t_35 = PyTuple_New(2+__pyx_t_31); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 673, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_35);
        if (__pyx_t_34) {
          __Pyx_GIVEREF(__pyx_t_34); PyTuple_SET_ITEM(__pyx_t_35, 0, __pyx_t_34); __pyx_t_34 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_35, 0+__pyx_t_31, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_33);
        PyTuple_SET_ITEM(__pyx_t_35, 1+__pyx_t_31, __pyx_t_33);
        __pyx_t_9 = 0;
        __pyx_t_33 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_35, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 673, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_35); __pyx_t_35 = 0;
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      __pyx_t_31 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_31 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_A), __pyx_t_10};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 673, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_A), __pyx_t_10};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_31, 2+__pyx_t_31); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 673, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      {
        __pyx_t_35 = PyTuple_New(2+__pyx_t_31); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 673, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_35);
        if (__pyx_t_12) {
          __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_35, 0, __pyx_t_12); __pyx_t_12 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_A));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_A));
        PyTuple_SET_ITEM(__pyx_t_35, 0+__pyx_t_31, ((PyObject *)__pyx_v_A));
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_35, 1+__pyx_t_31, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_35, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 673, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_35); __pyx_t_35 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyNumber_Add(__pyx_t_1, ((PyObject *)__pyx_v_dQ)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_7, __pyx_t_1) < 0)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "GPy/models/state_space_cython.pyx":675
 *             dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ
 * 
 *             dP_pred[:,:,j] = 0.5*(dP_pred[:,:,j] + dP_pred[:,:,j].T) #symmetrize             # <<<<<<<<<<<<<<
 *     else:
 *         dm_pred = None
 */
      __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_T); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Add(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyNumber_Multiply(__pyx_float_0_5, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_1);
      __pyx_t_1 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_7, __pyx_t_6) < 0)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }

    /* "GPy/models/state_space_cython.pyx":654
 *     cdef np.ndarray[DTYPE_t, ndim=2] dA
 *     cdef np.ndarray[DTYPE_t, ndim=2] dQ
 *     if calc_grad_log_likelihood:             # <<<<<<<<<<<<<<
 *         dA_all_params = p_dynamic_callables.dAk(k) # derivatives of A wrt parameters
 *         dQ_all_params = p_dynamic_callables.dQk(k) # derivatives of Q wrt parameters
 */
    goto __pyx_L3;
  }

  /* "GPy/models/state_space_cython.pyx":677
 *             dP_pred[:,:,j] = 0.5*(dP_pred[:,:,j] + dP_pred[:,:,j].T) #symmetrize
 *     else:
 *         dm_pred = None             # <<<<<<<<<<<<<<
 *         dP_pred = None
 * 
 */
  /*else*/ {
    __pyx_t_26 = ((PyArrayObject *)Py_None);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_26, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
        }
        __pyx_t_22 = __pyx_t_23 = __pyx_t_24 = 0;
      }
      __pyx_pybuffernd_dm_pred.diminfo[0].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_pred.diminfo[0].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_pred.diminfo[1].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_pred.diminfo[1].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_pred.diminfo[2].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_pred.diminfo[2].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 677, __pyx_L1_error)
    }
    __pyx_t_26 = 0;
    __Pyx_INCREF(Py_None);
    __pyx_v_dm_pred = ((PyArrayObject *)Py_None);

    /* "GPy/models/state_space_cython.pyx":678
 *     else:
 *         dm_pred = None
 *         dP_pred = None             # <<<<<<<<<<<<<<
 * 
 *     ret = (P_pred, S_new, Vh.T)
 */
    __pyx_t_27 = ((PyArrayObject *)Py_None);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_27, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
        }
        __pyx_t_24 = __pyx_t_23 = __pyx_t_22 = 0;
      }
      __pyx_pybuffernd_dP_pred.diminfo[0].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_pred.diminfo[0].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_pred.diminfo[1].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_pred.diminfo[1].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_pred.diminfo[2].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_pred.diminfo[2].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 678, __pyx_L1_error)
    }
    __pyx_t_27 = 0;
    __Pyx_INCREF(Py_None);
    __pyx_v_dP_pred = ((PyArrayObject *)Py_None);
  }
  __pyx_L3:;

  /* "GPy/models/state_space_cython.pyx":680
 *         dP_pred = None
 * 
 *     ret = (P_pred, S_new, Vh.T)             # <<<<<<<<<<<<<<
 *     return m_pred, ret, dm_pred, dP_pred
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Vh), __pyx_n_s_T); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_P_pred));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred));
  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_P_pred));
  __Pyx_INCREF(((PyObject *)__pyx_v_S_new));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_S_new));
  PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_v_S_new));
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_v_ret = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "GPy/models/state_space_cython.pyx":681
 * 
 *     ret = (P_pred, S_new, Vh.T)
 *     return m_pred, ret, dm_pred, dP_pred             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_m_pred));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred));
  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_m_pred));
  __Pyx_INCREF(__pyx_v_ret);
  __Pyx_GIVEREF(__pyx_v_ret);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_ret);
  __Pyx_INCREF(((PyObject *)__pyx_v_dm_pred));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dm_pred));
  PyTuple_SET_ITEM(__pyx_t_7, 2, ((PyObject *)__pyx_v_dm_pred));
  __Pyx_INCREF(((PyObject *)__pyx_v_dP_pred));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dP_pred));
  PyTuple_SET_ITEM(__pyx_t_7, 3, ((PyObject *)__pyx_v_dP_pred));
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":547
 * 
 * @cython.boundscheck(False)
 * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P,             # <<<<<<<<<<<<<<
 *                                 Dynamic_Callables_Cython p_dynamic_callables,
 *                                 bint calc_grad_log_likelihood=False,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_33);
  __Pyx_XDECREF(__pyx_t_34);
  __Pyx_XDECREF(__pyx_t_35);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q_sr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_new.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_old.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_new.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_old.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython._kalman_prediction_step_SVD_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q_sr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_new.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_old.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_new.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_old.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_Prev_cov);
  __Pyx_XDECREF((PyObject *)__pyx_v_S_old);
  __Pyx_XDECREF((PyObject *)__pyx_v_V_old);
  __Pyx_XDECREF((PyObject *)__pyx_v_A);
  __Pyx_XDECREF((PyObject *)__pyx_v_Q);
  __Pyx_XDECREF((PyObject *)__pyx_v_Q_sr);
  __Pyx_XDECREF((PyObject *)__pyx_v_m_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_svd_1_matr);
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XDECREF((PyObject *)__pyx_v_U);
  __Pyx_XDECREF((PyObject *)__pyx_v_S);
  __Pyx_XDECREF((PyObject *)__pyx_v_Vh);
  __Pyx_XDECREF((PyObject *)__pyx_v_V_new);
  __Pyx_XDECREF((PyObject *)__pyx_v_S_new);
  __Pyx_XDECREF((PyObject *)__pyx_v_P_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_dA_all_params);
  __Pyx_XDECREF((PyObject *)__pyx_v_dQ_all_params);
  __Pyx_XDECREF((PyObject *)__pyx_v_dm_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_dP_pred);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF((PyObject *)__pyx_v_dA);
  __Pyx_XDECREF((PyObject *)__pyx_v_dQ);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":686
 * 
 * @cython.boundscheck(False)
 * def _kalman_update_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m, tuple p_P,             # <<<<<<<<<<<<<<
 *                             Measurement_Callables_Cython p_measurement_callables,
 *                             np.ndarray[DTYPE_t, ndim=2] measurement,
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_3_kalman_update_step_SVD_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3GPy_6models_18state_space_cython_2_kalman_update_step_SVD_Cython[] = "\n    Input:\n    \n    k: int\n          Iteration No. Starts at 0. Total number of iterations equal to the \n          number of measurements.\n      \n    m_P: matrix of size (state_dim, time_series_no)\n         Mean value from the previous step. For \"multiple time series mode\" \n            it is matrix, second dimension of which correspond to different\n            time series.\n            \n    p_P: tuple (P_pred, S, V)\n         Covariance matrix from the prediction step and its SVD decomposition.\n         P_pred = V * S * V.T The tuple is (P_pred, S, V)\n         \n    p_h: function (k, x_{k}, H_{k}). Measurement function.\n        k (iteration number), starts at 0\n        x_{k} state \n        H_{k} Jacobian matrices of f_h. In the linear case it is exactly H_{k}.\n    \n    p_f_H: function (k, m, P) return Jacobian of dynamic function, it is\n        passed into p_h.\n        k (iteration number), starts at 0\n        m: point where Jacobian is evaluated\n        P: parameter for Jacobian, usually covariance matrix.\n    \n    p_f_R: function (k). Returns noise matrix of measurement equation \n        on iteration k.\n        k (iteration number). starts at 0\n        \n    p_f_iRsr: function (k). Returns the square root of the noise matrix of \n        measurement equation on iteration k. \n        k (iteration number). starts at 0\n        \n    measurement: (measurement_dim, time_series_no) matrix\n        One measurement used on the current update step. For \n        \"multiple time series mode\" it is matrix, second dimension of \n        which correspond to different time series.\n        \n    calc_log_likelihood: boolean\n        Whether to calculate marginal likelihood of the state-space model.\n    \n    calc_grad_log_likelihood: boolean\n            Whether to calculate gradient of the marginal likelihood \n            of the state-space model. If true then the next parameter must \n            provide the extra parameters for gradient cal""culation.\n    \n    p_dm: 3D array (state_dim, time_series_no, parameters_no)\n            Mean derivatives from the prediction step. For \"multiple time series mode\" \n            it is 3D array, second dimension of which correspond to different\n            time series.\n    \n    p_dP: array\n        Covariance derivatives from the prediction step.\n    \n    grad_calc_params_2: List or None\n        List with derivatives. The first component is 'f_dH' - function(k)\n        which returns the derivative of H. The second element is 'f_dR'\n         - function(k). Function which returns the derivative of R.\n    \n    Output:\n    ----------------------------\n    m_upd, P_upd, dm_upd, dP_upd: metrices, 3D objects\n        Results of the prediction steps.\n        \n    log_likelihood_update: double or 1D array\n        Update to the log_likelihood from this step        \n    \n    d_log_likelihood_update: (grad_params_no, time_series_no) matrix\n        Update to the gradient of log_likelihood, \"multiple time series mode\"\n        adds extra columns to the gradient.\n    \n    ";
static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_3_kalman_update_step_SVD_Cython = {"_kalman_update_step_SVD_Cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_3_kalman_update_step_SVD_Cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_2_kalman_update_step_SVD_Cython};
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_3_kalman_update_step_SVD_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  long __pyx_v_k;
  PyArrayObject *__pyx_v_p_m = 0;
  PyObject *__pyx_v_p_P = 0;
  struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables = 0;
  PyArrayObject *__pyx_v_measurement = 0;
  int __pyx_v_calc_log_likelihood;
  int __pyx_v_calc_grad_log_likelihood;
  PyArrayObject *__pyx_v_p_dm = 0;
  PyArrayObject *__pyx_v_p_dP = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_kalman_update_step_SVD_Cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_p_m,&__pyx_n_s_p_P,&__pyx_n_s_p_measurement_callables,&__pyx_n_s_measurement,&__pyx_n_s_calc_log_likelihood,&__pyx_n_s_calc_grad_log_likelihood,&__pyx_n_s_p_dm,&__pyx_n_s_p_dP,0};
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};

    /* "GPy/models/state_space_cython.pyx":691
 *                             bint calc_log_likelihood= False,
 *                             bint calc_grad_log_likelihood=False,
 *                             np.ndarray[DTYPE_t, ndim=3] p_dm = None,             # <<<<<<<<<<<<<<
 *                             np.ndarray[DTYPE_t, ndim=3] p_dP = None):
 *     """
 */
    values[7] = (PyObject *)((PyArrayObject *)Py_None);

    /* "GPy/models/state_space_cython.pyx":692
 *                             bint calc_grad_log_likelihood=False,
 *                             np.ndarray[DTYPE_t, ndim=3] p_dm = None,
 *                             np.ndarray[DTYPE_t, ndim=3] p_dP = None):             # <<<<<<<<<<<<<<
 *     """
 *     Input:
 */
    values[8] = (PyObject *)((PyArrayObject *)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  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_m)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_kalman_update_step_SVD_Cython", 0, 5, 9, 1); __PYX_ERR(0, 686, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_P)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_kalman_update_step_SVD_Cython", 0, 5, 9, 2); __PYX_ERR(0, 686, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_measurement_callables)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_kalman_update_step_SVD_Cython", 0, 5, 9, 3); __PYX_ERR(0, 686, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_measurement)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_kalman_update_step_SVD_Cython", 0, 5, 9, 4); __PYX_ERR(0, 686, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_calc_log_likelihood);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_calc_grad_log_likelihood);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_dm);
          if (value) { values[7] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_dP);
          if (value) { values[8] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_kalman_update_step_SVD_Cython") < 0)) __PYX_ERR(0, 686, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 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_k = __Pyx_PyInt_As_long(values[0]); if (unlikely((__pyx_v_k == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 686, __pyx_L3_error)
    __pyx_v_p_m = ((PyArrayObject *)values[1]);
    __pyx_v_p_P = ((PyObject*)values[2]);
    __pyx_v_p_measurement_callables = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)values[3]);
    __pyx_v_measurement = ((PyArrayObject *)values[4]);
    if (values[5]) {
      __pyx_v_calc_log_likelihood = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_calc_log_likelihood == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 689, __pyx_L3_error)
    } else {

      /* "GPy/models/state_space_cython.pyx":689
 *                             Measurement_Callables_Cython p_measurement_callables,
 *                             np.ndarray[DTYPE_t, ndim=2] measurement,
 *                             bint calc_log_likelihood= False,             # <<<<<<<<<<<<<<
 *                             bint calc_grad_log_likelihood=False,
 *                             np.ndarray[DTYPE_t, ndim=3] p_dm = None,
 */
      __pyx_v_calc_log_likelihood = ((int)0);
    }
    if (values[6]) {
      __pyx_v_calc_grad_log_likelihood = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_calc_grad_log_likelihood == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 690, __pyx_L3_error)
    } else {

      /* "GPy/models/state_space_cython.pyx":690
 *                             np.ndarray[DTYPE_t, ndim=2] measurement,
 *                             bint calc_log_likelihood= False,
 *                             bint calc_grad_log_likelihood=False,             # <<<<<<<<<<<<<<
 *                             np.ndarray[DTYPE_t, ndim=3] p_dm = None,
 *                             np.ndarray[DTYPE_t, ndim=3] p_dP = None):
 */
      __pyx_v_calc_grad_log_likelihood = ((int)0);
    }
    __pyx_v_p_dm = ((PyArrayObject *)values[7]);
    __pyx_v_p_dP = ((PyArrayObject *)values[8]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_kalman_update_step_SVD_Cython", 0, 5, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 686, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython._kalman_update_step_SVD_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_m), __pyx_ptype_5numpy_ndarray, 1, "p_m", 0))) __PYX_ERR(0, 686, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_P), (&PyTuple_Type), 1, "p_P", 1))) __PYX_ERR(0, 686, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_measurement_callables), __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython, 1, "p_measurement_callables", 0))) __PYX_ERR(0, 687, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_measurement), __pyx_ptype_5numpy_ndarray, 1, "measurement", 0))) __PYX_ERR(0, 688, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dm), __pyx_ptype_5numpy_ndarray, 1, "p_dm", 0))) __PYX_ERR(0, 691, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dP), __pyx_ptype_5numpy_ndarray, 1, "p_dP", 0))) __PYX_ERR(0, 692, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_2_kalman_update_step_SVD_Cython(__pyx_self, __pyx_v_k, __pyx_v_p_m, __pyx_v_p_P, __pyx_v_p_measurement_callables, __pyx_v_measurement, __pyx_v_calc_log_likelihood, __pyx_v_calc_grad_log_likelihood, __pyx_v_p_dm, __pyx_v_p_dP);

  /* "GPy/models/state_space_cython.pyx":686
 * 
 * @cython.boundscheck(False)
 * def _kalman_update_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m, tuple p_P,             # <<<<<<<<<<<<<<
 *                             Measurement_Callables_Cython p_measurement_callables,
 *                             np.ndarray[DTYPE_t, ndim=2] measurement,
 */

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_2_kalman_update_step_SVD_Cython(CYTHON_UNUSED PyObject *__pyx_self, long __pyx_v_k, PyArrayObject *__pyx_v_p_m, PyObject *__pyx_v_p_P, struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables, PyArrayObject *__pyx_v_measurement, int __pyx_v_calc_log_likelihood, int __pyx_v_calc_grad_log_likelihood, PyArrayObject *__pyx_v_p_dm, PyArrayObject *__pyx_v_p_dP) {
  PyArrayObject *__pyx_v_m_pred = 0;
  PyArrayObject *__pyx_v_P_pred = 0;
  PyArrayObject *__pyx_v_S_pred = 0;
  PyArrayObject *__pyx_v_V_pred = 0;
  PyArrayObject *__pyx_v_H = 0;
  PyArrayObject *__pyx_v_R = 0;
  PyArrayObject *__pyx_v_R_isr = 0;
  int __pyx_v_time_series_no;
  PyArrayObject *__pyx_v_log_likelihood_update = 0;
  PyArrayObject *__pyx_v_v = 0;
  PyArrayObject *__pyx_v_svd_2_matr = 0;
  PyObject *__pyx_v_res = NULL;
  CYTHON_UNUSED PyArrayObject *__pyx_v_U = 0;
  PyArrayObject *__pyx_v_S_svd = 0;
  PyArrayObject *__pyx_v_Vh = 0;
  PyArrayObject *__pyx_v_U_upd = 0;
  PyArrayObject *__pyx_v_S_upd = 0;
  PyArrayObject *__pyx_v_P_upd = 0;
  PyArrayObject *__pyx_v_S = 0;
  PyArrayObject *__pyx_v_K = 0;
  CYTHON_UNUSED int __pyx_v_measurement_dim_gt_one;
  PyArrayObject *__pyx_v_dm_upd = 0;
  PyArrayObject *__pyx_v_dP_upd = 0;
  PyArrayObject *__pyx_v_d_log_likelihood_update = 0;
  PyArrayObject *__pyx_v_dm_pred_all_params = 0;
  PyArrayObject *__pyx_v_dP_pred_all_params = 0;
  int __pyx_v_param_number;
  PyArrayObject *__pyx_v_dH_all_params = 0;
  PyArrayObject *__pyx_v_dR_all_params = 0;
  int __pyx_v_param;
  PyArrayObject *__pyx_v_dH = 0;
  PyArrayObject *__pyx_v_dR = 0;
  PyArrayObject *__pyx_v_dm_pred = 0;
  PyArrayObject *__pyx_v_dP_pred = 0;
  PyArrayObject *__pyx_v_dv = 0;
  PyArrayObject *__pyx_v_dS = 0;
  PyArrayObject *__pyx_v_tmp1 = 0;
  PyArrayObject *__pyx_v_tmp2 = 0;
  PyArrayObject *__pyx_v_tmp3 = 0;
  PyArrayObject *__pyx_v_dK = 0;
  PyArrayObject *__pyx_v_tmp5 = 0;
  PyObject *__pyx_v_ret = 0;
  PyObject *__pyx_v_m_upd = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_H;
  __Pyx_Buffer __pyx_pybuffer_H;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_K;
  __Pyx_Buffer __pyx_pybuffer_K;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred;
  __Pyx_Buffer __pyx_pybuffer_P_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P_upd;
  __Pyx_Buffer __pyx_pybuffer_P_upd;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_R;
  __Pyx_Buffer __pyx_pybuffer_R;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_R_isr;
  __Pyx_Buffer __pyx_pybuffer_R_isr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S;
  __Pyx_Buffer __pyx_pybuffer_S;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S_pred;
  __Pyx_Buffer __pyx_pybuffer_S_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S_svd;
  __Pyx_Buffer __pyx_pybuffer_S_svd;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S_upd;
  __Pyx_Buffer __pyx_pybuffer_S_upd;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_U;
  __Pyx_Buffer __pyx_pybuffer_U;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_U_upd;
  __Pyx_Buffer __pyx_pybuffer_U_upd;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_V_pred;
  __Pyx_Buffer __pyx_pybuffer_V_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh;
  __Pyx_Buffer __pyx_pybuffer_Vh;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dH;
  __Pyx_Buffer __pyx_pybuffer_dH;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dH_all_params;
  __Pyx_Buffer __pyx_pybuffer_dH_all_params;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dK;
  __Pyx_Buffer __pyx_pybuffer_dK;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_pred;
  __Pyx_Buffer __pyx_pybuffer_dP_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_pred_all_params;
  __Pyx_Buffer __pyx_pybuffer_dP_pred_all_params;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_upd;
  __Pyx_Buffer __pyx_pybuffer_dP_upd;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dR;
  __Pyx_Buffer __pyx_pybuffer_dR;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dR_all_params;
  __Pyx_Buffer __pyx_pybuffer_dR_all_params;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dS;
  __Pyx_Buffer __pyx_pybuffer_dS;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_d_log_likelihood_update;
  __Pyx_Buffer __pyx_pybuffer_d_log_likelihood_update;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_pred;
  __Pyx_Buffer __pyx_pybuffer_dm_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_pred_all_params;
  __Pyx_Buffer __pyx_pybuffer_dm_pred_all_params;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_upd;
  __Pyx_Buffer __pyx_pybuffer_dm_upd;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dv;
  __Pyx_Buffer __pyx_pybuffer_dv;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_log_likelihood_update;
  __Pyx_Buffer __pyx_pybuffer_log_likelihood_update;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred;
  __Pyx_Buffer __pyx_pybuffer_m_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_measurement;
  __Pyx_Buffer __pyx_pybuffer_measurement;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_p_dP;
  __Pyx_Buffer __pyx_pybuffer_p_dP;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_p_dm;
  __Pyx_Buffer __pyx_pybuffer_p_dm;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_p_m;
  __Pyx_Buffer __pyx_pybuffer_p_m;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_svd_2_matr;
  __Pyx_Buffer __pyx_pybuffer_svd_2_matr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_tmp1;
  __Pyx_Buffer __pyx_pybuffer_tmp1;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_tmp2;
  __Pyx_Buffer __pyx_pybuffer_tmp2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_tmp3;
  __Pyx_Buffer __pyx_pybuffer_tmp3;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_tmp5;
  __Pyx_Buffer __pyx_pybuffer_tmp5;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_v;
  __Pyx_Buffer __pyx_pybuffer_v;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyArrayObject *__pyx_t_2 = NULL;
  PyArrayObject *__pyx_t_3 = NULL;
  PyArrayObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyArrayObject *__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;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyArrayObject *__pyx_t_15 = NULL;
  PyArrayObject *__pyx_t_16 = NULL;
  PyArrayObject *__pyx_t_17 = NULL;
  PyArrayObject *__pyx_t_18 = NULL;
  PyArrayObject *__pyx_t_19 = NULL;
  PyArrayObject *__pyx_t_20 = NULL;
  PyArrayObject *__pyx_t_21 = NULL;
  PyArrayObject *__pyx_t_22 = NULL;
  int __pyx_t_23;
  PyArrayObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyArrayObject *__pyx_t_28 = NULL;
  PyArrayObject *__pyx_t_29 = NULL;
  PyArrayObject *__pyx_t_30 = NULL;
  PyArrayObject *__pyx_t_31 = NULL;
  PyArrayObject *__pyx_t_32 = NULL;
  PyArrayObject *__pyx_t_33 = NULL;
  int __pyx_t_34;
  int __pyx_t_35;
  PyArrayObject *__pyx_t_36 = NULL;
  int __pyx_t_37;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_kalman_update_step_SVD_Cython", 0);
  __pyx_pybuffer_m_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_m_pred.refcount = 0;
  __pyx_pybuffernd_m_pred.data = NULL;
  __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred;
  __pyx_pybuffer_P_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_P_pred.refcount = 0;
  __pyx_pybuffernd_P_pred.data = NULL;
  __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred;
  __pyx_pybuffer_S_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_S_pred.refcount = 0;
  __pyx_pybuffernd_S_pred.data = NULL;
  __pyx_pybuffernd_S_pred.rcbuffer = &__pyx_pybuffer_S_pred;
  __pyx_pybuffer_V_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_V_pred.refcount = 0;
  __pyx_pybuffernd_V_pred.data = NULL;
  __pyx_pybuffernd_V_pred.rcbuffer = &__pyx_pybuffer_V_pred;
  __pyx_pybuffer_H.pybuffer.buf = NULL;
  __pyx_pybuffer_H.refcount = 0;
  __pyx_pybuffernd_H.data = NULL;
  __pyx_pybuffernd_H.rcbuffer = &__pyx_pybuffer_H;
  __pyx_pybuffer_R.pybuffer.buf = NULL;
  __pyx_pybuffer_R.refcount = 0;
  __pyx_pybuffernd_R.data = NULL;
  __pyx_pybuffernd_R.rcbuffer = &__pyx_pybuffer_R;
  __pyx_pybuffer_R_isr.pybuffer.buf = NULL;
  __pyx_pybuffer_R_isr.refcount = 0;
  __pyx_pybuffernd_R_isr.data = NULL;
  __pyx_pybuffernd_R_isr.rcbuffer = &__pyx_pybuffer_R_isr;
  __pyx_pybuffer_log_likelihood_update.pybuffer.buf = NULL;
  __pyx_pybuffer_log_likelihood_update.refcount = 0;
  __pyx_pybuffernd_log_likelihood_update.data = NULL;
  __pyx_pybuffernd_log_likelihood_update.rcbuffer = &__pyx_pybuffer_log_likelihood_update;
  __pyx_pybuffer_v.pybuffer.buf = NULL;
  __pyx_pybuffer_v.refcount = 0;
  __pyx_pybuffernd_v.data = NULL;
  __pyx_pybuffernd_v.rcbuffer = &__pyx_pybuffer_v;
  __pyx_pybuffer_svd_2_matr.pybuffer.buf = NULL;
  __pyx_pybuffer_svd_2_matr.refcount = 0;
  __pyx_pybuffernd_svd_2_matr.data = NULL;
  __pyx_pybuffernd_svd_2_matr.rcbuffer = &__pyx_pybuffer_svd_2_matr;
  __pyx_pybuffer_U.pybuffer.buf = NULL;
  __pyx_pybuffer_U.refcount = 0;
  __pyx_pybuffernd_U.data = NULL;
  __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U;
  __pyx_pybuffer_S_svd.pybuffer.buf = NULL;
  __pyx_pybuffer_S_svd.refcount = 0;
  __pyx_pybuffernd_S_svd.data = NULL;
  __pyx_pybuffernd_S_svd.rcbuffer = &__pyx_pybuffer_S_svd;
  __pyx_pybuffer_Vh.pybuffer.buf = NULL;
  __pyx_pybuffer_Vh.refcount = 0;
  __pyx_pybuffernd_Vh.data = NULL;
  __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh;
  __pyx_pybuffer_U_upd.pybuffer.buf = NULL;
  __pyx_pybuffer_U_upd.refcount = 0;
  __pyx_pybuffernd_U_upd.data = NULL;
  __pyx_pybuffernd_U_upd.rcbuffer = &__pyx_pybuffer_U_upd;
  __pyx_pybuffer_S_upd.pybuffer.buf = NULL;
  __pyx_pybuffer_S_upd.refcount = 0;
  __pyx_pybuffernd_S_upd.data = NULL;
  __pyx_pybuffernd_S_upd.rcbuffer = &__pyx_pybuffer_S_upd;
  __pyx_pybuffer_P_upd.pybuffer.buf = NULL;
  __pyx_pybuffer_P_upd.refcount = 0;
  __pyx_pybuffernd_P_upd.data = NULL;
  __pyx_pybuffernd_P_upd.rcbuffer = &__pyx_pybuffer_P_upd;
  __pyx_pybuffer_S.pybuffer.buf = NULL;
  __pyx_pybuffer_S.refcount = 0;
  __pyx_pybuffernd_S.data = NULL;
  __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S;
  __pyx_pybuffer_K.pybuffer.buf = NULL;
  __pyx_pybuffer_K.refcount = 0;
  __pyx_pybuffernd_K.data = NULL;
  __pyx_pybuffernd_K.rcbuffer = &__pyx_pybuffer_K;
  __pyx_pybuffer_dm_upd.pybuffer.buf = NULL;
  __pyx_pybuffer_dm_upd.refcount = 0;
  __pyx_pybuffernd_dm_upd.data = NULL;
  __pyx_pybuffernd_dm_upd.rcbuffer = &__pyx_pybuffer_dm_upd;
  __pyx_pybuffer_dP_upd.pybuffer.buf = NULL;
  __pyx_pybuffer_dP_upd.refcount = 0;
  __pyx_pybuffernd_dP_upd.data = NULL;
  __pyx_pybuffernd_dP_upd.rcbuffer = &__pyx_pybuffer_dP_upd;
  __pyx_pybuffer_d_log_likelihood_update.pybuffer.buf = NULL;
  __pyx_pybuffer_d_log_likelihood_update.refcount = 0;
  __pyx_pybuffernd_d_log_likelihood_update.data = NULL;
  __pyx_pybuffernd_d_log_likelihood_update.rcbuffer = &__pyx_pybuffer_d_log_likelihood_update;
  __pyx_pybuffer_dm_pred_all_params.pybuffer.buf = NULL;
  __pyx_pybuffer_dm_pred_all_params.refcount = 0;
  __pyx_pybuffernd_dm_pred_all_params.data = NULL;
  __pyx_pybuffernd_dm_pred_all_params.rcbuffer = &__pyx_pybuffer_dm_pred_all_params;
  __pyx_pybuffer_dP_pred_all_params.pybuffer.buf = NULL;
  __pyx_pybuffer_dP_pred_all_params.refcount = 0;
  __pyx_pybuffernd_dP_pred_all_params.data = NULL;
  __pyx_pybuffernd_dP_pred_all_params.rcbuffer = &__pyx_pybuffer_dP_pred_all_params;
  __pyx_pybuffer_dH_all_params.pybuffer.buf = NULL;
  __pyx_pybuffer_dH_all_params.refcount = 0;
  __pyx_pybuffernd_dH_all_params.data = NULL;
  __pyx_pybuffernd_dH_all_params.rcbuffer = &__pyx_pybuffer_dH_all_params;
  __pyx_pybuffer_dR_all_params.pybuffer.buf = NULL;
  __pyx_pybuffer_dR_all_params.refcount = 0;
  __pyx_pybuffernd_dR_all_params.data = NULL;
  __pyx_pybuffernd_dR_all_params.rcbuffer = &__pyx_pybuffer_dR_all_params;
  __pyx_pybuffer_dH.pybuffer.buf = NULL;
  __pyx_pybuffer_dH.refcount = 0;
  __pyx_pybuffernd_dH.data = NULL;
  __pyx_pybuffernd_dH.rcbuffer = &__pyx_pybuffer_dH;
  __pyx_pybuffer_dR.pybuffer.buf = NULL;
  __pyx_pybuffer_dR.refcount = 0;
  __pyx_pybuffernd_dR.data = NULL;
  __pyx_pybuffernd_dR.rcbuffer = &__pyx_pybuffer_dR;
  __pyx_pybuffer_dm_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_dm_pred.refcount = 0;
  __pyx_pybuffernd_dm_pred.data = NULL;
  __pyx_pybuffernd_dm_pred.rcbuffer = &__pyx_pybuffer_dm_pred;
  __pyx_pybuffer_dP_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_dP_pred.refcount = 0;
  __pyx_pybuffernd_dP_pred.data = NULL;
  __pyx_pybuffernd_dP_pred.rcbuffer = &__pyx_pybuffer_dP_pred;
  __pyx_pybuffer_dv.pybuffer.buf = NULL;
  __pyx_pybuffer_dv.refcount = 0;
  __pyx_pybuffernd_dv.data = NULL;
  __pyx_pybuffernd_dv.rcbuffer = &__pyx_pybuffer_dv;
  __pyx_pybuffer_dS.pybuffer.buf = NULL;
  __pyx_pybuffer_dS.refcount = 0;
  __pyx_pybuffernd_dS.data = NULL;
  __pyx_pybuffernd_dS.rcbuffer = &__pyx_pybuffer_dS;
  __pyx_pybuffer_tmp1.pybuffer.buf = NULL;
  __pyx_pybuffer_tmp1.refcount = 0;
  __pyx_pybuffernd_tmp1.data = NULL;
  __pyx_pybuffernd_tmp1.rcbuffer = &__pyx_pybuffer_tmp1;
  __pyx_pybuffer_tmp2.pybuffer.buf = NULL;
  __pyx_pybuffer_tmp2.refcount = 0;
  __pyx_pybuffernd_tmp2.data = NULL;
  __pyx_pybuffernd_tmp2.rcbuffer = &__pyx_pybuffer_tmp2;
  __pyx_pybuffer_tmp3.pybuffer.buf = NULL;
  __pyx_pybuffer_tmp3.refcount = 0;
  __pyx_pybuffernd_tmp3.data = NULL;
  __pyx_pybuffernd_tmp3.rcbuffer = &__pyx_pybuffer_tmp3;
  __pyx_pybuffer_dK.pybuffer.buf = NULL;
  __pyx_pybuffer_dK.refcount = 0;
  __pyx_pybuffernd_dK.data = NULL;
  __pyx_pybuffernd_dK.rcbuffer = &__pyx_pybuffer_dK;
  __pyx_pybuffer_tmp5.pybuffer.buf = NULL;
  __pyx_pybuffer_tmp5.refcount = 0;
  __pyx_pybuffernd_tmp5.data = NULL;
  __pyx_pybuffernd_tmp5.rcbuffer = &__pyx_pybuffer_tmp5;
  __pyx_pybuffer_p_m.pybuffer.buf = NULL;
  __pyx_pybuffer_p_m.refcount = 0;
  __pyx_pybuffernd_p_m.data = NULL;
  __pyx_pybuffernd_p_m.rcbuffer = &__pyx_pybuffer_p_m;
  __pyx_pybuffer_measurement.pybuffer.buf = NULL;
  __pyx_pybuffer_measurement.refcount = 0;
  __pyx_pybuffernd_measurement.data = NULL;
  __pyx_pybuffernd_measurement.rcbuffer = &__pyx_pybuffer_measurement;
  __pyx_pybuffer_p_dm.pybuffer.buf = NULL;
  __pyx_pybuffer_p_dm.refcount = 0;
  __pyx_pybuffernd_p_dm.data = NULL;
  __pyx_pybuffernd_p_dm.rcbuffer = &__pyx_pybuffer_p_dm;
  __pyx_pybuffer_p_dP.pybuffer.buf = NULL;
  __pyx_pybuffer_p_dP.refcount = 0;
  __pyx_pybuffernd_p_dP.data = NULL;
  __pyx_pybuffernd_p_dP.rcbuffer = &__pyx_pybuffer_p_dP;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 686, __pyx_L1_error)
  }
  __pyx_pybuffernd_p_m.diminfo[0].strides = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_m.diminfo[0].shape = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_m.diminfo[1].strides = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_m.diminfo[1].shape = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_measurement.rcbuffer->pybuffer, (PyObject*)__pyx_v_measurement, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 686, __pyx_L1_error)
  }
  __pyx_pybuffernd_measurement.diminfo[0].strides = __pyx_pybuffernd_measurement.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_measurement.diminfo[0].shape = __pyx_pybuffernd_measurement.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_measurement.diminfo[1].strides = __pyx_pybuffernd_measurement.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_measurement.diminfo[1].shape = __pyx_pybuffernd_measurement.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_dm, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 686, __pyx_L1_error)
  }
  __pyx_pybuffernd_p_dm.diminfo[0].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_dm.diminfo[0].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_dm.diminfo[1].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_dm.diminfo[1].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_p_dm.diminfo[2].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_p_dm.diminfo[2].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_dP, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 686, __pyx_L1_error)
  }
  __pyx_pybuffernd_p_dP.diminfo[0].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_dP.diminfo[0].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_dP.diminfo[1].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_dP.diminfo[1].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_p_dP.diminfo[2].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_p_dP.diminfo[2].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[2];

  /* "GPy/models/state_space_cython.pyx":768
 *     """
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] m_pred = p_m # from prediction step             # <<<<<<<<<<<<<<
 *     #P_pred,S_pred,V_pred = p_P # from prediction step
 *     cdef np.ndarray[DTYPE_t, ndim=2] P_pred = p_P[0]
 */
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_p_m), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_m_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 768, __pyx_L1_error)
    } else {__pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1];
    }
  }
  __Pyx_INCREF(((PyObject *)__pyx_v_p_m));
  __pyx_v_m_pred = ((PyArrayObject *)__pyx_v_p_m);

  /* "GPy/models/state_space_cython.pyx":770
 *     cdef np.ndarray[DTYPE_t, ndim=2] m_pred = p_m # from prediction step
 *     #P_pred,S_pred,V_pred = p_P # from prediction step
 *     cdef np.ndarray[DTYPE_t, ndim=2] P_pred = p_P[0]             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_pred = p_P[1]
 *     cdef np.ndarray[DTYPE_t, ndim=2] V_pred = p_P[2]
 */
  if (unlikely(__pyx_v_p_P == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 770, __pyx_L1_error)
  }
  if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 0)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 0), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 770, __pyx_L1_error)
  __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 0);
  __Pyx_INCREF(__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_P_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 770, __pyx_L1_error)
    } else {__pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_v_P_pred = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":771
 *     #P_pred,S_pred,V_pred = p_P # from prediction step
 *     cdef np.ndarray[DTYPE_t, ndim=2] P_pred = p_P[0]
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_pred = p_P[1]             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=2] V_pred = p_P[2]
 * 
 */
  if (unlikely(__pyx_v_p_P == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 771, __pyx_L1_error)
  }
  if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 1)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 1), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 771, __pyx_L1_error)
  __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 1);
  __Pyx_INCREF(__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S_pred.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_S_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S_pred.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 771, __pyx_L1_error)
    } else {__pyx_pybuffernd_S_pred.diminfo[0].strides = __pyx_pybuffernd_S_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S_pred.diminfo[0].shape = __pyx_pybuffernd_S_pred.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_v_S_pred = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":772
 *     cdef np.ndarray[DTYPE_t, ndim=2] P_pred = p_P[0]
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_pred = p_P[1]
 *     cdef np.ndarray[DTYPE_t, ndim=2] V_pred = p_P[2]             # <<<<<<<<<<<<<<
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] H = p_measurement_callables.Hk(k, m_pred, P_pred)
 */
  if (unlikely(__pyx_v_p_P == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 772, __pyx_L1_error)
  }
  if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 2)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 2), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 772, __pyx_L1_error)
  __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 2);
  __Pyx_INCREF(__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_V_pred.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_V_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_V_pred.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 772, __pyx_L1_error)
    } else {__pyx_pybuffernd_V_pred.diminfo[0].strides = __pyx_pybuffernd_V_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_V_pred.diminfo[0].shape = __pyx_pybuffernd_V_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_V_pred.diminfo[1].strides = __pyx_pybuffernd_V_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_V_pred.diminfo[1].shape = __pyx_pybuffernd_V_pred.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_v_V_pred = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":774
 *     cdef np.ndarray[DTYPE_t, ndim=2] V_pred = p_P[2]
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] H = p_measurement_callables.Hk(k, m_pred, P_pred)             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=2] R = p_measurement_callables.Rk(k)
 *     cdef np.ndarray[DTYPE_t, ndim=2] R_isr =p_measurement_callables.R_isrk(k) # square root of the inverse of R matrix
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->Hk(__pyx_v_p_measurement_callables, __pyx_v_k, ((PyArrayObject *)__pyx_v_m_pred), ((PyArrayObject *)__pyx_v_P_pred), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 774, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 774, __pyx_L1_error)
  __pyx_t_2 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_H.rcbuffer->pybuffer, (PyObject*)__pyx_t_2, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_H = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_H.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 774, __pyx_L1_error)
    } else {__pyx_pybuffernd_H.diminfo[0].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_H.diminfo[0].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_H.diminfo[1].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_H.diminfo[1].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_2 = 0;
  __pyx_v_H = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":775
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] H = p_measurement_callables.Hk(k, m_pred, P_pred)
 *     cdef np.ndarray[DTYPE_t, ndim=2] R = p_measurement_callables.Rk(k)             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=2] R_isr =p_measurement_callables.R_isrk(k) # square root of the inverse of R matrix
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->Rk(__pyx_v_p_measurement_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 775, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 775, __pyx_L1_error)
  __pyx_t_3 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_R = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_R.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 775, __pyx_L1_error)
    } else {__pyx_pybuffernd_R.diminfo[0].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R.diminfo[0].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_R.diminfo[1].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_R.diminfo[1].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_3 = 0;
  __pyx_v_R = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":776
 *     cdef np.ndarray[DTYPE_t, ndim=2] H = p_measurement_callables.Hk(k, m_pred, P_pred)
 *     cdef np.ndarray[DTYPE_t, ndim=2] R = p_measurement_callables.Rk(k)
 *     cdef np.ndarray[DTYPE_t, ndim=2] R_isr =p_measurement_callables.R_isrk(k) # square root of the inverse of R matrix             # <<<<<<<<<<<<<<
 * 
 *     cdef int time_series_no = p_m.shape[1] # number of time serieses
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->R_isrk(__pyx_v_p_measurement_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 776, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 776, __pyx_L1_error)
  __pyx_t_4 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R_isr.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_R_isr = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_R_isr.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 776, __pyx_L1_error)
    } else {__pyx_pybuffernd_R_isr.diminfo[0].strides = __pyx_pybuffernd_R_isr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R_isr.diminfo[0].shape = __pyx_pybuffernd_R_isr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_R_isr.diminfo[1].strides = __pyx_pybuffernd_R_isr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_R_isr.diminfo[1].shape = __pyx_pybuffernd_R_isr.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_4 = 0;
  __pyx_v_R_isr = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":778
 *     cdef np.ndarray[DTYPE_t, ndim=2] R_isr =p_measurement_callables.R_isrk(k) # square root of the inverse of R matrix
 * 
 *     cdef int time_series_no = p_m.shape[1] # number of time serieses             # <<<<<<<<<<<<<<
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] log_likelihood_update # log_likelihood_update=None;
 */
  __pyx_v_time_series_no = (__pyx_v_p_m->dimensions[1]);

  /* "GPy/models/state_space_cython.pyx":783
 *     # Update step (only if there is data)
 *     #if not np.any(np.isnan(measurement)): # TODO: if some dimensions are missing, do properly computations for other.
 *     cdef np.ndarray[DTYPE_t, ndim=2] v = measurement-p_measurement_callables.f_h(k, m_pred, H)             # <<<<<<<<<<<<<<
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] svd_2_matr = np.vstack( ( np.dot( R_isr.T, np.dot(H, V_pred)) , np.diag( 1.0/np.sqrt(S_pred) ) ) )
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->f_h(__pyx_v_p_measurement_callables, __pyx_v_k, ((PyArrayObject *)__pyx_v_m_pred), ((PyArrayObject *)__pyx_v_H), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyNumber_Subtract(((PyObject *)__pyx_v_measurement), __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 783, __pyx_L1_error)
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_v.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_v = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_v.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 783, __pyx_L1_error)
    } else {__pyx_pybuffernd_v.diminfo[0].strides = __pyx_pybuffernd_v.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_v.diminfo[0].shape = __pyx_pybuffernd_v.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_v.diminfo[1].strides = __pyx_pybuffernd_v.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_v.diminfo[1].shape = __pyx_pybuffernd_v.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_6 = 0;
  __pyx_v_v = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "GPy/models/state_space_cython.pyx":785
 *     cdef np.ndarray[DTYPE_t, ndim=2] v = measurement-p_measurement_callables.f_h(k, m_pred, H)
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] svd_2_matr = np.vstack( ( np.dot( R_isr.T, np.dot(H, V_pred)) , np.diag( 1.0/np.sqrt(S_pred) ) ) )             # <<<<<<<<<<<<<<
 * 
 *     res = sp.linalg.svd( svd_2_matr,full_matrices=False, compute_uv=True,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_vstack); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dot); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_R_isr), __pyx_n_s_T); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_dot); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = NULL;
  __pyx_t_13 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
      __pyx_t_13 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_H), ((PyObject *)__pyx_v_V_pred)};
    __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_10);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_H), ((PyObject *)__pyx_v_V_pred)};
    __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_10);
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 785, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_11) {
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_11); __pyx_t_11 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_H));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_H));
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, ((PyObject *)__pyx_v_H));
    __Pyx_INCREF(((PyObject *)__pyx_v_V_pred));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_V_pred));
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, ((PyObject *)__pyx_v_V_pred));
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = NULL;
  __pyx_t_13 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
      __pyx_t_13 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_8, __pyx_t_10};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 785, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_8, __pyx_t_10};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 785, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 785, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_12) {
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_t_10);
    __pyx_t_8 = 0;
    __pyx_t_10 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 785, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_diag); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  __pyx_t_14 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_8, ((PyObject *)__pyx_v_S_pred)) : __Pyx_PyObject_CallOneArg(__pyx_t_12, ((PyObject *)__pyx_v_S_pred));
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyFloat_DivideCObj(__pyx_float_1_0, __pyx_t_14, 1.0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  __pyx_t_9 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_14, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
  __pyx_t_1 = 0;
  __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_5 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_9, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 785, __pyx_L1_error)
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_svd_2_matr = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 785, __pyx_L1_error)
    } else {__pyx_pybuffernd_svd_2_matr.diminfo[0].strides = __pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_svd_2_matr.diminfo[0].shape = __pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_svd_2_matr.diminfo[1].strides = __pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_svd_2_matr.diminfo[1].shape = __pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_15 = 0;
  __pyx_v_svd_2_matr = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "GPy/models/state_space_cython.pyx":787
 *     cdef np.ndarray[DTYPE_t, ndim=2] svd_2_matr = np.vstack( ( np.dot( R_isr.T, np.dot(H, V_pred)) , np.diag( 1.0/np.sqrt(S_pred) ) ) )
 * 
 *     res = sp.linalg.svd( svd_2_matr,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                  overwrite_a=False,check_finite=True)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_sp); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_linalg); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_svd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_svd_2_matr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_svd_2_matr));
  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_svd_2_matr));
  __pyx_t_10 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_full_matrices, Py_False) < 0) __PYX_ERR(0, 787, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_compute_uv, Py_True) < 0) __PYX_ERR(0, 787, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":788
 * 
 *     res = sp.linalg.svd( svd_2_matr,full_matrices=False, compute_uv=True,
 *                  overwrite_a=False,check_finite=True)             # <<<<<<<<<<<<<<
 * 
 *     #(U,S,Vh)
 */
  if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_overwrite_a, Py_False) < 0) __PYX_ERR(0, 787, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_check_finite, Py_True) < 0) __PYX_ERR(0, 787, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":787
 *     cdef np.ndarray[DTYPE_t, ndim=2] svd_2_matr = np.vstack( ( np.dot( R_isr.T, np.dot(H, V_pred)) , np.diag( 1.0/np.sqrt(S_pred) ) ) )
 * 
 *     res = sp.linalg.svd( svd_2_matr,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *                  overwrite_a=False,check_finite=True)
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_v_res = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "GPy/models/state_space_cython.pyx":791
 * 
 *     #(U,S,Vh)
 *     cdef np.ndarray[DTYPE_t, ndim=2] U = res[0]             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_svd = res[1]
 *     cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2]
 */
  __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_res, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 791, __pyx_L1_error)
  __pyx_t_16 = ((PyArrayObject *)__pyx_t_9);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_U = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_U.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 791, __pyx_L1_error)
    } else {__pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_16 = 0;
  __pyx_v_U = ((PyArrayObject *)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "GPy/models/state_space_cython.pyx":792
 *     #(U,S,Vh)
 *     cdef np.ndarray[DTYPE_t, ndim=2] U = res[0]
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_svd = res[1]             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2]
 * 
 */
  __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_res, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 792, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 792, __pyx_L1_error)
  __pyx_t_17 = ((PyArrayObject *)__pyx_t_9);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S_svd.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_S_svd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S_svd.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 792, __pyx_L1_error)
    } else {__pyx_pybuffernd_S_svd.diminfo[0].strides = __pyx_pybuffernd_S_svd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S_svd.diminfo[0].shape = __pyx_pybuffernd_S_svd.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_17 = 0;
  __pyx_v_S_svd = ((PyArrayObject *)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "GPy/models/state_space_cython.pyx":793
 *     cdef np.ndarray[DTYPE_t, ndim=2] U = res[0]
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_svd = res[1]
 *     cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2]             # <<<<<<<<<<<<<<
 * 
 *      # P_upd = U_upd S_upd**2 U_upd.T
 */
  __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_res, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 793, __pyx_L1_error)
  __pyx_t_18 = ((PyArrayObject *)__pyx_t_9);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_Vh = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Vh.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 793, __pyx_L1_error)
    } else {__pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_18 = 0;
  __pyx_v_Vh = ((PyArrayObject *)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "GPy/models/state_space_cython.pyx":796
 * 
 *      # P_upd = U_upd S_upd**2 U_upd.T
 *     cdef np.ndarray[DTYPE_t, ndim=2] U_upd = np.dot(V_pred, Vh.T)             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_upd = (1.0/S_svd)**2
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Vh), __pyx_n_s_T); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_5 = NULL;
  __pyx_t_13 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
      __pyx_t_13 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_V_pred), __pyx_t_10};
    __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 796, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_V_pred), __pyx_t_10};
    __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 796, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  {
    __pyx_t_1 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 796, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_V_pred));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_V_pred));
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_13, ((PyObject *)__pyx_v_V_pred));
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_13, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 796, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 796, __pyx_L1_error)
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_9);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_U_upd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_U_upd.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 796, __pyx_L1_error)
    } else {__pyx_pybuffernd_U_upd.diminfo[0].strides = __pyx_pybuffernd_U_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U_upd.diminfo[0].shape = __pyx_pybuffernd_U_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U_upd.diminfo[1].strides = __pyx_pybuffernd_U_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U_upd.diminfo[1].shape = __pyx_pybuffernd_U_upd.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_19 = 0;
  __pyx_v_U_upd = ((PyArrayObject *)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "GPy/models/state_space_cython.pyx":797
 *      # P_upd = U_upd S_upd**2 U_upd.T
 *     cdef np.ndarray[DTYPE_t, ndim=2] U_upd = np.dot(V_pred, Vh.T)
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_upd = (1.0/S_svd)**2             # <<<<<<<<<<<<<<
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] P_upd = np.dot(U_upd * S_upd, U_upd.T) # update covariance
 */
  __pyx_t_9 = __Pyx_PyNumber_Divide(__pyx_float_1_0, ((PyObject *)__pyx_v_S_svd)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 797, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_7 = PyNumber_Power(__pyx_t_9, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 797, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 797, __pyx_L1_error)
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_7);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_S_upd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S_upd.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 797, __pyx_L1_error)
    } else {__pyx_pybuffernd_S_upd.diminfo[0].strides = __pyx_pybuffernd_S_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S_upd.diminfo[0].shape = __pyx_pybuffernd_S_upd.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_20 = 0;
  __pyx_v_S_upd = ((PyArrayObject *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "GPy/models/state_space_cython.pyx":799
 *     cdef np.ndarray[DTYPE_t, ndim=1] S_upd = (1.0/S_svd)**2
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] P_upd = np.dot(U_upd * S_upd, U_upd.T) # update covariance             # <<<<<<<<<<<<<<
 *     #P_upd = (P_upd,S_upd,U_upd) # tuple to pass to the next step
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 799, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 799, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyNumber_Multiply(((PyObject *)__pyx_v_U_upd), ((PyObject *)__pyx_v_S_upd)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 799, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_U_upd), __pyx_n_s_T); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 799, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_5 = NULL;
  __pyx_t_13 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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);
      __pyx_t_13 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_9, __pyx_t_10};
    __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 799, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_9, __pyx_t_10};
    __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 799, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 799, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_13, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_13, __pyx_t_10);
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 799, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 799, __pyx_L1_error)
  __pyx_t_21 = ((PyArrayObject *)__pyx_t_7);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_21, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_P_upd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_P_upd.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 799, __pyx_L1_error)
    } else {__pyx_pybuffernd_P_upd.diminfo[0].strides = __pyx_pybuffernd_P_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_upd.diminfo[0].shape = __pyx_pybuffernd_P_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_upd.diminfo[1].strides = __pyx_pybuffernd_P_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_upd.diminfo[1].shape = __pyx_pybuffernd_P_upd.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_21 = 0;
  __pyx_v_P_upd = ((PyArrayObject *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "GPy/models/state_space_cython.pyx":803
 * 
 *      # stil need to compute S and K for derivative computation
 *     cdef np.ndarray[DTYPE_t, ndim=2] S = H.dot(P_pred).dot(H.T) + R             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=2] K
 *     cdef bint measurement_dim_gt_one = False
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_dot); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_10, ((PyObject *)__pyx_v_P_pred)) : __Pyx_PyObject_CallOneArg(__pyx_t_12, ((PyObject *)__pyx_v_P_pred));
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dot); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_T); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  __pyx_t_7 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_10, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_v_R)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 803, __pyx_L1_error)
  __pyx_t_22 = ((PyArrayObject *)__pyx_t_12);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_22, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_S = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 803, __pyx_L1_error)
    } else {__pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_S.diminfo[1].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_S.diminfo[1].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_22 = 0;
  __pyx_v_S = ((PyArrayObject *)__pyx_t_12);
  __pyx_t_12 = 0;

  /* "GPy/models/state_space_cython.pyx":805
 *     cdef np.ndarray[DTYPE_t, ndim=2] S = H.dot(P_pred).dot(H.T) + R
 *     cdef np.ndarray[DTYPE_t, ndim=2] K
 *     cdef bint measurement_dim_gt_one = False             # <<<<<<<<<<<<<<
 *     if measurement.shape[0]==1: # measurements are one dimensional
 *         if (S < 0):
 */
  __pyx_v_measurement_dim_gt_one = 0;

  /* "GPy/models/state_space_cython.pyx":806
 *     cdef np.ndarray[DTYPE_t, ndim=2] K
 *     cdef bint measurement_dim_gt_one = False
 *     if measurement.shape[0]==1: # measurements are one dimensional             # <<<<<<<<<<<<<<
 *         if (S < 0):
 *             raise ValueError("Kalman Filter Update SVD: S is negative step %i" % k )
 */
  __pyx_t_23 = (((__pyx_v_measurement->dimensions[0]) == 1) != 0);
  if (likely(__pyx_t_23)) {

    /* "GPy/models/state_space_cython.pyx":807
 *     cdef bint measurement_dim_gt_one = False
 *     if measurement.shape[0]==1: # measurements are one dimensional
 *         if (S < 0):             # <<<<<<<<<<<<<<
 *             raise ValueError("Kalman Filter Update SVD: S is negative step %i" % k )
 *             #import pdb; pdb.set_trace()
 */
    __pyx_t_12 = PyObject_RichCompare(((PyObject *)__pyx_v_S), __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 807, __pyx_L1_error)
    __pyx_t_23 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 807, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (unlikely(__pyx_t_23)) {

      /* "GPy/models/state_space_cython.pyx":808
 *     if measurement.shape[0]==1: # measurements are one dimensional
 *         if (S < 0):
 *             raise ValueError("Kalman Filter Update SVD: S is negative step %i" % k )             # <<<<<<<<<<<<<<
 *             #import pdb; pdb.set_trace()
 * 
 */
      __pyx_t_12 = __Pyx_PyInt_From_long(__pyx_v_k); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 808, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Kalman_Filter_Update_SVD_S_is_ne, __pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 808, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 808, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_12, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __PYX_ERR(0, 808, __pyx_L1_error)

      /* "GPy/models/state_space_cython.pyx":807
 *     cdef bint measurement_dim_gt_one = False
 *     if measurement.shape[0]==1: # measurements are one dimensional
 *         if (S < 0):             # <<<<<<<<<<<<<<
 *             raise ValueError("Kalman Filter Update SVD: S is negative step %i" % k )
 *             #import pdb; pdb.set_trace()
 */
    }

    /* "GPy/models/state_space_cython.pyx":811
 *             #import pdb; pdb.set_trace()
 * 
 *         K = P_pred.dot(H.T) / S             # <<<<<<<<<<<<<<
 *         if calc_log_likelihood:
 *             log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) +
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_P_pred), __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_T); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_12 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_10, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyNumber_Divide(__pyx_t_12, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 811, __pyx_L1_error)
    __pyx_t_24 = ((PyArrayObject *)__pyx_t_7);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_K.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_K.rcbuffer->pybuffer, (PyObject*)__pyx_t_24, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_K.rcbuffer->pybuffer, (PyObject*)__pyx_v_K, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
        }
        __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
      }
      __pyx_pybuffernd_K.diminfo[0].strides = __pyx_pybuffernd_K.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_K.diminfo[0].shape = __pyx_pybuffernd_K.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_K.diminfo[1].strides = __pyx_pybuffernd_K.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_K.diminfo[1].shape = __pyx_pybuffernd_K.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 811, __pyx_L1_error)
    }
    __pyx_t_24 = 0;
    __pyx_v_K = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "GPy/models/state_space_cython.pyx":812
 * 
 *         K = P_pred.dot(H.T) / S
 *         if calc_log_likelihood:             # <<<<<<<<<<<<<<
 *             log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) +
 *                                  v*v / S)
 */
    __pyx_t_23 = (__pyx_v_calc_log_likelihood != 0);
    if (__pyx_t_23) {

      /* "GPy/models/state_space_cython.pyx":813
 *         K = P_pred.dot(H.T) / S
 *         if calc_log_likelihood:
 *             log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) +             # <<<<<<<<<<<<<<
 *                                  v*v / S)
 *             #log_likelihood_update = log_likelihood_update[0,0] # to make int
 */
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_pi); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyNumber_Multiply(__pyx_int_2, __pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_7 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_10, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_12);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_log); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_12, ((PyObject *)__pyx_v_S)) : __Pyx_PyObject_CallOneArg(__pyx_t_10, ((PyObject *)__pyx_v_S));
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyNumber_Add(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "GPy/models/state_space_cython.pyx":814
 *         if calc_log_likelihood:
 *             log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) +
 *                                  v*v / S)             # <<<<<<<<<<<<<<
 *             #log_likelihood_update = log_likelihood_update[0,0] # to make int
 *             if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None.
 */
      __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_v), ((PyObject *)__pyx_v_v)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 814, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __Pyx_PyNumber_Divide(__pyx_t_1, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 814, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "GPy/models/state_space_cython.pyx":813
 *         K = P_pred.dot(H.T) / S
 *         if calc_log_likelihood:
 *             log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) +             # <<<<<<<<<<<<<<
 *                                  v*v / S)
 *             #log_likelihood_update = log_likelihood_update[0,0] # to make int
 */
      __pyx_t_1 = PyNumber_Add(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyNumber_Multiply(__pyx_float_neg_0_5, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 813, __pyx_L1_error)
      __pyx_t_28 = ((PyArrayObject *)__pyx_t_7);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer);
        __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_13 < 0)) {
          PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
          }
          __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
        }
        __pyx_pybuffernd_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 813, __pyx_L1_error)
      }
      __pyx_t_28 = 0;
      __pyx_v_log_likelihood_update = ((PyArrayObject *)__pyx_t_7);
      __pyx_t_7 = 0;

      /* "GPy/models/state_space_cython.pyx":816
 *                                  v*v / S)
 *             #log_likelihood_update = log_likelihood_update[0,0] # to make int
 *             if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None.             # <<<<<<<<<<<<<<
 *                 raise ValueError("Nan values in likelihood update!")
 *         else:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_any); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_isnan); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_12, ((PyObject *)__pyx_v_log_likelihood_update)) : __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)__pyx_v_log_likelihood_update));
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_9, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_23 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__pyx_t_23)) {

        /* "GPy/models/state_space_cython.pyx":817
 *             #log_likelihood_update = log_likelihood_update[0,0] # to make int
 *             if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None.
 *                 raise ValueError("Nan values in likelihood update!")             # <<<<<<<<<<<<<<
 *         else:
 *             log_likelihood_update = None
 */
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 817, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(0, 817, __pyx_L1_error)

        /* "GPy/models/state_space_cython.pyx":816
 *                                  v*v / S)
 *             #log_likelihood_update = log_likelihood_update[0,0] # to make int
 *             if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None.             # <<<<<<<<<<<<<<
 *                 raise ValueError("Nan values in likelihood update!")
 *         else:
 */
      }

      /* "GPy/models/state_space_cython.pyx":812
 * 
 *         K = P_pred.dot(H.T) / S
 *         if calc_log_likelihood:             # <<<<<<<<<<<<<<
 *             log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) +
 *                                  v*v / S)
 */
      goto __pyx_L5;
    }

    /* "GPy/models/state_space_cython.pyx":819
 *                 raise ValueError("Nan values in likelihood update!")
 *         else:
 *             log_likelihood_update = None             # <<<<<<<<<<<<<<
 *         #LL = None; islower = None
 *     else:
 */
    /*else*/ {
      __pyx_t_28 = ((PyArrayObject *)Py_None);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer);
        __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_13 < 0)) {
          PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
          }
          __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
        }
        __pyx_pybuffernd_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 819, __pyx_L1_error)
      }
      __pyx_t_28 = 0;
      __Pyx_INCREF(Py_None);
      __pyx_v_log_likelihood_update = ((PyArrayObject *)Py_None);
    }
    __pyx_L5:;

    /* "GPy/models/state_space_cython.pyx":806
 *     cdef np.ndarray[DTYPE_t, ndim=2] K
 *     cdef bint measurement_dim_gt_one = False
 *     if measurement.shape[0]==1: # measurements are one dimensional             # <<<<<<<<<<<<<<
 *         if (S < 0):
 *             raise ValueError("Kalman Filter Update SVD: S is negative step %i" % k )
 */
    goto __pyx_L3;
  }

  /* "GPy/models/state_space_cython.pyx":822
 *         #LL = None; islower = None
 *     else:
 *         measurement_dim_gt_one = True             # <<<<<<<<<<<<<<
 *         raise ValueError("""Measurement dimension larger then 1 is currently not supported""")
 * 
 */
  /*else*/ {
    __pyx_v_measurement_dim_gt_one = 1;

    /* "GPy/models/state_space_cython.pyx":823
 *     else:
 *         measurement_dim_gt_one = True
 *         raise ValueError("""Measurement dimension larger then 1 is currently not supported""")             # <<<<<<<<<<<<<<
 * 
 *     # Old  method of computing updated covariance (for testing) ->
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __PYX_ERR(0, 823, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "GPy/models/state_space_cython.pyx":846
 *     cdef tuple ret
 * 
 *     if calc_grad_log_likelihood:             # <<<<<<<<<<<<<<
 *         dm_pred_all_params = p_dm # derivativas of the prediction phase
 *         dP_pred_all_params = p_dP
 */
  __pyx_t_23 = (__pyx_v_calc_grad_log_likelihood != 0);
  if (__pyx_t_23) {

    /* "GPy/models/state_space_cython.pyx":847
 * 
 *     if calc_grad_log_likelihood:
 *         dm_pred_all_params = p_dm # derivativas of the prediction phase             # <<<<<<<<<<<<<<
 *         dP_pred_all_params = p_dP
 * 
 */
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_p_dm), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_pred_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
        }
        __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
      }
      __pyx_pybuffernd_dm_pred_all_params.diminfo[0].strides = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_pred_all_params.diminfo[0].shape = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_pred_all_params.diminfo[1].strides = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_pred_all_params.diminfo[1].shape = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_pred_all_params.diminfo[2].strides = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_pred_all_params.diminfo[2].shape = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 847, __pyx_L1_error)
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_p_dm));
    __pyx_v_dm_pred_all_params = ((PyArrayObject *)__pyx_v_p_dm);

    /* "GPy/models/state_space_cython.pyx":848
 *     if calc_grad_log_likelihood:
 *         dm_pred_all_params = p_dm # derivativas of the prediction phase
 *         dP_pred_all_params = p_dP             # <<<<<<<<<<<<<<
 * 
 *         param_number = p_dP.shape[2]
 */
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_p_dP), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_pred_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
        }
        __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
      }
      __pyx_pybuffernd_dP_pred_all_params.diminfo[0].strides = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_pred_all_params.diminfo[0].shape = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_pred_all_params.diminfo[1].strides = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_pred_all_params.diminfo[1].shape = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_pred_all_params.diminfo[2].strides = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_pred_all_params.diminfo[2].shape = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 848, __pyx_L1_error)
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_p_dP));
    __pyx_v_dP_pred_all_params = ((PyArrayObject *)__pyx_v_p_dP);

    /* "GPy/models/state_space_cython.pyx":850
 *         dP_pred_all_params = p_dP
 * 
 *         param_number = p_dP.shape[2]             # <<<<<<<<<<<<<<
 * 
 *         dH_all_params = p_measurement_callables.dHk(k)
 */
    __pyx_v_param_number = (__pyx_v_p_dP->dimensions[2]);

    /* "GPy/models/state_space_cython.pyx":852
 *         param_number = p_dP.shape[2]
 * 
 *         dH_all_params = p_measurement_callables.dHk(k)             # <<<<<<<<<<<<<<
 *         dR_all_params = p_measurement_callables.dRk(k)
 * 
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->dHk(__pyx_v_p_measurement_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 852, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 852, __pyx_L1_error)
    __pyx_t_29 = ((PyArrayObject *)__pyx_t_7);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dH_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
        }
        __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
      }
      __pyx_pybuffernd_dH_all_params.diminfo[0].strides = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dH_all_params.diminfo[0].shape = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dH_all_params.diminfo[1].strides = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dH_all_params.diminfo[1].shape = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dH_all_params.diminfo[2].strides = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dH_all_params.diminfo[2].shape = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 852, __pyx_L1_error)
    }
    __pyx_t_29 = 0;
    __pyx_v_dH_all_params = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "GPy/models/state_space_cython.pyx":853
 * 
 *         dH_all_params = p_measurement_callables.dHk(k)
 *         dR_all_params = p_measurement_callables.dRk(k)             # <<<<<<<<<<<<<<
 * 
 *         dm_upd = np.empty((dm_pred_all_params.shape[0], dm_pred_all_params.shape[1], dm_pred_all_params.shape[2]), dtype = DTYPE)
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->dRk(__pyx_v_p_measurement_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 853, __pyx_L1_error)
    __pyx_t_30 = ((PyArrayObject *)__pyx_t_7);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_t_30, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dR_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
        }
        __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
      }
      __pyx_pybuffernd_dR_all_params.diminfo[0].strides = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dR_all_params.diminfo[0].shape = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dR_all_params.diminfo[1].strides = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dR_all_params.diminfo[1].shape = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dR_all_params.diminfo[2].strides = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dR_all_params.diminfo[2].shape = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 853, __pyx_L1_error)
    }
    __pyx_t_30 = 0;
    __pyx_v_dR_all_params = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "GPy/models/state_space_cython.pyx":855
 *         dR_all_params = p_measurement_callables.dRk(k)
 * 
 *         dm_upd = np.empty((dm_pred_all_params.shape[0], dm_pred_all_params.shape[1], dm_pred_all_params.shape[2]), dtype = DTYPE)             # <<<<<<<<<<<<<<
 *         dP_upd = np.empty((dP_pred_all_params.shape[0], dP_pred_all_params.shape[1], dP_pred_all_params.shape[2]), dtype = DTYPE)
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_empty); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dm_pred_all_params->dimensions[0])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dm_pred_all_params->dimensions[1])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dm_pred_all_params->dimensions[2])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_9);
    __pyx_t_7 = 0;
    __pyx_t_1 = 0;
    __pyx_t_9 = 0;
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 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_ERR(0, 855, __pyx_L1_error)
    __pyx_t_31 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_31, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
        }
        __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
      }
      __pyx_pybuffernd_dm_upd.diminfo[0].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_upd.diminfo[0].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_upd.diminfo[1].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_upd.diminfo[1].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_upd.diminfo[2].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_upd.diminfo[2].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 855, __pyx_L1_error)
    }
    __pyx_t_31 = 0;
    __pyx_v_dm_upd = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "GPy/models/state_space_cython.pyx":856
 * 
 *         dm_upd = np.empty((dm_pred_all_params.shape[0], dm_pred_all_params.shape[1], dm_pred_all_params.shape[2]), dtype = DTYPE)
 *         dP_upd = np.empty((dP_pred_all_params.shape[0], dP_pred_all_params.shape[1], dP_pred_all_params.shape[2]), dtype = DTYPE)             # <<<<<<<<<<<<<<
 * 
 *          # firts dimension parameter_no, second - time series number
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dP_pred_all_params->dimensions[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dP_pred_all_params->dimensions[1])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dP_pred_all_params->dimensions[2])); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_10);
    __pyx_t_1 = 0;
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 856, __pyx_L1_error)
    __pyx_t_32 = ((PyArrayObject *)__pyx_t_9);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_32, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
        }
        __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
      }
      __pyx_pybuffernd_dP_upd.diminfo[0].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_upd.diminfo[0].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_upd.diminfo[1].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_upd.diminfo[1].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_upd.diminfo[2].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_upd.diminfo[2].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 856, __pyx_L1_error)
    }
    __pyx_t_32 = 0;
    __pyx_v_dP_upd = ((PyArrayObject *)__pyx_t_9);
    __pyx_t_9 = 0;

    /* "GPy/models/state_space_cython.pyx":859
 * 
 *          # firts dimension parameter_no, second - time series number
 *         d_log_likelihood_update = np.empty((param_number,time_series_no), dtype = DTYPE)             # <<<<<<<<<<<<<<
 *         for param in range(param_number):
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_empty); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_param_number); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_time_series_no); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_10);
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 859, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 859, __pyx_L1_error)
    __pyx_t_33 = ((PyArrayObject *)__pyx_t_9);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_33, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_d_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
        }
        __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
      }
      __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 859, __pyx_L1_error)
    }
    __pyx_t_33 = 0;
    __pyx_v_d_log_likelihood_update = ((PyArrayObject *)__pyx_t_9);
    __pyx_t_9 = 0;

    /* "GPy/models/state_space_cython.pyx":860
 *          # firts dimension parameter_no, second - time series number
 *         d_log_likelihood_update = np.empty((param_number,time_series_no), dtype = DTYPE)
 *         for param in range(param_number):             # <<<<<<<<<<<<<<
 * 
 *            dH = dH_all_params[:,:,param]
 */
    __pyx_t_13 = __pyx_v_param_number;
    __pyx_t_34 = __pyx_t_13;
    for (__pyx_t_35 = 0; __pyx_t_35 < __pyx_t_34; __pyx_t_35+=1) {
      __pyx_v_param = __pyx_t_35;

      /* "GPy/models/state_space_cython.pyx":862
 *         for param in range(param_number):
 * 
 *            dH = dH_all_params[:,:,param]             # <<<<<<<<<<<<<<
 *            dR = dR_all_params[:,:,param]
 * 
 */
      __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 862, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 862, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dH_all_params), __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 862, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 862, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_9);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dH.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dH.rcbuffer->pybuffer, (PyObject*)__pyx_v_dH, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
          }
          __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
        }
        __pyx_pybuffernd_dH.diminfo[0].strides = __pyx_pybuffernd_dH.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dH.diminfo[0].shape = __pyx_pybuffernd_dH.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dH.diminfo[1].strides = __pyx_pybuffernd_dH.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dH.diminfo[1].shape = __pyx_pybuffernd_dH.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 862, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dH, ((PyArrayObject *)__pyx_t_9));
      __pyx_t_9 = 0;

      /* "GPy/models/state_space_cython.pyx":863
 * 
 *            dH = dH_all_params[:,:,param]
 *            dR = dR_all_params[:,:,param]             # <<<<<<<<<<<<<<
 * 
 *            dm_pred = dm_pred_all_params[:,:,param]
 */
      __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 863, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 863, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dR_all_params), __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 863, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 863, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_9);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR.rcbuffer->pybuffer, (PyObject*)__pyx_v_dR, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
          }
          __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
        }
        __pyx_pybuffernd_dR.diminfo[0].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dR.diminfo[0].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dR.diminfo[1].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dR.diminfo[1].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 863, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dR, ((PyArrayObject *)__pyx_t_9));
      __pyx_t_9 = 0;

      /* "GPy/models/state_space_cython.pyx":865
 *            dR = dR_all_params[:,:,param]
 * 
 *            dm_pred = dm_pred_all_params[:,:,param]             # <<<<<<<<<<<<<<
 *            dP_pred = dP_pred_all_params[:,:,param]
 * 
 */
      __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 865, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 865, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dm_pred_all_params), __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 865, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 865, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_9);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
          }
          __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
        }
        __pyx_pybuffernd_dm_pred.diminfo[0].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_pred.diminfo[0].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_pred.diminfo[1].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_pred.diminfo[1].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 865, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dm_pred, ((PyArrayObject *)__pyx_t_9));
      __pyx_t_9 = 0;

      /* "GPy/models/state_space_cython.pyx":866
 * 
 *            dm_pred = dm_pred_all_params[:,:,param]
 *            dP_pred = dP_pred_all_params[:,:,param]             # <<<<<<<<<<<<<<
 * 
 *             # Terms in the likelihood derivatives
 */
      __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 866, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 866, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dP_pred_all_params), __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 866, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 866, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_9);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
          }
          __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
        }
        __pyx_pybuffernd_dP_pred.diminfo[0].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_pred.diminfo[0].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_pred.diminfo[1].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_pred.diminfo[1].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 866, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dP_pred, ((PyArrayObject *)__pyx_t_9));
      __pyx_t_9 = 0;

      /* "GPy/models/state_space_cython.pyx":869
 * 
 *             # Terms in the likelihood derivatives
 *            dv = - np.dot( dH, m_pred) -  np.dot( H, dm_pred)             # <<<<<<<<<<<<<<
 *            dS = np.dot(dH, np.dot( P_pred, H.T))
 *            dS += dS.T
 */
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 869, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_dot); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 869, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_dH), ((PyObject *)__pyx_v_m_pred)};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 869, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_dH), ((PyObject *)__pyx_v_m_pred)};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 869, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 869, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__pyx_t_12) {
          __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_12); __pyx_t_12 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dH));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dH));
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_37, ((PyObject *)__pyx_v_dH));
        __Pyx_INCREF(((PyObject *)__pyx_v_m_pred));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred));
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_37, ((PyObject *)__pyx_v_m_pred));
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_7, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 869, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyNumber_Negative(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 869, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 869, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dot); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 869, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_H), ((PyObject *)__pyx_v_dm_pred)};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 869, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_H), ((PyObject *)__pyx_v_dm_pred)};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 869, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      {
        __pyx_t_1 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 869, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_H));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_H));
        PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_37, ((PyObject *)__pyx_v_H));
        __Pyx_INCREF(((PyObject *)__pyx_v_dm_pred));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dm_pred));
        PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_37, ((PyObject *)__pyx_v_dm_pred));
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_1, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 869, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyNumber_Subtract(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 869, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 869, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_12);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dv.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dv.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dv.rcbuffer->pybuffer, (PyObject*)__pyx_v_dv, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
          }
          __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
        }
        __pyx_pybuffernd_dv.diminfo[0].strides = __pyx_pybuffernd_dv.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dv.diminfo[0].shape = __pyx_pybuffernd_dv.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dv.diminfo[1].strides = __pyx_pybuffernd_dv.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dv.diminfo[1].shape = __pyx_pybuffernd_dv.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 869, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dv, ((PyArrayObject *)__pyx_t_12));
      __pyx_t_12 = 0;

      /* "GPy/models/state_space_cython.pyx":870
 *             # Terms in the likelihood derivatives
 *            dv = - np.dot( dH, m_pred) -  np.dot( H, dm_pred)
 *            dS = np.dot(dH, np.dot( P_pred, H.T))             # <<<<<<<<<<<<<<
 *            dS += dS.T
 *            dS += np.dot(H, np.dot( dP_pred, H.T)) + dR
 */
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_T); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_P_pred), __pyx_t_1};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 870, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_P_pred), __pyx_t_1};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 870, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      {
        __pyx_t_14 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 870, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_P_pred));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred));
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_37, ((PyObject *)__pyx_v_P_pred));
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_37, __pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 870, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_dH), __pyx_t_9};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 870, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_dH), __pyx_t_9};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 870, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_14 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 870, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dH));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dH));
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_37, ((PyObject *)__pyx_v_dH));
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_37, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 870, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 870, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_12);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
          }
          __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
        }
        __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dS.diminfo[1].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dS.diminfo[1].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 870, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dS, ((PyArrayObject *)__pyx_t_12));
      __pyx_t_12 = 0;

      /* "GPy/models/state_space_cython.pyx":871
 *            dv = - np.dot( dH, m_pred) -  np.dot( H, dm_pred)
 *            dS = np.dot(dH, np.dot( P_pred, H.T))
 *            dS += dS.T             # <<<<<<<<<<<<<<
 *            dS += np.dot(H, np.dot( dP_pred, H.T)) + dR
 * 
 */
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dS), __pyx_n_s_T); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 871, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_10 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_dS), __pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 871, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 871, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_10);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
          }
          __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
        }
        __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dS.diminfo[1].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dS.diminfo[1].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 871, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_DECREF_SET(__pyx_v_dS, ((PyArrayObject *)__pyx_t_10));
      __pyx_t_10 = 0;

      /* "GPy/models/state_space_cython.pyx":872
 *            dS = np.dot(dH, np.dot( P_pred, H.T))
 *            dS += dS.T
 *            dS += np.dot(H, np.dot( dP_pred, H.T)) + dR             # <<<<<<<<<<<<<<
 * 
 *             # TODO: maybe symmetrize dS
 */
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_dot); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_T); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_dP_pred), __pyx_t_9};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 872, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_dP_pred), __pyx_t_9};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 872, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 872, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__pyx_t_1) {
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dP_pred));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dP_pred));
        PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_37, ((PyObject *)__pyx_v_dP_pred));
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_37, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 872, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_14);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_14, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_14)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_H), __pyx_t_12};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 872, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_H), __pyx_t_12};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 872, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 872, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_H));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_H));
        PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_37, ((PyObject *)__pyx_v_H));
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_37, __pyx_t_12);
        __pyx_t_12 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_5, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 872, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = PyNumber_Add(__pyx_t_10, ((PyObject *)__pyx_v_dR)); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_dS), __pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 872, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_10);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
          }
          __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
        }
        __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dS.diminfo[1].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dS.diminfo[1].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 872, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_DECREF_SET(__pyx_v_dS, ((PyArrayObject *)__pyx_t_10));
      __pyx_t_10 = 0;

      /* "GPy/models/state_space_cython.pyx":876
 *             # TODO: maybe symmetrize dS
 * 
 *            tmp1 = H.T / S             # <<<<<<<<<<<<<<
 *            tmp2 = dH.T / S
 *            tmp3 = dS.T / S
 */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_T); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 876, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_14 = __Pyx_PyNumber_Divide(__pyx_t_10, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 876, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (!(likely(((__pyx_t_14) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_14, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 876, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_14);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp1.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp1.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp1.rcbuffer->pybuffer, (PyObject*)__pyx_v_tmp1, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
          }
          __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
        }
        __pyx_pybuffernd_tmp1.diminfo[0].strides = __pyx_pybuffernd_tmp1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tmp1.diminfo[0].shape = __pyx_pybuffernd_tmp1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_tmp1.diminfo[1].strides = __pyx_pybuffernd_tmp1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_tmp1.diminfo[1].shape = __pyx_pybuffernd_tmp1.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 876, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_XDECREF_SET(__pyx_v_tmp1, ((PyArrayObject *)__pyx_t_14));
      __pyx_t_14 = 0;

      /* "GPy/models/state_space_cython.pyx":877
 * 
 *            tmp1 = H.T / S
 *            tmp2 = dH.T / S             # <<<<<<<<<<<<<<
 *            tmp3 = dS.T / S
 * 
 */
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dH), __pyx_n_s_T); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 877, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_14, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 877, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 877, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_10);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp2.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp2.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp2.rcbuffer->pybuffer, (PyObject*)__pyx_v_tmp2, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
          }
          __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
        }
        __pyx_pybuffernd_tmp2.diminfo[0].strides = __pyx_pybuffernd_tmp2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tmp2.diminfo[0].shape = __pyx_pybuffernd_tmp2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_tmp2.diminfo[1].strides = __pyx_pybuffernd_tmp2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_tmp2.diminfo[1].shape = __pyx_pybuffernd_tmp2.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 877, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_XDECREF_SET(__pyx_v_tmp2, ((PyArrayObject *)__pyx_t_10));
      __pyx_t_10 = 0;

      /* "GPy/models/state_space_cython.pyx":878
 *            tmp1 = H.T / S
 *            tmp2 = dH.T / S
 *            tmp3 = dS.T / S             # <<<<<<<<<<<<<<
 * 
 *            dK = np.dot( dP_pred, tmp1) + np.dot( P_pred, tmp2) - \
 */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dS), __pyx_n_s_T); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 878, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_14 = __Pyx_PyNumber_Divide(__pyx_t_10, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 878, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (!(likely(((__pyx_t_14) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_14, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 878, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_14);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp3.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp3.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp3.rcbuffer->pybuffer, (PyObject*)__pyx_v_tmp3, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
          }
          __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
        }
        __pyx_pybuffernd_tmp3.diminfo[0].strides = __pyx_pybuffernd_tmp3.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tmp3.diminfo[0].shape = __pyx_pybuffernd_tmp3.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_tmp3.diminfo[1].strides = __pyx_pybuffernd_tmp3.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_tmp3.diminfo[1].shape = __pyx_pybuffernd_tmp3.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 878, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_XDECREF_SET(__pyx_v_tmp3, ((PyArrayObject *)__pyx_t_14));
      __pyx_t_14 = 0;

      /* "GPy/models/state_space_cython.pyx":880
 *            tmp3 = dS.T / S
 * 
 *            dK = np.dot( dP_pred, tmp1) + np.dot( P_pred, tmp2) - \             # <<<<<<<<<<<<<<
 *                 np.dot( P_pred, np.dot( tmp1, tmp3 ) )
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 880, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dot); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 880, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_dP_pred), ((PyObject *)__pyx_v_tmp1)};
        __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 880, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_14);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_dP_pred), ((PyObject *)__pyx_v_tmp1)};
        __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 880, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_14);
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 880, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dP_pred));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dP_pred));
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_37, ((PyObject *)__pyx_v_dP_pred));
        __Pyx_INCREF(((PyObject *)__pyx_v_tmp1));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp1));
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_37, ((PyObject *)__pyx_v_tmp1));
        __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 880, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 880, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_dot); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 880, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_P_pred), ((PyObject *)__pyx_v_tmp2)};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 880, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_P_pred), ((PyObject *)__pyx_v_tmp2)};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 880, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 880, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__pyx_t_12) {
          __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_12); __pyx_t_12 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_P_pred));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred));
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_37, ((PyObject *)__pyx_v_P_pred));
        __Pyx_INCREF(((PyObject *)__pyx_v_tmp2));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp2));
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_37, ((PyObject *)__pyx_v_tmp2));
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 880, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyNumber_Add(__pyx_t_14, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 880, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "GPy/models/state_space_cython.pyx":881
 * 
 *            dK = np.dot( dP_pred, tmp1) + np.dot( P_pred, tmp2) - \
 *                 np.dot( P_pred, np.dot( tmp1, tmp3 ) )             # <<<<<<<<<<<<<<
 * 
 *             # terms required for the next step, save this for each parameter
 */
      __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_dot); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_tmp1), ((PyObject *)__pyx_v_tmp3)};
        __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 881, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_14);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_tmp1), ((PyObject *)__pyx_v_tmp3)};
        __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 881, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_14);
      } else
      #endif
      {
        __pyx_t_1 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 881, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (__pyx_t_12) {
          __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_12); __pyx_t_12 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_tmp1));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp1));
        PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_37, ((PyObject *)__pyx_v_tmp1));
        __Pyx_INCREF(((PyObject *)__pyx_v_tmp3));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp3));
        PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_37, ((PyObject *)__pyx_v_tmp3));
        __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_1, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 881, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, ((PyObject *)__pyx_v_P_pred), __pyx_t_14};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 881, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, ((PyObject *)__pyx_v_P_pred), __pyx_t_14};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 881, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      {
        __pyx_t_1 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 881, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (__pyx_t_9) {
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); __pyx_t_9 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_P_pred));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred));
        PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_37, ((PyObject *)__pyx_v_P_pred));
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_37, __pyx_t_14);
        __pyx_t_14 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 881, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "GPy/models/state_space_cython.pyx":880
 *            tmp3 = dS.T / S
 * 
 *            dK = np.dot( dP_pred, tmp1) + np.dot( P_pred, tmp2) - \             # <<<<<<<<<<<<<<
 *                 np.dot( P_pred, np.dot( tmp1, tmp3 ) )
 * 
 */
      __pyx_t_7 = PyNumber_Subtract(__pyx_t_10, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 880, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 880, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_7);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dK.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dK.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dK.rcbuffer->pybuffer, (PyObject*)__pyx_v_dK, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
          }
          __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
        }
        __pyx_pybuffernd_dK.diminfo[0].strides = __pyx_pybuffernd_dK.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dK.diminfo[0].shape = __pyx_pybuffernd_dK.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dK.diminfo[1].strides = __pyx_pybuffernd_dK.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dK.diminfo[1].shape = __pyx_pybuffernd_dK.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 880, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_XDECREF_SET(__pyx_v_dK, ((PyArrayObject *)__pyx_t_7));
      __pyx_t_7 = 0;

      /* "GPy/models/state_space_cython.pyx":884
 * 
 *             # terms required for the next step, save this for each parameter
 *            dm_upd[:,:,param] = dm_pred + np.dot(dK, v) + np.dot(K, dv)             # <<<<<<<<<<<<<<
 * 
 *            dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T))
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_dot); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_dK), ((PyObject *)__pyx_v_v)};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 884, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_dK), ((PyObject *)__pyx_v_v)};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 884, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else
      #endif
      {
        __pyx_t_1 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 884, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dK));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dK));
        PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_37, ((PyObject *)__pyx_v_dK));
        __Pyx_INCREF(((PyObject *)__pyx_v_v));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_v));
        PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_37, ((PyObject *)__pyx_v_v));
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 884, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyNumber_Add(((PyObject *)__pyx_v_dm_pred), __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dot); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_K), ((PyObject *)__pyx_v_dv)};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 884, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_K), ((PyObject *)__pyx_v_dv)};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 884, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else
      #endif
      {
        __pyx_t_14 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 884, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        if (__pyx_t_1) {
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); __pyx_t_1 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_K));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_K));
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_37, ((PyObject *)__pyx_v_K));
        __Pyx_INCREF(((PyObject *)__pyx_v_dv));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dv));
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_37, ((PyObject *)__pyx_v_dv));
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_14, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 884, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Add(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_7);
      __pyx_t_7 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dm_upd), __pyx_t_10, __pyx_t_5) < 0)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "GPy/models/state_space_cython.pyx":886
 *            dm_upd[:,:,param] = dm_pred + np.dot(dK, v) + np.dot(K, dv)
 * 
 *            dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T))             # <<<<<<<<<<<<<<
 *            dP_upd[:,:,param] += dP_upd[:,:,param].T
 *            dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T))
 */
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dot); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_K), __pyx_n_s_T); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_9 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, ((PyObject *)__pyx_v_S), __pyx_t_14};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 886, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, ((PyObject *)__pyx_v_S), __pyx_t_14};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 886, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 886, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_9) {
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_S));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_S));
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_37, ((PyObject *)__pyx_v_S));
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_37, __pyx_t_14);
        __pyx_t_14 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 886, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_dK), __pyx_t_10};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 886, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_dK), __pyx_t_10};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 886, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 886, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_1) {
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_1); __pyx_t_1 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dK));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dK));
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_37, ((PyObject *)__pyx_v_dK));
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_37, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 886, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyNumber_Negative(__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_5);
      __pyx_t_5 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_12, __pyx_t_7) < 0)) __PYX_ERR(0, 886, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "GPy/models/state_space_cython.pyx":887
 * 
 *            dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T))
 *            dP_upd[:,:,param] += dP_upd[:,:,param].T             # <<<<<<<<<<<<<<
 *            dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T))
 * 
 */
      __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 887, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 887, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 887, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 887, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 887, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 887, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_T); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 887, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 887, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_12, __pyx_t_5) < 0)) __PYX_ERR(0, 887, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "GPy/models/state_space_cython.pyx":888
 *            dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T))
 *            dP_upd[:,:,param] += dP_upd[:,:,param].T
 *            dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T))             # <<<<<<<<<<<<<<
 * 
 *            dP_upd[:,:,param] = 0.5*(dP_upd[:,:,param] + dP_upd[:,:,param].T) #symmetrize
 */
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_t_12 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dot); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_dot); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_K), __pyx_n_s_T); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_8 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_dS), __pyx_t_14};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 888, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_dS), __pyx_t_14};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 888, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 888, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        if (__pyx_t_8) {
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dS));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dS));
        PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_37, ((PyObject *)__pyx_v_dS));
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_37, __pyx_t_14);
        __pyx_t_14 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 888, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, ((PyObject *)__pyx_v_K), __pyx_t_7};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 888, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, ((PyObject *)__pyx_v_K), __pyx_t_7};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 888, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 888, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        if (__pyx_t_9) {
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_K));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_K));
        PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_37, ((PyObject *)__pyx_v_K));
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_37, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 888, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Subtract(((PyObject *)__pyx_v_dP_pred), __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_t_12, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_5, __pyx_t_10) < 0)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "GPy/models/state_space_cython.pyx":890
 *            dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T))
 * 
 *            dP_upd[:,:,param] = 0.5*(dP_upd[:,:,param] + dP_upd[:,:,param].T) #symmetrize             # <<<<<<<<<<<<<<
 *            # computing the likelihood change for each parameter:
 *            tmp5 = v / S
 */
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_T); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyNumber_Add(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Multiply(__pyx_float_0_5, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_slice__10);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_slice__10);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_10);
      __pyx_t_10 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_5, __pyx_t_1) < 0)) __PYX_ERR(0, 890, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "GPy/models/state_space_cython.pyx":892
 *            dP_upd[:,:,param] = 0.5*(dP_upd[:,:,param] + dP_upd[:,:,param].T) #symmetrize
 *            # computing the likelihood change for each parameter:
 *            tmp5 = v / S             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_1 = __Pyx_PyNumber_Divide(((PyObject *)__pyx_v_v), ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 892, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 892, __pyx_L1_error)
      __pyx_t_36 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp5.rcbuffer->pybuffer);
        __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp5.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_37 < 0)) {
          PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp5.rcbuffer->pybuffer, (PyObject*)__pyx_v_tmp5, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
          }
          __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
        }
        __pyx_pybuffernd_tmp5.diminfo[0].strides = __pyx_pybuffernd_tmp5.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tmp5.diminfo[0].shape = __pyx_pybuffernd_tmp5.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_tmp5.diminfo[1].strides = __pyx_pybuffernd_tmp5.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_tmp5.diminfo[1].shape = __pyx_pybuffernd_tmp5.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 892, __pyx_L1_error)
      }
      __pyx_t_36 = 0;
      __Pyx_XDECREF_SET(__pyx_v_tmp5, ((PyArrayObject *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "GPy/models/state_space_cython.pyx":895
 * 
 * 
 *            d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \             # <<<<<<<<<<<<<<
 *                np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) )
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sum); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_diag); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_5 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_12, ((PyObject *)__pyx_v_tmp3)) : __Pyx_PyObject_CallOneArg(__pyx_t_11, ((PyObject *)__pyx_v_tmp3));
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      __pyx_t_1 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_11, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyNumber_Multiply(__pyx_float_0_5, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "GPy/models/state_space_cython.pyx":896
 * 
 *            d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \
 *                np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) )             # <<<<<<<<<<<<<<
 * 
 *         # Compute the actual updates for mean of the states. Variance update
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_tmp5), ((PyObject *)__pyx_v_dv)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(0, 896, __pyx_L1_error)
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "GPy/models/state_space_cython.pyx":895
 * 
 * 
 *            d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \             # <<<<<<<<<<<<<<
 *                np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) )
 * 
 */
      __pyx_t_1 = PyNumber_Add(__pyx_t_10, __pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "GPy/models/state_space_cython.pyx":896
 * 
 *            d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \
 *                np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) )             # <<<<<<<<<<<<<<
 * 
 *         # Compute the actual updates for mean of the states. Variance update
 */
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_sum); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_dot); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      __pyx_t_37 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_37 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_dS), ((PyObject *)__pyx_v_tmp5)};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 896, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_12);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_dS), ((PyObject *)__pyx_v_tmp5)};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_37, 2+__pyx_t_37); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 896, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_12);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(2+__pyx_t_37); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 896, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__pyx_t_11) {
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_11); __pyx_t_11 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dS));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_dS));
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_37, ((PyObject *)__pyx_v_dS));
        __Pyx_INCREF(((PyObject *)__pyx_v_tmp5));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp5));
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_37, ((PyObject *)__pyx_v_tmp5));
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 896, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Multiply(((PyObject *)__pyx_v_tmp5), __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(0, 896, __pyx_L1_error)
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Multiply(__pyx_float_0_5, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyNumber_Subtract(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "GPy/models/state_space_cython.pyx":895
 * 
 * 
 *            d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \             # <<<<<<<<<<<<<<
 *                np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) )
 * 
 */
      __pyx_t_5 = PyNumber_Negative(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
      __Pyx_INCREF(__pyx_slice__10);
      __Pyx_GIVEREF(__pyx_slice__10);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__10);
      __pyx_t_7 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_d_log_likelihood_update), __pyx_t_1, __pyx_t_5) < 0)) __PYX_ERR(0, 895, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }

    /* "GPy/models/state_space_cython.pyx":846
 *     cdef tuple ret
 * 
 *     if calc_grad_log_likelihood:             # <<<<<<<<<<<<<<
 *         dm_pred_all_params = p_dm # derivativas of the prediction phase
 *         dP_pred_all_params = p_dP
 */
    goto __pyx_L7;
  }

  /* "GPy/models/state_space_cython.pyx":901
 *         # is computed earlier.
 *     else:
 *         dm_upd = None             # <<<<<<<<<<<<<<
 *         dP_upd = None
 *         d_log_likelihood_update = None
 */
  /*else*/ {
    __pyx_t_31 = ((PyArrayObject *)Py_None);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_31, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
        }
        __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
      }
      __pyx_pybuffernd_dm_upd.diminfo[0].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_upd.diminfo[0].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_upd.diminfo[1].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_upd.diminfo[1].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_upd.diminfo[2].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_upd.diminfo[2].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 901, __pyx_L1_error)
    }
    __pyx_t_31 = 0;
    __Pyx_INCREF(Py_None);
    __pyx_v_dm_upd = ((PyArrayObject *)Py_None);

    /* "GPy/models/state_space_cython.pyx":902
 *     else:
 *         dm_upd = None
 *         dP_upd = None             # <<<<<<<<<<<<<<
 *         d_log_likelihood_update = None
 * 
 */
    __pyx_t_32 = ((PyArrayObject *)Py_None);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_32, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_25, __pyx_t_26, __pyx_t_27);
        }
        __pyx_t_25 = __pyx_t_26 = __pyx_t_27 = 0;
      }
      __pyx_pybuffernd_dP_upd.diminfo[0].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_upd.diminfo[0].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_upd.diminfo[1].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_upd.diminfo[1].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_upd.diminfo[2].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_upd.diminfo[2].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 902, __pyx_L1_error)
    }
    __pyx_t_32 = 0;
    __Pyx_INCREF(Py_None);
    __pyx_v_dP_upd = ((PyArrayObject *)Py_None);

    /* "GPy/models/state_space_cython.pyx":903
 *         dm_upd = None
 *         dP_upd = None
 *         d_log_likelihood_update = None             # <<<<<<<<<<<<<<
 * 
 *     m_upd = m_pred + K.dot( v )
 */
    __pyx_t_33 = ((PyArrayObject *)Py_None);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_33, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_d_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_25);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_27, __pyx_t_26, __pyx_t_25);
        }
        __pyx_t_27 = __pyx_t_26 = __pyx_t_25 = 0;
      }
      __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 903, __pyx_L1_error)
    }
    __pyx_t_33 = 0;
    __Pyx_INCREF(Py_None);
    __pyx_v_d_log_likelihood_update = ((PyArrayObject *)Py_None);
  }
  __pyx_L7:;

  /* "GPy/models/state_space_cython.pyx":905
 *         d_log_likelihood_update = None
 * 
 *     m_upd = m_pred + K.dot( v )             # <<<<<<<<<<<<<<
 * 
 *     ret = (P_upd,S_upd,U_upd)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_K), __pyx_n_s_dot); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 905, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_7, ((PyObject *)__pyx_v_v)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_v));
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 905, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_v_m_pred), __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 905, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_m_upd = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":907
 *     m_upd = m_pred + K.dot( v )
 * 
 *     ret = (P_upd,S_upd,U_upd)             # <<<<<<<<<<<<<<
 *     return m_upd, ret, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update
 * 
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 907, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_P_upd));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_P_upd));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_P_upd));
  __Pyx_INCREF(((PyObject *)__pyx_v_S_upd));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_S_upd));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_S_upd));
  __Pyx_INCREF(((PyObject *)__pyx_v_U_upd));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_U_upd));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_U_upd));
  __pyx_v_ret = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":908
 * 
 *     ret = (P_upd,S_upd,U_upd)
 *     return m_upd, ret, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_m_upd);
  __Pyx_GIVEREF(__pyx_v_m_upd);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_m_upd);
  __Pyx_INCREF(__pyx_v_ret);
  __Pyx_GIVEREF(__pyx_v_ret);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ret);
  __Pyx_INCREF(((PyObject *)__pyx_v_log_likelihood_update));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_log_likelihood_update));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_log_likelihood_update));
  __Pyx_INCREF(((PyObject *)__pyx_v_dm_upd));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dm_upd));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_dm_upd));
  __Pyx_INCREF(((PyObject *)__pyx_v_dP_upd));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dP_upd));
  PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_v_dP_upd));
  __Pyx_INCREF(((PyObject *)__pyx_v_d_log_likelihood_update));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_d_log_likelihood_update));
  PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_v_d_log_likelihood_update));
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":686
 * 
 * @cython.boundscheck(False)
 * def _kalman_update_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m, tuple p_P,             # <<<<<<<<<<<<<<
 *                             Measurement_Callables_Cython p_measurement_callables,
 *                             np.ndarray[DTYPE_t, ndim=2] measurement,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_K.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_upd.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R_isr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_svd.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_upd.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U_upd.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dK.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dv.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_measurement.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp1.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp2.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp3.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp5.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_v.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython._kalman_update_step_SVD_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_K.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_upd.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R_isr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_svd.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_upd.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U_upd.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dK.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dv.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_measurement.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp1.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp2.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp3.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp5.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_v.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_m_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_P_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_S_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_V_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_H);
  __Pyx_XDECREF((PyObject *)__pyx_v_R);
  __Pyx_XDECREF((PyObject *)__pyx_v_R_isr);
  __Pyx_XDECREF((PyObject *)__pyx_v_log_likelihood_update);
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_XDECREF((PyObject *)__pyx_v_svd_2_matr);
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XDECREF((PyObject *)__pyx_v_U);
  __Pyx_XDECREF((PyObject *)__pyx_v_S_svd);
  __Pyx_XDECREF((PyObject *)__pyx_v_Vh);
  __Pyx_XDECREF((PyObject *)__pyx_v_U_upd);
  __Pyx_XDECREF((PyObject *)__pyx_v_S_upd);
  __Pyx_XDECREF((PyObject *)__pyx_v_P_upd);
  __Pyx_XDECREF((PyObject *)__pyx_v_S);
  __Pyx_XDECREF((PyObject *)__pyx_v_K);
  __Pyx_XDECREF((PyObject *)__pyx_v_dm_upd);
  __Pyx_XDECREF((PyObject *)__pyx_v_dP_upd);
  __Pyx_XDECREF((PyObject *)__pyx_v_d_log_likelihood_update);
  __Pyx_XDECREF((PyObject *)__pyx_v_dm_pred_all_params);
  __Pyx_XDECREF((PyObject *)__pyx_v_dP_pred_all_params);
  __Pyx_XDECREF((PyObject *)__pyx_v_dH_all_params);
  __Pyx_XDECREF((PyObject *)__pyx_v_dR_all_params);
  __Pyx_XDECREF((PyObject *)__pyx_v_dH);
  __Pyx_XDECREF((PyObject *)__pyx_v_dR);
  __Pyx_XDECREF((PyObject *)__pyx_v_dm_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_dP_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_dv);
  __Pyx_XDECREF((PyObject *)__pyx_v_dS);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp1);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp2);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp3);
  __Pyx_XDECREF((PyObject *)__pyx_v_dK);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp5);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_m_upd);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GPy/models/state_space_cython.pyx":912
 * 
 * @cython.boundscheck(False)
 * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables,             # <<<<<<<<<<<<<<
 *                                   Measurement_Callables_Cython p_measurement_callables, X, Y,
 *                                   np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None,
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_5_cont_discr_kalman_filter_raw_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_5_cont_discr_kalman_filter_raw_Cython = {"_cont_discr_kalman_filter_raw_Cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_5_cont_discr_kalman_filter_raw_Cython, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_5_cont_discr_kalman_filter_raw_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_state_dim;
  struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables = 0;
  struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables = 0;
  CYTHON_UNUSED PyObject *__pyx_v_X = 0;
  PyObject *__pyx_v_Y = 0;
  PyArrayObject *__pyx_v_m_init = 0;
  PyArrayObject *__pyx_v_P_init = 0;
  CYTHON_UNUSED PyObject *__pyx_v_p_kalman_filter_type = 0;
  int __pyx_v_calc_log_likelihood;
  int __pyx_v_calc_grad_log_likelihood;
  int __pyx_v_grad_params_no;
  PyArrayObject *__pyx_v_dm_init = 0;
  PyArrayObject *__pyx_v_dP_init = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_cont_discr_kalman_filter_raw_Cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_state_dim,&__pyx_n_s_p_dynamic_callables,&__pyx_n_s_p_measurement_callables,&__pyx_n_s_X,&__pyx_n_s_Y,&__pyx_n_s_m_init,&__pyx_n_s_P_init,&__pyx_n_s_p_kalman_filter_type,&__pyx_n_s_calc_log_likelihood,&__pyx_n_s_calc_grad_log_likelihood,&__pyx_n_s_grad_params_no,&__pyx_n_s_dm_init,&__pyx_n_s_dP_init,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};

    /* "GPy/models/state_space_cython.pyx":914
 * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables,
 *                                   Measurement_Callables_Cython p_measurement_callables, X, Y,
 *                                   np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None,             # <<<<<<<<<<<<<<
 *                                   p_kalman_filter_type='regular',
 *                                   bint calc_log_likelihood=False,
 */
    values[5] = (PyObject *)((PyArrayObject *)Py_None);
    values[6] = (PyObject *)((PyArrayObject *)Py_None);
    values[7] = ((PyObject *)__pyx_n_s_regular);

    /* "GPy/models/state_space_cython.pyx":919
 *                                   bint calc_grad_log_likelihood=False,
 *                                   int grad_params_no=0,
 *                                   np.ndarray[DTYPE_t, ndim=3] dm_init=None,             # <<<<<<<<<<<<<<
 *                                   np.ndarray[DTYPE_t, ndim=3] dP_init=None):
 * 
 */
    values[11] = (PyObject *)((PyArrayObject *)Py_None);

    /* "GPy/models/state_space_cython.pyx":920
 *                                   int grad_params_no=0,
 *                                   np.ndarray[DTYPE_t, ndim=3] dm_init=None,
 *                                   np.ndarray[DTYPE_t, ndim=3] dP_init=None):             # <<<<<<<<<<<<<<
 * 
 *     cdef int steps_no = Y.shape[0] # number of steps in the Kalman Filter
 */
    values[12] = (PyObject *)((PyArrayObject *)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 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_state_dim)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_dynamic_callables)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cont_discr_kalman_filter_raw_Cython", 0, 5, 13, 1); __PYX_ERR(0, 912, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_measurement_callables)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cont_discr_kalman_filter_raw_Cython", 0, 5, 13, 2); __PYX_ERR(0, 912, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_X)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cont_discr_kalman_filter_raw_Cython", 0, 5, 13, 3); __PYX_ERR(0, 912, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cont_discr_kalman_filter_raw_Cython", 0, 5, 13, 4); __PYX_ERR(0, 912, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m_init);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_P_init);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p_kalman_filter_type);
          if (value) { values[7] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_calc_log_likelihood);
          if (value) { values[8] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_calc_grad_log_likelihood);
          if (value) { values[9] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_grad_params_no);
          if (value) { values[10] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dm_init);
          if (value) { values[11] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dP_init);
          if (value) { values[12] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_cont_discr_kalman_filter_raw_Cython") < 0)) __PYX_ERR(0, 912, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 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_state_dim = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_state_dim == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 912, __pyx_L3_error)
    __pyx_v_p_dynamic_callables = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)values[1]);
    __pyx_v_p_measurement_callables = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)values[2]);
    __pyx_v_X = values[3];
    __pyx_v_Y = values[4];
    __pyx_v_m_init = ((PyArrayObject *)values[5]);
    __pyx_v_P_init = ((PyArrayObject *)values[6]);
    __pyx_v_p_kalman_filter_type = values[7];
    if (values[8]) {
      __pyx_v_calc_log_likelihood = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_calc_log_likelihood == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 916, __pyx_L3_error)
    } else {

      /* "GPy/models/state_space_cython.pyx":916
 *                                   np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None,
 *                                   p_kalman_filter_type='regular',
 *                                   bint calc_log_likelihood=False,             # <<<<<<<<<<<<<<
 *                                   bint calc_grad_log_likelihood=False,
 *                                   int grad_params_no=0,
 */
      __pyx_v_calc_log_likelihood = ((int)0);
    }
    if (values[9]) {
      __pyx_v_calc_grad_log_likelihood = __Pyx_PyObject_IsTrue(values[9]); if (unlikely((__pyx_v_calc_grad_log_likelihood == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 917, __pyx_L3_error)
    } else {

      /* "GPy/models/state_space_cython.pyx":917
 *                                   p_kalman_filter_type='regular',
 *                                   bint calc_log_likelihood=False,
 *                                   bint calc_grad_log_likelihood=False,             # <<<<<<<<<<<<<<
 *                                   int grad_params_no=0,
 *                                   np.ndarray[DTYPE_t, ndim=3] dm_init=None,
 */
      __pyx_v_calc_grad_log_likelihood = ((int)0);
    }
    if (values[10]) {
      __pyx_v_grad_params_no = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_grad_params_no == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 918, __pyx_L3_error)
    } else {
      __pyx_v_grad_params_no = ((int)0);
    }
    __pyx_v_dm_init = ((PyArrayObject *)values[11]);
    __pyx_v_dP_init = ((PyArrayObject *)values[12]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_cont_discr_kalman_filter_raw_Cython", 0, 5, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 912, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython._cont_discr_kalman_filter_raw_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dynamic_callables), __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython, 1, "p_dynamic_callables", 0))) __PYX_ERR(0, 912, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_measurement_callables), __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython, 1, "p_measurement_callables", 0))) __PYX_ERR(0, 913, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m_init), __pyx_ptype_5numpy_ndarray, 1, "m_init", 0))) __PYX_ERR(0, 914, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P_init), __pyx_ptype_5numpy_ndarray, 1, "P_init", 0))) __PYX_ERR(0, 914, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dm_init), __pyx_ptype_5numpy_ndarray, 1, "dm_init", 0))) __PYX_ERR(0, 919, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dP_init), __pyx_ptype_5numpy_ndarray, 1, "dP_init", 0))) __PYX_ERR(0, 920, __pyx_L1_error)
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_4_cont_discr_kalman_filter_raw_Cython(__pyx_self, __pyx_v_state_dim, __pyx_v_p_dynamic_callables, __pyx_v_p_measurement_callables, __pyx_v_X, __pyx_v_Y, __pyx_v_m_init, __pyx_v_P_init, __pyx_v_p_kalman_filter_type, __pyx_v_calc_log_likelihood, __pyx_v_calc_grad_log_likelihood, __pyx_v_grad_params_no, __pyx_v_dm_init, __pyx_v_dP_init);

  /* "GPy/models/state_space_cython.pyx":912
 * 
 * @cython.boundscheck(False)
 * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables,             # <<<<<<<<<<<<<<
 *                                   Measurement_Callables_Cython p_measurement_callables, X, Y,
 *                                   np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None,
 */

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_4_cont_discr_kalman_filter_raw_Cython(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_state_dim, struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables, struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables, CYTHON_UNUSED PyObject *__pyx_v_X, PyObject *__pyx_v_Y, PyArrayObject *__pyx_v_m_init, PyArrayObject *__pyx_v_P_init, CYTHON_UNUSED PyObject *__pyx_v_p_kalman_filter_type, int __pyx_v_calc_log_likelihood, int __pyx_v_calc_grad_log_likelihood, int __pyx_v_grad_params_no, PyArrayObject *__pyx_v_dm_init, PyArrayObject *__pyx_v_dP_init) {
  int __pyx_v_steps_no;
  int __pyx_v_time_series_no;
  PyArrayObject *__pyx_v_M = 0;
  PyArrayObject *__pyx_v_P = 0;
  PyArrayObject *__pyx_v_U = 0;
  PyArrayObject *__pyx_v_S = 0;
  CYTHON_UNUSED PyArrayObject *__pyx_v_Vh = 0;
  PyObject *__pyx_v_P_upd = 0;
  PyArrayObject *__pyx_v_log_likelihood = 0;
  PyArrayObject *__pyx_v_grad_log_likelihood = 0;
  PyArrayObject *__pyx_v_dm_upd = 0;
  PyArrayObject *__pyx_v_dP_upd = 0;
  PyArrayObject *__pyx_v_prev_mean = 0;
  PyArrayObject *__pyx_v_k_measurment = 0;
  PyArrayObject *__pyx_v_m_pred = 0;
  PyArrayObject *__pyx_v_m_upd = 0;
  PyObject *__pyx_v_P_pred = 0;
  PyArrayObject *__pyx_v_dm_pred = 0;
  PyArrayObject *__pyx_v_dP_pred = 0;
  PyArrayObject *__pyx_v_log_likelihood_update = 0;
  PyArrayObject *__pyx_v_d_log_likelihood_update = 0;
  int __pyx_v_k;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_M;
  __Pyx_Buffer __pyx_pybuffer_M;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P;
  __Pyx_Buffer __pyx_pybuffer_P;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_P_init;
  __Pyx_Buffer __pyx_pybuffer_P_init;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_S;
  __Pyx_Buffer __pyx_pybuffer_S;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_U;
  __Pyx_Buffer __pyx_pybuffer_U;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh;
  __Pyx_Buffer __pyx_pybuffer_Vh;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_init;
  __Pyx_Buffer __pyx_pybuffer_dP_init;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_pred;
  __Pyx_Buffer __pyx_pybuffer_dP_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_upd;
  __Pyx_Buffer __pyx_pybuffer_dP_upd;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_d_log_likelihood_update;
  __Pyx_Buffer __pyx_pybuffer_d_log_likelihood_update;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_init;
  __Pyx_Buffer __pyx_pybuffer_dm_init;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_pred;
  __Pyx_Buffer __pyx_pybuffer_dm_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_upd;
  __Pyx_Buffer __pyx_pybuffer_dm_upd;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_grad_log_likelihood;
  __Pyx_Buffer __pyx_pybuffer_grad_log_likelihood;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_k_measurment;
  __Pyx_Buffer __pyx_pybuffer_k_measurment;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_log_likelihood;
  __Pyx_Buffer __pyx_pybuffer_log_likelihood;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_log_likelihood_update;
  __Pyx_Buffer __pyx_pybuffer_log_likelihood_update;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_init;
  __Pyx_Buffer __pyx_pybuffer_m_init;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred;
  __Pyx_Buffer __pyx_pybuffer_m_pred;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_m_upd;
  __Pyx_Buffer __pyx_pybuffer_m_upd;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_prev_mean;
  __Pyx_Buffer __pyx_pybuffer_prev_mean;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  PyArrayObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyArrayObject *__pyx_t_15 = NULL;
  PyArrayObject *__pyx_t_16 = NULL;
  PyArrayObject *__pyx_t_17 = NULL;
  PyArrayObject *__pyx_t_18 = NULL;
  PyArrayObject *__pyx_t_19 = NULL;
  int __pyx_t_20;
  int __pyx_t_21;
  PyArrayObject *__pyx_t_22 = NULL;
  int __pyx_t_23;
  PyArrayObject *__pyx_t_24 = NULL;
  PyArrayObject *__pyx_t_25 = NULL;
  int __pyx_t_26;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyArrayObject *__pyx_t_29 = NULL;
  PyArrayObject *__pyx_t_30 = NULL;
  PyArrayObject *__pyx_t_31 = NULL;
  int __pyx_t_32;
  struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset __pyx_t_33;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_cont_discr_kalman_filter_raw_Cython", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_P_init);
  __pyx_pybuffer_M.pybuffer.buf = NULL;
  __pyx_pybuffer_M.refcount = 0;
  __pyx_pybuffernd_M.data = NULL;
  __pyx_pybuffernd_M.rcbuffer = &__pyx_pybuffer_M;
  __pyx_pybuffer_P.pybuffer.buf = NULL;
  __pyx_pybuffer_P.refcount = 0;
  __pyx_pybuffernd_P.data = NULL;
  __pyx_pybuffernd_P.rcbuffer = &__pyx_pybuffer_P;
  __pyx_pybuffer_U.pybuffer.buf = NULL;
  __pyx_pybuffer_U.refcount = 0;
  __pyx_pybuffernd_U.data = NULL;
  __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U;
  __pyx_pybuffer_S.pybuffer.buf = NULL;
  __pyx_pybuffer_S.refcount = 0;
  __pyx_pybuffernd_S.data = NULL;
  __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S;
  __pyx_pybuffer_Vh.pybuffer.buf = NULL;
  __pyx_pybuffer_Vh.refcount = 0;
  __pyx_pybuffernd_Vh.data = NULL;
  __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh;
  __pyx_pybuffer_log_likelihood.pybuffer.buf = NULL;
  __pyx_pybuffer_log_likelihood.refcount = 0;
  __pyx_pybuffernd_log_likelihood.data = NULL;
  __pyx_pybuffernd_log_likelihood.rcbuffer = &__pyx_pybuffer_log_likelihood;
  __pyx_pybuffer_grad_log_likelihood.pybuffer.buf = NULL;
  __pyx_pybuffer_grad_log_likelihood.refcount = 0;
  __pyx_pybuffernd_grad_log_likelihood.data = NULL;
  __pyx_pybuffernd_grad_log_likelihood.rcbuffer = &__pyx_pybuffer_grad_log_likelihood;
  __pyx_pybuffer_dm_upd.pybuffer.buf = NULL;
  __pyx_pybuffer_dm_upd.refcount = 0;
  __pyx_pybuffernd_dm_upd.data = NULL;
  __pyx_pybuffernd_dm_upd.rcbuffer = &__pyx_pybuffer_dm_upd;
  __pyx_pybuffer_dP_upd.pybuffer.buf = NULL;
  __pyx_pybuffer_dP_upd.refcount = 0;
  __pyx_pybuffernd_dP_upd.data = NULL;
  __pyx_pybuffernd_dP_upd.rcbuffer = &__pyx_pybuffer_dP_upd;
  __pyx_pybuffer_prev_mean.pybuffer.buf = NULL;
  __pyx_pybuffer_prev_mean.refcount = 0;
  __pyx_pybuffernd_prev_mean.data = NULL;
  __pyx_pybuffernd_prev_mean.rcbuffer = &__pyx_pybuffer_prev_mean;
  __pyx_pybuffer_k_measurment.pybuffer.buf = NULL;
  __pyx_pybuffer_k_measurment.refcount = 0;
  __pyx_pybuffernd_k_measurment.data = NULL;
  __pyx_pybuffernd_k_measurment.rcbuffer = &__pyx_pybuffer_k_measurment;
  __pyx_pybuffer_m_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_m_pred.refcount = 0;
  __pyx_pybuffernd_m_pred.data = NULL;
  __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred;
  __pyx_pybuffer_m_upd.pybuffer.buf = NULL;
  __pyx_pybuffer_m_upd.refcount = 0;
  __pyx_pybuffernd_m_upd.data = NULL;
  __pyx_pybuffernd_m_upd.rcbuffer = &__pyx_pybuffer_m_upd;
  __pyx_pybuffer_dm_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_dm_pred.refcount = 0;
  __pyx_pybuffernd_dm_pred.data = NULL;
  __pyx_pybuffernd_dm_pred.rcbuffer = &__pyx_pybuffer_dm_pred;
  __pyx_pybuffer_dP_pred.pybuffer.buf = NULL;
  __pyx_pybuffer_dP_pred.refcount = 0;
  __pyx_pybuffernd_dP_pred.data = NULL;
  __pyx_pybuffernd_dP_pred.rcbuffer = &__pyx_pybuffer_dP_pred;
  __pyx_pybuffer_log_likelihood_update.pybuffer.buf = NULL;
  __pyx_pybuffer_log_likelihood_update.refcount = 0;
  __pyx_pybuffernd_log_likelihood_update.data = NULL;
  __pyx_pybuffernd_log_likelihood_update.rcbuffer = &__pyx_pybuffer_log_likelihood_update;
  __pyx_pybuffer_d_log_likelihood_update.pybuffer.buf = NULL;
  __pyx_pybuffer_d_log_likelihood_update.refcount = 0;
  __pyx_pybuffernd_d_log_likelihood_update.data = NULL;
  __pyx_pybuffernd_d_log_likelihood_update.rcbuffer = &__pyx_pybuffer_d_log_likelihood_update;
  __pyx_pybuffer_m_init.pybuffer.buf = NULL;
  __pyx_pybuffer_m_init.refcount = 0;
  __pyx_pybuffernd_m_init.data = NULL;
  __pyx_pybuffernd_m_init.rcbuffer = &__pyx_pybuffer_m_init;
  __pyx_pybuffer_P_init.pybuffer.buf = NULL;
  __pyx_pybuffer_P_init.refcount = 0;
  __pyx_pybuffernd_P_init.data = NULL;
  __pyx_pybuffernd_P_init.rcbuffer = &__pyx_pybuffer_P_init;
  __pyx_pybuffer_dm_init.pybuffer.buf = NULL;
  __pyx_pybuffer_dm_init.refcount = 0;
  __pyx_pybuffernd_dm_init.data = NULL;
  __pyx_pybuffernd_dm_init.rcbuffer = &__pyx_pybuffer_dm_init;
  __pyx_pybuffer_dP_init.pybuffer.buf = NULL;
  __pyx_pybuffer_dP_init.refcount = 0;
  __pyx_pybuffernd_dP_init.data = NULL;
  __pyx_pybuffernd_dP_init.rcbuffer = &__pyx_pybuffer_dP_init;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_init.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_init, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 912, __pyx_L1_error)
  }
  __pyx_pybuffernd_m_init.diminfo[0].strides = __pyx_pybuffernd_m_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_init.diminfo[0].shape = __pyx_pybuffernd_m_init.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_init.diminfo[1].strides = __pyx_pybuffernd_m_init.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_init.diminfo[1].shape = __pyx_pybuffernd_m_init.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_init, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 912, __pyx_L1_error)
  }
  __pyx_pybuffernd_P_init.diminfo[0].strides = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_init.diminfo[0].shape = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_init.diminfo[1].strides = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_init.diminfo[1].shape = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_init.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_init, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 912, __pyx_L1_error)
  }
  __pyx_pybuffernd_dm_init.diminfo[0].strides = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_init.diminfo[0].shape = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_init.diminfo[1].strides = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_init.diminfo[1].shape = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_init.diminfo[2].strides = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_init.diminfo[2].shape = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_init.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_init, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 912, __pyx_L1_error)
  }
  __pyx_pybuffernd_dP_init.diminfo[0].strides = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_init.diminfo[0].shape = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_init.diminfo[1].strides = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_init.diminfo[1].shape = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_init.diminfo[2].strides = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_init.diminfo[2].shape = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.shape[2];

  /* "GPy/models/state_space_cython.pyx":922
 *                                   np.ndarray[DTYPE_t, ndim=3] dP_init=None):
 * 
 *     cdef int steps_no = Y.shape[0] # number of steps in the Kalman Filter             # <<<<<<<<<<<<<<
 *     cdef int time_series_no = Y.shape[2] # multiple time series mode
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Y, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 922, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 922, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 922, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_steps_no = __pyx_t_3;

  /* "GPy/models/state_space_cython.pyx":923
 * 
 *     cdef int steps_no = Y.shape[0] # number of steps in the Kalman Filter
 *     cdef int time_series_no = Y.shape[2] # multiple time series mode             # <<<<<<<<<<<<<<
 * 
 *     # Allocate space for results
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_Y, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 923, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 923, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 923, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_time_series_no = __pyx_t_3;

  /* "GPy/models/state_space_cython.pyx":927
 *     # Allocate space for results
 *     # Mean estimations. Initial values will be included
 *     cdef np.ndarray[DTYPE_t, ndim=3] M = np.empty(((steps_no+1),state_dim,time_series_no), dtype=DTYPE)             # <<<<<<<<<<<<<<
 *     M[0,:,:] = m_init # Initialize mean values
 *     # Variance estimations. Initial values will be included
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_steps_no + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_state_dim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_time_series_no); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 927, __pyx_L1_error)
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_M.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_M = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_M.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 927, __pyx_L1_error)
    } else {__pyx_pybuffernd_M.diminfo[0].strides = __pyx_pybuffernd_M.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_M.diminfo[0].shape = __pyx_pybuffernd_M.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_M.diminfo[1].strides = __pyx_pybuffernd_M.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_M.diminfo[1].shape = __pyx_pybuffernd_M.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_M.diminfo[2].strides = __pyx_pybuffernd_M.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_M.diminfo[2].shape = __pyx_pybuffernd_M.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_t_7 = 0;
  __pyx_v_M = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "GPy/models/state_space_cython.pyx":928
 *     # Mean estimations. Initial values will be included
 *     cdef np.ndarray[DTYPE_t, ndim=3] M = np.empty(((steps_no+1),state_dim,time_series_no), dtype=DTYPE)
 *     M[0,:,:] = m_init # Initialize mean values             # <<<<<<<<<<<<<<
 *     # Variance estimations. Initial values will be included
 *     cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim))
 */
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_M), __pyx_tuple__17, ((PyObject *)__pyx_v_m_init)) < 0)) __PYX_ERR(0, 928, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":930
 *     M[0,:,:] = m_init # Initialize mean values
 *     # Variance estimations. Initial values will be included
 *     cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim))             # <<<<<<<<<<<<<<
 *     P_init = 0.5*( P_init + P_init.T) # symmetrize initial covariance. In some ustable cases this is uiseful
 *     P[0,:,:] = P_init # Initialize initial covariance matrix
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_steps_no + 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_state_dim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_state_dim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_1);
  __pyx_t_6 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_1, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 930, __pyx_L1_error)
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_P = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_P.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 930, __pyx_L1_error)
    } else {__pyx_pybuffernd_P.diminfo[0].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P.diminfo[0].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P.diminfo[1].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P.diminfo[1].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_P.diminfo[2].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_P.diminfo[2].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_P = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "GPy/models/state_space_cython.pyx":931
 *     # Variance estimations. Initial values will be included
 *     cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim))
 *     P_init = 0.5*( P_init + P_init.T) # symmetrize initial covariance. In some ustable cases this is uiseful             # <<<<<<<<<<<<<<
 *     P[0,:,:] = P_init # Initialize initial covariance matrix
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_P_init), __pyx_n_s_T); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 931, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_v_P_init), __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 931, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Multiply(__pyx_float_0_5, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 931, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 931, __pyx_L1_error)
  __pyx_t_10 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer);
    __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_3 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_init, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
    }
    __pyx_pybuffernd_P_init.diminfo[0].strides = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_init.diminfo[0].shape = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_init.diminfo[1].strides = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_init.diminfo[1].shape = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 931, __pyx_L1_error)
  }
  __pyx_t_10 = 0;
  __Pyx_DECREF_SET(__pyx_v_P_init, ((PyArrayObject *)__pyx_t_4));
  __pyx_t_4 = 0;

  /* "GPy/models/state_space_cython.pyx":932
 *     cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim))
 *     P_init = 0.5*( P_init + P_init.T) # symmetrize initial covariance. In some ustable cases this is uiseful
 *     P[0,:,:] = P_init # Initialize initial covariance matrix             # <<<<<<<<<<<<<<
 * 
 *     cdef np.ndarray[DTYPE_t, ndim=2] U
 */
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_P), __pyx_tuple__17, ((PyObject *)__pyx_v_P_init)) < 0)) __PYX_ERR(0, 932, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":938
 *     cdef np.ndarray[DTYPE_t, ndim=2] Vh
 * 
 *     U,S,Vh = sp.linalg.svd( P_init,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *               overwrite_a=False,check_finite=True)
 *     S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_sp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_linalg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_svd); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_v_P_init));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_P_init));
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_P_init));
  __pyx_t_8 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_full_matrices, Py_False) < 0) __PYX_ERR(0, 938, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_compute_uv, Py_True) < 0) __PYX_ERR(0, 938, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":939
 * 
 *     U,S,Vh = sp.linalg.svd( P_init,full_matrices=False, compute_uv=True,
 *               overwrite_a=False,check_finite=True)             # <<<<<<<<<<<<<<
 *     S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance
 *     cdef tuple P_upd = (P_init, S,U)
 */
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_overwrite_a, Py_False) < 0) __PYX_ERR(0, 938, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_check_finite, Py_True) < 0) __PYX_ERR(0, 938, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":938
 *     cdef np.ndarray[DTYPE_t, ndim=2] Vh
 * 
 *     U,S,Vh = sp.linalg.svd( P_init,full_matrices=False, compute_uv=True,             # <<<<<<<<<<<<<<
 *               overwrite_a=False,check_finite=True)
 *     S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 938, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 938, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 938, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 938, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 938, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_14 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_8 = __pyx_t_14(__pyx_t_2); if (unlikely(!__pyx_t_8)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_8);
    index = 1; __pyx_t_5 = __pyx_t_14(__pyx_t_2); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    index = 2; __pyx_t_4 = __pyx_t_14(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_2), 3) < 0) __PYX_ERR(0, 938, __pyx_L1_error)
    __pyx_t_14 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_14 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 938, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 938, __pyx_L1_error)
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 938, __pyx_L1_error)
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 938, __pyx_L1_error)
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
    __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_3 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
    }
    __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 938, __pyx_L1_error)
  }
  __pyx_t_15 = 0;
  __pyx_v_U = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_16 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
    __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_3 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 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_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
    }
    __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 938, __pyx_L1_error)
  }
  __pyx_t_16 = 0;
  __pyx_v_S = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_17 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
    __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_3 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
    }
    __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 938, __pyx_L1_error)
  }
  __pyx_t_17 = 0;
  __pyx_v_Vh = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "GPy/models/state_space_cython.pyx":940
 *     U,S,Vh = sp.linalg.svd( P_init,full_matrices=False, compute_uv=True,
 *               overwrite_a=False,check_finite=True)
 *     S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance             # <<<<<<<<<<<<<<
 *     cdef tuple P_upd = (P_init, S,U)
 *     #log_likelihood = 0
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_S), __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 940, __pyx_L1_error)
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_S), __pyx_t_1, __pyx_float_1eneg_17) < 0)) __PYX_ERR(0, 940, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":941
 *               overwrite_a=False,check_finite=True)
 *     S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance
 *     cdef tuple P_upd = (P_init, S,U)             # <<<<<<<<<<<<<<
 *     #log_likelihood = 0
 *     #grad_log_likelihood = np.zeros((grad_params_no,1))
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_P_init));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_P_init));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_P_init));
  __Pyx_INCREF(((PyObject *)__pyx_v_S));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_S));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_S));
  __Pyx_INCREF(((PyObject *)__pyx_v_U));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_U));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_U));
  __pyx_v_P_upd = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":944
 *     #log_likelihood = 0
 *     #grad_log_likelihood = np.zeros((grad_params_no,1))
 *     cdef np.ndarray[DTYPE_t, ndim=2] log_likelihood = np.zeros((1, time_series_no), dtype = DTYPE) #if calc_log_likelihood else None             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=2] grad_log_likelihood = np.zeros((grad_params_no, time_series_no), dtype = DTYPE) #if calc_grad_log_likelihood else None
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 944, __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_time_series_no); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_8) < 0) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 944, __pyx_L1_error)
  __pyx_t_18 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_log_likelihood = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 944, __pyx_L1_error)
    } else {__pyx_pybuffernd_log_likelihood.diminfo[0].strides = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood.diminfo[0].shape = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood.diminfo[1].strides = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood.diminfo[1].shape = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_18 = 0;
  __pyx_v_log_likelihood = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "GPy/models/state_space_cython.pyx":945
 *     #grad_log_likelihood = np.zeros((grad_params_no,1))
 *     cdef np.ndarray[DTYPE_t, ndim=2] log_likelihood = np.zeros((1, time_series_no), dtype = DTYPE) #if calc_log_likelihood else None
 *     cdef np.ndarray[DTYPE_t, ndim=2] grad_log_likelihood = np.zeros((grad_params_no, time_series_no), dtype = DTYPE) #if calc_grad_log_likelihood else None             # <<<<<<<<<<<<<<
 * 
 *     #setting initial values for derivatives update
 */
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 945, __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_ERR(0, 945, __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_grad_params_no); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_time_series_no); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __pyx_t_8 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_8) < 0) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 945, __pyx_L1_error)
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_grad_log_likelihood = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 945, __pyx_L1_error)
    } else {__pyx_pybuffernd_grad_log_likelihood.diminfo[0].strides = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_grad_log_likelihood.diminfo[0].shape = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_grad_log_likelihood.diminfo[1].strides = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_grad_log_likelihood.diminfo[1].shape = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_19 = 0;
  __pyx_v_grad_log_likelihood = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "GPy/models/state_space_cython.pyx":948
 * 
 *     #setting initial values for derivatives update
 *     cdef np.ndarray[DTYPE_t, ndim=3] dm_upd = dm_init             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=3] dP_upd = dP_init
 *     # Main loop of the Kalman filter
 */
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_dm_init), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_dm_upd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 948, __pyx_L1_error)
    } else {__pyx_pybuffernd_dm_upd.diminfo[0].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_upd.diminfo[0].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_upd.diminfo[1].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_upd.diminfo[1].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_upd.diminfo[2].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_upd.diminfo[2].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[2];
    }
  }
  __Pyx_INCREF(((PyObject *)__pyx_v_dm_init));
  __pyx_v_dm_upd = ((PyArrayObject *)__pyx_v_dm_init);

  /* "GPy/models/state_space_cython.pyx":949
 *     #setting initial values for derivatives update
 *     cdef np.ndarray[DTYPE_t, ndim=3] dm_upd = dm_init
 *     cdef np.ndarray[DTYPE_t, ndim=3] dP_upd = dP_init             # <<<<<<<<<<<<<<
 *     # Main loop of the Kalman filter
 *     cdef np.ndarray[DTYPE_t, ndim=2] prev_mean, k_measurment
 */
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_dP_init), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_dP_upd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 949, __pyx_L1_error)
    } else {__pyx_pybuffernd_dP_upd.diminfo[0].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_upd.diminfo[0].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_upd.diminfo[1].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_upd.diminfo[1].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_upd.diminfo[2].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_upd.diminfo[2].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[2];
    }
  }
  __Pyx_INCREF(((PyObject *)__pyx_v_dP_init));
  __pyx_v_dP_upd = ((PyArrayObject *)__pyx_v_dP_init);

  /* "GPy/models/state_space_cython.pyx":959
 * 
 *     #print "Hi I am cython"
 *     for k in range(0,steps_no):             # <<<<<<<<<<<<<<
 *         # In this loop index for new estimations is (k+1), old - (k)
 *         # This happened because initial values are stored at 0-th index.
 */
  __pyx_t_3 = __pyx_v_steps_no;
  __pyx_t_20 = __pyx_t_3;
  for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) {
    __pyx_v_k = __pyx_t_21;

    /* "GPy/models/state_space_cython.pyx":964
 *         #import pdb; pdb.set_trace()
 * 
 *         prev_mean = M[k,:,:] # mean from the previous step             # <<<<<<<<<<<<<<
 * 
 *         m_pred, P_pred, dm_pred, dP_pred = \
 */
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 964, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 964, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8);
    __Pyx_INCREF(__pyx_slice__10);
    __Pyx_GIVEREF(__pyx_slice__10);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__10);
    __Pyx_INCREF(__pyx_slice__10);
    __Pyx_GIVEREF(__pyx_slice__10);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_slice__10);
    __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_M), __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 964, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 964, __pyx_L1_error)
    __pyx_t_22 = ((PyArrayObject *)__pyx_t_8);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_prev_mean.rcbuffer->pybuffer);
      __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_prev_mean.rcbuffer->pybuffer, (PyObject*)__pyx_t_22, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_23 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_prev_mean.rcbuffer->pybuffer, (PyObject*)__pyx_v_prev_mean, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
      }
      __pyx_pybuffernd_prev_mean.diminfo[0].strides = __pyx_pybuffernd_prev_mean.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_prev_mean.diminfo[0].shape = __pyx_pybuffernd_prev_mean.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_prev_mean.diminfo[1].strides = __pyx_pybuffernd_prev_mean.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_prev_mean.diminfo[1].shape = __pyx_pybuffernd_prev_mean.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 964, __pyx_L1_error)
    }
    __pyx_t_22 = 0;
    __Pyx_XDECREF_SET(__pyx_v_prev_mean, ((PyArrayObject *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "GPy/models/state_space_cython.pyx":967
 * 
 *         m_pred, P_pred, dm_pred, dP_pred = \
 *         _kalman_prediction_step_SVD_Cython(k, prev_mean ,P_upd, p_dynamic_callables,             # <<<<<<<<<<<<<<
 *             calc_grad_log_likelihood, dm_upd, dP_upd)
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_kalman_prediction_step_SVD_Cyth); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 967, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 967, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "GPy/models/state_space_cython.pyx":968
 *         m_pred, P_pred, dm_pred, dP_pred = \
 *         _kalman_prediction_step_SVD_Cython(k, prev_mean ,P_upd, p_dynamic_callables,
 *             calc_grad_log_likelihood, dm_upd, dP_upd)             # <<<<<<<<<<<<<<
 * 
 *         k_measurment = Y[k,:,:]
 */
    __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_calc_grad_log_likelihood); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 968, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = NULL;
    __pyx_t_23 = 0;
    if (CYTHON_UNPACK_METHODS && 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_23 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[8] = {__pyx_t_2, __pyx_t_1, ((PyObject *)__pyx_v_prev_mean), __pyx_v_P_upd, ((PyObject *)__pyx_v_p_dynamic_callables), __pyx_t_5, ((PyObject *)__pyx_v_dm_upd), ((PyObject *)__pyx_v_dP_upd)};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_23, 7+__pyx_t_23); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 967, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[8] = {__pyx_t_2, __pyx_t_1, ((PyObject *)__pyx_v_prev_mean), __pyx_v_P_upd, ((PyObject *)__pyx_v_p_dynamic_callables), __pyx_t_5, ((PyObject *)__pyx_v_dm_upd), ((PyObject *)__pyx_v_dP_upd)};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_23, 7+__pyx_t_23); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 967, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(7+__pyx_t_23); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 967, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_23, __pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_prev_mean));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_prev_mean));
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_23, ((PyObject *)__pyx_v_prev_mean));
      __Pyx_INCREF(__pyx_v_P_upd);
      __Pyx_GIVEREF(__pyx_v_P_upd);
      PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_23, __pyx_v_P_upd);
      __Pyx_INCREF(((PyObject *)__pyx_v_p_dynamic_callables));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_p_dynamic_callables));
      PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_23, ((PyObject *)__pyx_v_p_dynamic_callables));
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_23, __pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_v_dm_upd));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_dm_upd));
      PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_23, ((PyObject *)__pyx_v_dm_upd));
      __Pyx_INCREF(((PyObject *)__pyx_v_dP_upd));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_dP_upd));
      PyTuple_SET_ITEM(__pyx_t_6, 6+__pyx_t_23, ((PyObject *)__pyx_v_dP_upd));
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 967, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
      PyObject* sequence = __pyx_t_8;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 4)) {
        if (size > 4) __Pyx_RaiseTooManyValuesError(4);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 966, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 3); 
      } else {
        __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 3); 
      }
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_6,&__pyx_t_5,&__pyx_t_1};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 966, __pyx_L1_error)
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_6,&__pyx_t_5,&__pyx_t_1};
      __pyx_t_2 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 966, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_14 = Py_TYPE(__pyx_t_2)->tp_iternext;
      for (index=0; index < 4; index++) {
        PyObject* item = __pyx_t_14(__pyx_t_2); if (unlikely(!item)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_2), 4) < 0) __PYX_ERR(0, 966, __pyx_L1_error)
      __pyx_t_14 = NULL;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L8_unpacking_done;
      __pyx_L7_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_14 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 966, __pyx_L1_error)
      __pyx_L8_unpacking_done:;
    }

    /* "GPy/models/state_space_cython.pyx":966
 *         prev_mean = M[k,:,:] # mean from the previous step
 * 
 *         m_pred, P_pred, dm_pred, dP_pred = \             # <<<<<<<<<<<<<<
 *         _kalman_prediction_step_SVD_Cython(k, prev_mean ,P_upd, p_dynamic_callables,
 *             calc_grad_log_likelihood, dm_upd, dP_upd)
 */
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 966, __pyx_L1_error)
    if (!(likely(PyTuple_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(0, 966, __pyx_L1_error)
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 966, __pyx_L1_error)
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 966, __pyx_L1_error)
    __pyx_t_24 = ((PyArrayObject *)__pyx_t_4);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
      __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_24, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_23 < 0)) {
        PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
      }
      __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 966, __pyx_L1_error)
    }
    __pyx_t_24 = 0;
    __Pyx_XDECREF_SET(__pyx_v_m_pred, ((PyArrayObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_P_pred, ((PyObject*)__pyx_t_6));
    __pyx_t_6 = 0;
    __pyx_t_25 = ((PyArrayObject *)__pyx_t_5);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer);
      __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_23 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 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_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
      }
      __pyx_pybuffernd_dm_pred.diminfo[0].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_pred.diminfo[0].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_pred.diminfo[1].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_pred.diminfo[1].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_pred.diminfo[2].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_pred.diminfo[2].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 966, __pyx_L1_error)
    }
    __pyx_t_25 = 0;
    __Pyx_XDECREF_SET(__pyx_v_dm_pred, ((PyArrayObject *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_t_25 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer);
      __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_23 < 0)) {
        PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 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_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
      }
      __pyx_pybuffernd_dP_pred.diminfo[0].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_pred.diminfo[0].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_pred.diminfo[1].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_pred.diminfo[1].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_pred.diminfo[2].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_pred.diminfo[2].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[2];
      if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 966, __pyx_L1_error)
    }
    __pyx_t_25 = 0;
    __Pyx_XDECREF_SET(__pyx_v_dP_pred, ((PyArrayObject *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "GPy/models/state_space_cython.pyx":970
 *             calc_grad_log_likelihood, dm_upd, dP_upd)
 * 
 *         k_measurment = Y[k,:,:]             # <<<<<<<<<<<<<<
 *         if (np.any(np.isnan(k_measurment)) == False):
 * #        if np.any(np.isnan(k_measurment)):
 */
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 970, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 970, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
    __Pyx_INCREF(__pyx_slice__10);
    __Pyx_GIVEREF(__pyx_slice__10);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__10);
    __Pyx_INCREF(__pyx_slice__10);
    __Pyx_GIVEREF(__pyx_slice__10);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_slice__10);
    __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_Y, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 970, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 970, __pyx_L1_error)
    __pyx_t_22 = ((PyArrayObject *)__pyx_t_8);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_k_measurment.rcbuffer->pybuffer);
      __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_k_measurment.rcbuffer->pybuffer, (PyObject*)__pyx_t_22, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_23 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_k_measurment.rcbuffer->pybuffer, (PyObject*)__pyx_v_k_measurment, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
      }
      __pyx_pybuffernd_k_measurment.diminfo[0].strides = __pyx_pybuffernd_k_measurment.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_k_measurment.diminfo[0].shape = __pyx_pybuffernd_k_measurment.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_k_measurment.diminfo[1].strides = __pyx_pybuffernd_k_measurment.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_k_measurment.diminfo[1].shape = __pyx_pybuffernd_k_measurment.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 970, __pyx_L1_error)
    }
    __pyx_t_22 = 0;
    __Pyx_XDECREF_SET(__pyx_v_k_measurment, ((PyArrayObject *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "GPy/models/state_space_cython.pyx":971
 * 
 *         k_measurment = Y[k,:,:]
 *         if (np.any(np.isnan(k_measurment)) == False):             # <<<<<<<<<<<<<<
 * #        if np.any(np.isnan(k_measurment)):
 * #            raise ValueError("Nan measurements are currently not supported")
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_any); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_isnan); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, ((PyObject *)__pyx_v_k_measurment)) : __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_k_measurment));
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_8 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_8, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_26 < 0)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_26) {

      /* "GPy/models/state_space_cython.pyx":976
 * 
 *             m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \
 *             _kalman_update_step_SVD_Cython(k,  m_pred , P_pred, p_measurement_callables,             # <<<<<<<<<<<<<<
 *                     k_measurment, calc_log_likelihood=calc_log_likelihood,
 *                     calc_grad_log_likelihood=calc_grad_log_likelihood,
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_kalman_update_step_SVD_Cython); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 976, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 976, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);

      /* "GPy/models/state_space_cython.pyx":977
 *             m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \
 *             _kalman_update_step_SVD_Cython(k,  m_pred , P_pred, p_measurement_callables,
 *                     k_measurment, calc_log_likelihood=calc_log_likelihood,             # <<<<<<<<<<<<<<
 *                     calc_grad_log_likelihood=calc_grad_log_likelihood,
 *                     p_dm = dm_pred, p_dP = dP_pred)
 */
      __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 976, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
      __Pyx_INCREF(((PyObject *)__pyx_v_m_pred));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred));
      PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_m_pred));
      __Pyx_INCREF(__pyx_v_P_pred);
      __Pyx_GIVEREF(__pyx_v_P_pred);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_P_pred);
      __Pyx_INCREF(((PyObject *)__pyx_v_p_measurement_callables));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_p_measurement_callables));
      PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_p_measurement_callables));
      __Pyx_INCREF(((PyObject *)__pyx_v_k_measurment));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_k_measurment));
      PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_v_k_measurment));
      __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 977, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_calc_log_likelihood); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 977, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_calc_log_likelihood, __pyx_t_4) < 0) __PYX_ERR(0, 977, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "GPy/models/state_space_cython.pyx":978
 *             _kalman_update_step_SVD_Cython(k,  m_pred , P_pred, p_measurement_callables,
 *                     k_measurment, calc_log_likelihood=calc_log_likelihood,
 *                     calc_grad_log_likelihood=calc_grad_log_likelihood,             # <<<<<<<<<<<<<<
 *                     p_dm = dm_pred, p_dP = dP_pred)
 *         else:
 */
      __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_calc_grad_log_likelihood); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 978, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_calc_grad_log_likelihood, __pyx_t_4) < 0) __PYX_ERR(0, 977, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "GPy/models/state_space_cython.pyx":979
 *                     k_measurment, calc_log_likelihood=calc_log_likelihood,
 *                     calc_grad_log_likelihood=calc_grad_log_likelihood,
 *                     p_dm = dm_pred, p_dP = dP_pred)             # <<<<<<<<<<<<<<
 *         else:
 *             if not np.all(np.isnan(k_measurment)):
 */
      if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_p_dm, ((PyObject *)__pyx_v_dm_pred)) < 0) __PYX_ERR(0, 977, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_p_dP, ((PyObject *)__pyx_v_dP_pred)) < 0) __PYX_ERR(0, 977, __pyx_L1_error)

      /* "GPy/models/state_space_cython.pyx":976
 * 
 *             m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \
 *             _kalman_update_step_SVD_Cython(k,  m_pred , P_pred, p_measurement_callables,             # <<<<<<<<<<<<<<
 *                     k_measurment, calc_log_likelihood=calc_log_likelihood,
 *                     calc_grad_log_likelihood=calc_grad_log_likelihood,
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 976, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
        PyObject* sequence = __pyx_t_4;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 6)) {
          if (size > 6) __Pyx_RaiseTooManyValuesError(6);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 975, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 3); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 4); 
          __pyx_t_27 = PyTuple_GET_ITEM(sequence, 5); 
        } else {
          __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 3); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 4); 
          __pyx_t_27 = PyList_GET_ITEM(sequence, 5); 
        }
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_27);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[6] = {&__pyx_t_8,&__pyx_t_1,&__pyx_t_5,&__pyx_t_6,&__pyx_t_2,&__pyx_t_27};
          for (i=0; i < 6; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 975, __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[6] = {&__pyx_t_8,&__pyx_t_1,&__pyx_t_5,&__pyx_t_6,&__pyx_t_2,&__pyx_t_27};
        __pyx_t_28 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 975, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_28);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_28)->tp_iternext;
        for (index=0; index < 6; index++) {
          PyObject* item = __pyx_t_14(__pyx_t_28); if (unlikely(!item)) goto __pyx_L10_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_28), 6) < 0) __PYX_ERR(0, 975, __pyx_L1_error)
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
        goto __pyx_L11_unpacking_done;
        __pyx_L10_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 975, __pyx_L1_error)
        __pyx_L11_unpacking_done:;
      }

      /* "GPy/models/state_space_cython.pyx":975
 * #            raise ValueError("Nan measurements are currently not supported")
 * 
 *             m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \             # <<<<<<<<<<<<<<
 *             _kalman_update_step_SVD_Cython(k,  m_pred , P_pred, p_measurement_callables,
 *                     k_measurment, calc_log_likelihood=calc_log_likelihood,
 */
      if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 975, __pyx_L1_error)
      if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 975, __pyx_L1_error)
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 975, __pyx_L1_error)
      if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 975, __pyx_L1_error)
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 975, __pyx_L1_error)
      if (!(likely(((__pyx_t_27) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_27, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 975, __pyx_L1_error)
      __pyx_t_24 = ((PyArrayObject *)__pyx_t_8);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer);
        __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_24, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_23 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
        }
        __pyx_pybuffernd_m_upd.diminfo[0].strides = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_upd.diminfo[0].shape = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_upd.diminfo[1].strides = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_upd.diminfo[1].shape = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 975, __pyx_L1_error)
      }
      __pyx_t_24 = 0;
      __Pyx_XDECREF_SET(__pyx_v_m_upd, ((PyArrayObject *)__pyx_t_8));
      __pyx_t_8 = 0;
      __Pyx_DECREF_SET(__pyx_v_P_upd, ((PyObject*)__pyx_t_1));
      __pyx_t_1 = 0;
      __pyx_t_29 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer);
        __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_23 < 0)) {
          PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
        }
        __pyx_pybuffernd_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 975, __pyx_L1_error)
      }
      __pyx_t_29 = 0;
      __Pyx_XDECREF_SET(__pyx_v_log_likelihood_update, ((PyArrayObject *)__pyx_t_5));
      __pyx_t_5 = 0;
      __pyx_t_30 = ((PyArrayObject *)__pyx_t_6);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer);
        __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_30, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
        if (unlikely(__pyx_t_23 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 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_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
        }
        __pyx_pybuffernd_dm_upd.diminfo[0].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_upd.diminfo[0].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_upd.diminfo[1].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_upd.diminfo[1].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_upd.diminfo[2].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_upd.diminfo[2].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[2];
        if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 975, __pyx_L1_error)
      }
      __pyx_t_30 = 0;
      __Pyx_DECREF_SET(__pyx_v_dm_upd, ((PyArrayObject *)__pyx_t_6));
      __pyx_t_6 = 0;
      __pyx_t_31 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer);
        __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_31, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
        if (unlikely(__pyx_t_23 < 0)) {
          PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 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_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
        }
        __pyx_pybuffernd_dP_upd.diminfo[0].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_upd.diminfo[0].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_upd.diminfo[1].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_upd.diminfo[1].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_upd.diminfo[2].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_upd.diminfo[2].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[2];
        if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 975, __pyx_L1_error)
      }
      __pyx_t_31 = 0;
      __Pyx_DECREF_SET(__pyx_v_dP_upd, ((PyArrayObject *)__pyx_t_2));
      __pyx_t_2 = 0;
      __pyx_t_29 = ((PyArrayObject *)__pyx_t_27);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer);
        __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_23 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_d_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
        }
        __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 975, __pyx_L1_error)
      }
      __pyx_t_29 = 0;
      __Pyx_XDECREF_SET(__pyx_v_d_log_likelihood_update, ((PyArrayObject *)__pyx_t_27));
      __pyx_t_27 = 0;

      /* "GPy/models/state_space_cython.pyx":971
 * 
 *         k_measurment = Y[k,:,:]
 *         if (np.any(np.isnan(k_measurment)) == False):             # <<<<<<<<<<<<<<
 * #        if np.any(np.isnan(k_measurment)):
 * #            raise ValueError("Nan measurements are currently not supported")
 */
      goto __pyx_L9;
    }

    /* "GPy/models/state_space_cython.pyx":981
 *                     p_dm = dm_pred, p_dP = dP_pred)
 *         else:
 *             if not np.all(np.isnan(k_measurment)):             # <<<<<<<<<<<<<<
 *                     raise ValueError("""Nan measurements are currently not supported if
 *                                      they are intermixed with not NaN measurements""")
 */
    /*else*/ {
      __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_n_s_np); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_27);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_27, __pyx_n_s_all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_isnan); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_27 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, ((PyObject *)__pyx_v_k_measurment)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_k_measurment));
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(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);
        }
      }
      __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_27) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_27);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_26 < 0)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_32 = ((!__pyx_t_26) != 0);
      if (unlikely(__pyx_t_32)) {

        /* "GPy/models/state_space_cython.pyx":982
 *         else:
 *             if not np.all(np.isnan(k_measurment)):
 *                     raise ValueError("""Nan measurements are currently not supported if             # <<<<<<<<<<<<<<
 *                                      they are intermixed with not NaN measurements""")
 *             else:
 */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 982, __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_ERR(0, 982, __pyx_L1_error)

        /* "GPy/models/state_space_cython.pyx":981
 *                     p_dm = dm_pred, p_dP = dP_pred)
 *         else:
 *             if not np.all(np.isnan(k_measurment)):             # <<<<<<<<<<<<<<
 *                     raise ValueError("""Nan measurements are currently not supported if
 *                                      they are intermixed with not NaN measurements""")
 */
      }

      /* "GPy/models/state_space_cython.pyx":985
 *                                      they are intermixed with not NaN measurements""")
 *             else:
 *                 m_upd = m_pred; P_upd = P_pred; dm_upd = dm_pred; dP_upd = dP_pred             # <<<<<<<<<<<<<<
 *                 if calc_log_likelihood:
 *                     log_likelihood_update = np.zeros((1,time_series_no))
 */
      /*else*/ {
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer);
          __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_23 < 0)) {
            PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
          }
          __pyx_pybuffernd_m_upd.diminfo[0].strides = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_upd.diminfo[0].shape = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_upd.diminfo[1].strides = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_upd.diminfo[1].shape = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 985, __pyx_L1_error)
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_m_pred));
        __Pyx_XDECREF_SET(__pyx_v_m_upd, __pyx_v_m_pred);
        __Pyx_INCREF(__pyx_v_P_pred);
        __Pyx_DECREF_SET(__pyx_v_P_upd, __pyx_v_P_pred);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer);
          __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_dm_pred), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
          if (unlikely(__pyx_t_23 < 0)) {
            PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 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_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
          }
          __pyx_pybuffernd_dm_upd.diminfo[0].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_upd.diminfo[0].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_upd.diminfo[1].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_upd.diminfo[1].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_upd.diminfo[2].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_upd.diminfo[2].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[2];
          if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 985, __pyx_L1_error)
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dm_pred));
        __Pyx_DECREF_SET(__pyx_v_dm_upd, ((PyArrayObject *)__pyx_v_dm_pred));
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer);
          __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_dP_pred), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
          if (unlikely(__pyx_t_23 < 0)) {
            PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 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_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
          }
          __pyx_pybuffernd_dP_upd.diminfo[0].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_upd.diminfo[0].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_upd.diminfo[1].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_upd.diminfo[1].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_upd.diminfo[2].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_upd.diminfo[2].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[2];
          if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 985, __pyx_L1_error)
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_dP_pred));
        __Pyx_DECREF_SET(__pyx_v_dP_upd, ((PyArrayObject *)__pyx_v_dP_pred));

        /* "GPy/models/state_space_cython.pyx":986
 *             else:
 *                 m_upd = m_pred; P_upd = P_pred; dm_upd = dm_pred; dP_upd = dP_pred
 *                 if calc_log_likelihood:             # <<<<<<<<<<<<<<
 *                     log_likelihood_update = np.zeros((1,time_series_no))
 *                 if calc_grad_log_likelihood:
 */
        __pyx_t_32 = (__pyx_v_calc_log_likelihood != 0);
        if (__pyx_t_32) {

          /* "GPy/models/state_space_cython.pyx":987
 *                 m_upd = m_pred; P_upd = P_pred; dm_upd = dm_pred; dP_upd = dP_pred
 *                 if calc_log_likelihood:
 *                     log_likelihood_update = np.zeros((1,time_series_no))             # <<<<<<<<<<<<<<
 *                 if calc_grad_log_likelihood:
 *                     d_log_likelihood_update = np.zeros((grad_params_no,time_series_no))
 */
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 987, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 987, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_27);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_time_series_no); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 987, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 987, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_INCREF(__pyx_int_1);
          __Pyx_GIVEREF(__pyx_int_1);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
          __Pyx_GIVEREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
          __pyx_t_2 = 0;
          __pyx_t_2 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_27))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_27);
            if (likely(__pyx_t_2)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_27);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_27, function);
            }
          }
          __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_27, __pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_27, __pyx_t_5);
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 987, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
          if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 987, __pyx_L1_error)
          __pyx_t_29 = ((PyArrayObject *)__pyx_t_4);
          {
            __Pyx_BufFmt_StackElem __pyx_stack[1];
            __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer);
            __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
            if (unlikely(__pyx_t_23 < 0)) {
              PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
              if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
            }
            __pyx_pybuffernd_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[1];
            if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 987, __pyx_L1_error)
          }
          __pyx_t_29 = 0;
          __Pyx_XDECREF_SET(__pyx_v_log_likelihood_update, ((PyArrayObject *)__pyx_t_4));
          __pyx_t_4 = 0;

          /* "GPy/models/state_space_cython.pyx":986
 *             else:
 *                 m_upd = m_pred; P_upd = P_pred; dm_upd = dm_pred; dP_upd = dP_pred
 *                 if calc_log_likelihood:             # <<<<<<<<<<<<<<
 *                     log_likelihood_update = np.zeros((1,time_series_no))
 *                 if calc_grad_log_likelihood:
 */
        }

        /* "GPy/models/state_space_cython.pyx":988
 *                 if calc_log_likelihood:
 *                     log_likelihood_update = np.zeros((1,time_series_no))
 *                 if calc_grad_log_likelihood:             # <<<<<<<<<<<<<<
 *                     d_log_likelihood_update = np.zeros((grad_params_no,time_series_no))
 * 
 */
        __pyx_t_32 = (__pyx_v_calc_grad_log_likelihood != 0);
        if (__pyx_t_32) {

          /* "GPy/models/state_space_cython.pyx":989
 *                     log_likelihood_update = np.zeros((1,time_series_no))
 *                 if calc_grad_log_likelihood:
 *                     d_log_likelihood_update = np.zeros((grad_params_no,time_series_no))             # <<<<<<<<<<<<<<
 * 
 * 
 */
          __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_n_s_np); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 989, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_27);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_27, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 989, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
          __pyx_t_27 = __Pyx_PyInt_From_int(__pyx_v_grad_params_no); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 989, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_27);
          __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_time_series_no); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 989, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 989, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_27);
          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_27);
          __Pyx_GIVEREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
          __pyx_t_27 = 0;
          __pyx_t_2 = 0;
          __pyx_t_2 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
            if (likely(__pyx_t_2)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_5, function);
            }
          }
          __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_2, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 989, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 989, __pyx_L1_error)
          __pyx_t_29 = ((PyArrayObject *)__pyx_t_4);
          {
            __Pyx_BufFmt_StackElem __pyx_stack[1];
            __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer);
            __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
            if (unlikely(__pyx_t_23 < 0)) {
              PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
              if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_d_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
            }
            __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[1];
            if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 989, __pyx_L1_error)
          }
          __pyx_t_29 = 0;
          __Pyx_XDECREF_SET(__pyx_v_d_log_likelihood_update, ((PyArrayObject *)__pyx_t_4));
          __pyx_t_4 = 0;

          /* "GPy/models/state_space_cython.pyx":988
 *                 if calc_log_likelihood:
 *                     log_likelihood_update = np.zeros((1,time_series_no))
 *                 if calc_grad_log_likelihood:             # <<<<<<<<<<<<<<
 *                     d_log_likelihood_update = np.zeros((grad_params_no,time_series_no))
 * 
 */
        }
      }
    }
    __pyx_L9:;

    /* "GPy/models/state_space_cython.pyx":992
 * 
 * 
 *         if calc_log_likelihood:             # <<<<<<<<<<<<<<
 *             log_likelihood += log_likelihood_update
 * 
 */
    __pyx_t_32 = (__pyx_v_calc_log_likelihood != 0);
    if (__pyx_t_32) {

      /* "GPy/models/state_space_cython.pyx":993
 * 
 *         if calc_log_likelihood:
 *             log_likelihood += log_likelihood_update             # <<<<<<<<<<<<<<
 * 
 *         if calc_grad_log_likelihood:
 */
      __pyx_t_4 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_log_likelihood), ((PyObject *)__pyx_v_log_likelihood_update)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 993, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 993, __pyx_L1_error)
      __pyx_t_18 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer);
        __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_23 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_v_log_likelihood, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
        }
        __pyx_pybuffernd_log_likelihood.diminfo[0].strides = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood.diminfo[0].shape = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood.diminfo[1].strides = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood.diminfo[1].shape = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 993, __pyx_L1_error)
      }
      __pyx_t_18 = 0;
      __Pyx_DECREF_SET(__pyx_v_log_likelihood, ((PyArrayObject *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "GPy/models/state_space_cython.pyx":992
 * 
 * 
 *         if calc_log_likelihood:             # <<<<<<<<<<<<<<
 *             log_likelihood += log_likelihood_update
 * 
 */
    }

    /* "GPy/models/state_space_cython.pyx":995
 *             log_likelihood += log_likelihood_update
 * 
 *         if calc_grad_log_likelihood:             # <<<<<<<<<<<<<<
 *             grad_log_likelihood += d_log_likelihood_update
 * 
 */
    __pyx_t_32 = (__pyx_v_calc_grad_log_likelihood != 0);
    if (__pyx_t_32) {

      /* "GPy/models/state_space_cython.pyx":996
 * 
 *         if calc_grad_log_likelihood:
 *             grad_log_likelihood += d_log_likelihood_update             # <<<<<<<<<<<<<<
 * 
 *         M[k+1,:,:] = m_upd # separate mean value for each time series
 */
      __pyx_t_4 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_grad_log_likelihood), ((PyObject *)__pyx_v_d_log_likelihood_update)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 996, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 996, __pyx_L1_error)
      __pyx_t_19 = ((PyArrayObject *)__pyx_t_4);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer);
        __pyx_t_23 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_23 < 0)) {
          PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_v_grad_log_likelihood, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 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_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
        }
        __pyx_pybuffernd_grad_log_likelihood.diminfo[0].strides = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_grad_log_likelihood.diminfo[0].shape = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_grad_log_likelihood.diminfo[1].strides = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_grad_log_likelihood.diminfo[1].shape = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_23 < 0)) __PYX_ERR(0, 996, __pyx_L1_error)
      }
      __pyx_t_19 = 0;
      __Pyx_DECREF_SET(__pyx_v_grad_log_likelihood, ((PyArrayObject *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "GPy/models/state_space_cython.pyx":995
 *             log_likelihood += log_likelihood_update
 * 
 *         if calc_grad_log_likelihood:             # <<<<<<<<<<<<<<
 *             grad_log_likelihood += d_log_likelihood_update
 * 
 */
    }

    /* "GPy/models/state_space_cython.pyx":998
 *             grad_log_likelihood += d_log_likelihood_update
 * 
 *         M[k+1,:,:] = m_upd # separate mean value for each time series             # <<<<<<<<<<<<<<
 *         P[k+1,:,:] = P_upd[0]
 * 
 */
    __pyx_t_4 = __Pyx_PyInt_From_long((__pyx_v_k + 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 998, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 998, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_INCREF(__pyx_slice__10);
    __Pyx_GIVEREF(__pyx_slice__10);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_slice__10);
    __Pyx_INCREF(__pyx_slice__10);
    __Pyx_GIVEREF(__pyx_slice__10);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_slice__10);
    __pyx_t_4 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_M), __pyx_t_5, ((PyObject *)__pyx_v_m_upd)) < 0)) __PYX_ERR(0, 998, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "GPy/models/state_space_cython.pyx":999
 * 
 *         M[k+1,:,:] = m_upd # separate mean value for each time series
 *         P[k+1,:,:] = P_upd[0]             # <<<<<<<<<<<<<<
 * 
 *     return (M, P, log_likelihood, grad_log_likelihood, p_dynamic_callables.reset(False))
 */
    if (unlikely(__pyx_v_P_upd == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 999, __pyx_L1_error)
    }
    __pyx_t_5 = PyTuple_GET_ITEM(__pyx_v_P_upd, 0);
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyInt_From_long((__pyx_v_k + 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 999, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 999, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_INCREF(__pyx_slice__10);
    __Pyx_GIVEREF(__pyx_slice__10);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_slice__10);
    __Pyx_INCREF(__pyx_slice__10);
    __Pyx_GIVEREF(__pyx_slice__10);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_slice__10);
    __pyx_t_4 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_P), __pyx_t_6, __pyx_t_5) < 0)) __PYX_ERR(0, 999, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }

  /* "GPy/models/state_space_cython.pyx":1001
 *         P[k+1,:,:] = P_upd[0]
 * 
 *     return (M, P, log_likelihood, grad_log_likelihood, p_dynamic_callables.reset(False))             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_33.__pyx_n = 1;
  __pyx_t_33.compute_derivatives = 0;
  __pyx_t_5 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->reset(__pyx_v_p_dynamic_callables, 0, &__pyx_t_33); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_M));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_M));
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_M));
  __Pyx_INCREF(((PyObject *)__pyx_v_P));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_P));
  PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_P));
  __Pyx_INCREF(((PyObject *)__pyx_v_log_likelihood));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_log_likelihood));
  PyTuple_SET_ITEM(__pyx_t_6, 2, ((PyObject *)__pyx_v_log_likelihood));
  __Pyx_INCREF(((PyObject *)__pyx_v_grad_log_likelihood));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_grad_log_likelihood));
  PyTuple_SET_ITEM(__pyx_t_6, 3, ((PyObject *)__pyx_v_grad_log_likelihood));
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "GPy/models/state_space_cython.pyx":912
 * 
 * @cython.boundscheck(False)
 * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables,             # <<<<<<<<<<<<<<
 *                                   Measurement_Callables_Cython p_measurement_callables, X, Y,
 *                                   np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_27);
  __Pyx_XDECREF(__pyx_t_28);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_M.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_init.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_init.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_k_measurment.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_init.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_prev_mean.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GPy.models.state_space_cython._cont_discr_kalman_filter_raw_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_M.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_init.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_init.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_k_measurment.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_init.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_prev_mean.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_M);
  __Pyx_XDECREF((PyObject *)__pyx_v_P);
  __Pyx_XDECREF((PyObject *)__pyx_v_U);
  __Pyx_XDECREF((PyObject *)__pyx_v_S);
  __Pyx_XDECREF((PyObject *)__pyx_v_Vh);
  __Pyx_XDECREF(__pyx_v_P_upd);
  __Pyx_XDECREF((PyObject *)__pyx_v_log_likelihood);
  __Pyx_XDECREF((PyObject *)__pyx_v_grad_log_likelihood);
  __Pyx_XDECREF((PyObject *)__pyx_v_dm_upd);
  __Pyx_XDECREF((PyObject *)__pyx_v_dP_upd);
  __Pyx_XDECREF((PyObject *)__pyx_v_prev_mean);
  __Pyx_XDECREF((PyObject *)__pyx_v_k_measurment);
  __Pyx_XDECREF((PyObject *)__pyx_v_m_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_m_upd);
  __Pyx_XDECREF(__pyx_v_P_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_dm_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_dP_pred);
  __Pyx_XDECREF((PyObject *)__pyx_v_log_likelihood_update);
  __Pyx_XDECREF((PyObject *)__pyx_v_d_log_likelihood_update);
  __Pyx_XDECREF((PyObject *)__pyx_v_P_init);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Dynamic_Callables_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_7__pyx_unpickle_Dynamic_Callables_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_7__pyx_unpickle_Dynamic_Callables_Cython = {"__pyx_unpickle_Dynamic_Callables_Cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_7__pyx_unpickle_Dynamic_Callables_Cython, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_7__pyx_unpickle_Dynamic_Callables_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Dynamic_Callables_Cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Dynamic_Callables_Cython", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Dynamic_Callables_Cython", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Dynamic_Callables_Cython") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Dynamic_Callables_Cython", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_Dynamic_Callables_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_6__pyx_unpickle_Dynamic_Callables_Cython(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_6__pyx_unpickle_Dynamic_Callables_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Dynamic_Callables_Cython", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd41d8cd:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xd41d8cd) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd41d8cd:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = Dynamic_Callables_Cython.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xd41d8cd:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Dynamic_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xd4, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd41d8cd:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = Dynamic_Callables_Cython.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Dynamic_Callables_Cython__set_state(<Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = Dynamic_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Dynamic_Callables_Cython__set_state(<Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = Dynamic_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Dynamic_Callables_Cython__set_state(<Dynamic_Callables_Cython> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Dynamic_Callables_Cython__set_state(Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Dynamic_Callables_Cython__set_state(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = Dynamic_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Dynamic_Callables_Cython__set_state(<Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Dynamic_Callables_Cython__set_state(<Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Dynamic_Callables_Cython__set_state(Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Dynamic_Callables_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_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("GPy.models.state_space_cython.__pyx_unpickle_Dynamic_Callables_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Dynamic_Callables_Cython__set_state(<Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Dynamic_Callables_Cython__set_state(Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */

static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Dynamic_Callables_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  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("__pyx_unpickle_Dynamic_Callables_Cython__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Dynamic_Callables_Cython__set_state(Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 12, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_2 > 0) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 12, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Dynamic_Callables_Cython__set_state(Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[0])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 13, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Dynamic_Callables_Cython__set_state(Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Dynamic_Callables_Cython__set_state(<Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Dynamic_Callables_Cython__set_state(Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  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("GPy.models.state_space_cython.__pyx_unpickle_Dynamic_Callables_Cython__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Measurement_Callables_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_9__pyx_unpickle_Measurement_Callables_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_9__pyx_unpickle_Measurement_Callables_Cython = {"__pyx_unpickle_Measurement_Callables_Cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_9__pyx_unpickle_Measurement_Callables_Cython, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_9__pyx_unpickle_Measurement_Callables_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Measurement_Callables_Cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Measurement_Callables_Cython", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Measurement_Callables_Cython", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Measurement_Callables_Cython") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Measurement_Callables_Cython", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_Measurement_Callables_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_8__pyx_unpickle_Measurement_Callables_Cython(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_8__pyx_unpickle_Measurement_Callables_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Measurement_Callables_Cython", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd41d8cd:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xd41d8cd) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd41d8cd:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = Measurement_Callables_Cython.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xd41d8cd:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Measurement_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xd4, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd41d8cd:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = Measurement_Callables_Cython.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Measurement_Callables_Cython__set_state(<Measurement_Callables_Cython> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = Measurement_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Measurement_Callables_Cython__set_state(<Measurement_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = Measurement_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Measurement_Callables_Cython__set_state(<Measurement_Callables_Cython> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Measurement_Callables_Cython__set_state(Measurement_Callables_Cython __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Measurement_Callables_Cython__set_state(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = Measurement_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Measurement_Callables_Cython__set_state(<Measurement_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Measurement_Callables_Cython__set_state(<Measurement_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Measurement_Callables_Cython__set_state(Measurement_Callables_Cython __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Measurement_Callables_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_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("GPy.models.state_space_cython.__pyx_unpickle_Measurement_Callables_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Measurement_Callables_Cython__set_state(<Measurement_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Measurement_Callables_Cython__set_state(Measurement_Callables_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */

static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Measurement_Callables_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  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("__pyx_unpickle_Measurement_Callables_Cython__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Measurement_Callables_Cython__set_state(Measurement_Callables_Cython __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 12, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_2 > 0) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 12, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Measurement_Callables_Cython__set_state(Measurement_Callables_Cython __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[0])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 13, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Measurement_Callables_Cython__set_state(Measurement_Callables_Cython __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Measurement_Callables_Cython__set_state(<Measurement_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Measurement_Callables_Cython__set_state(Measurement_Callables_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  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("GPy.models.state_space_cython.__pyx_unpickle_Measurement_Callables_Cython__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_R_handling_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_11__pyx_unpickle_R_handling_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_11__pyx_unpickle_R_handling_Cython = {"__pyx_unpickle_R_handling_Cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_11__pyx_unpickle_R_handling_Cython, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_11__pyx_unpickle_R_handling_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_R_handling_Cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_R_handling_Cython", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_R_handling_Cython", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_R_handling_Cython") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_R_handling_Cython", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_R_handling_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_10__pyx_unpickle_R_handling_Cython(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_10__pyx_unpickle_R_handling_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_R_handling_Cython", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x9e97ca7:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9e97ca7 = (R, R_square_root, R_time_var_index, dR, index, svd_each_time))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x9e97ca7) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x9e97ca7:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9e97ca7 = (R, R_square_root, R_time_var_index, dR, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = R_handling_Cython.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x9e97ca7:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9e97ca7 = (R, R_square_root, R_time_var_index, dR, index, svd_each_time))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = R_handling_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x9e, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x9e97ca7:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9e97ca7 = (R, R_square_root, R_time_var_index, dR, index, svd_each_time))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9e97ca7 = (R, R_square_root, R_time_var_index, dR, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = R_handling_Cython.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_R_handling_Cython__set_state(<R_handling_Cython> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_R_handling_Cython), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9e97ca7 = (R, R_square_root, R_time_var_index, dR, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = R_handling_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_R_handling_Cython__set_state(<R_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = R_handling_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_R_handling_Cython__set_state(<R_handling_Cython> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_R_handling_Cython__set_state(R_handling_Cython __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_R_handling_Cython__set_state(((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9e97ca7 = (R, R_square_root, R_time_var_index, dR, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = R_handling_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_R_handling_Cython__set_state(<R_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_R_handling_Cython__set_state(<R_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_R_handling_Cython__set_state(R_handling_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.R = __pyx_state[0]; __pyx_result.R_square_root = __pyx_state[1]; __pyx_result.R_time_var_index = __pyx_state[2]; __pyx_result.dR = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_R_handling_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_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("GPy.models.state_space_cython.__pyx_unpickle_R_handling_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_R_handling_Cython__set_state(<R_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_R_handling_Cython__set_state(R_handling_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.R = __pyx_state[0]; __pyx_result.R_square_root = __pyx_state[1]; __pyx_result.R_time_var_index = __pyx_state[2]; __pyx_result.dR = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_R_handling_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  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("__pyx_unpickle_R_handling_Cython__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_R_handling_Cython__set_state(R_handling_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.R = __pyx_state[0]; __pyx_result.R_square_root = __pyx_state[1]; __pyx_result.R_time_var_index = __pyx_state[2]; __pyx_result.dR = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->R);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->R));
  __pyx_v___pyx_result->R = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->R_square_root);
  __Pyx_DECREF(__pyx_v___pyx_result->R_square_root);
  __pyx_v___pyx_result->R_square_root = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __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_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->R_time_var_index = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->dR);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->dR));
  __pyx_v___pyx_result->dR = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->index);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->index));
  __pyx_v___pyx_result->index = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->svd_each_time = __pyx_t_3;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_R_handling_Cython__set_state(R_handling_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.R = __pyx_state[0]; __pyx_result.R_square_root = __pyx_state[1]; __pyx_result.R_time_var_index = __pyx_state[2]; __pyx_result.dR = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 6) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result.R = __pyx_state[0]; __pyx_result.R_square_root = __pyx_state[1]; __pyx_result.R_time_var_index = __pyx_state[2]; __pyx_result.dR = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[6])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_R_handling_Cython__set_state(R_handling_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.R = __pyx_state[0]; __pyx_result.R_square_root = __pyx_state[1]; __pyx_result.R_time_var_index = __pyx_state[2]; __pyx_result.dR = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_R_handling_Cython__set_state(<R_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_R_handling_Cython__set_state(R_handling_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.R = __pyx_state[0]; __pyx_result.R_square_root = __pyx_state[1]; __pyx_result.R_time_var_index = __pyx_state[2]; __pyx_result.dR = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_R_handling_Cython__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Std_Measurement_Callables_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_13__pyx_unpickle_Std_Measurement_Callables_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_13__pyx_unpickle_Std_Measurement_Callables_Cython = {"__pyx_unpickle_Std_Measurement_Callables_Cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_13__pyx_unpickle_Std_Measurement_Callables_Cython, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_13__pyx_unpickle_Std_Measurement_Callables_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Std_Measurement_Callables_Cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Std_Measurement_Callables_Cython", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Std_Measurement_Callables_Cython", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Std_Measurement_Callables_Cython") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Std_Measurement_Callables_Cython", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_Std_Measurement_Callables_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_12__pyx_unpickle_Std_Measurement_Callables_Cython(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_12__pyx_unpickle_Std_Measurement_Callables_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Std_Measurement_Callables_Cython", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x706c35f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x706c35f = (H, H_time_var_index, R, R_square_root, R_time_var_index, dH, dR, index, svd_each_time))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x706c35f) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x706c35f:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x706c35f = (H, H_time_var_index, R, R_square_root, R_time_var_index, dH, dR, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Std_Measurement_Callables_Cython.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x706c35f:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x706c35f = (H, H_time_var_index, R, R_square_root, R_time_var_index, dH, dR, index, svd_each_time))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Std_Measurement_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x70, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x706c35f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x706c35f = (H, H_time_var_index, R, R_square_root, R_time_var_index, dH, dR, index, svd_each_time))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x706c35f = (H, H_time_var_index, R, R_square_root, R_time_var_index, dH, dR, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Std_Measurement_Callables_Cython.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(<Std_Measurement_Callables_Cython> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x706c35f = (H, H_time_var_index, R, R_square_root, R_time_var_index, dH, dR, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Std_Measurement_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(<Std_Measurement_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = Std_Measurement_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(<Std_Measurement_Callables_Cython> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(Std_Measurement_Callables_Cython __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Std_Measurement_Callables_Cython__set_state(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x706c35f = (H, H_time_var_index, R, R_square_root, R_time_var_index, dH, dR, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Std_Measurement_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(<Std_Measurement_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(<Std_Measurement_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(Std_Measurement_Callables_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.H = __pyx_state[0]; __pyx_result.H_time_var_index = __pyx_state[1]; __pyx_result.R = __pyx_state[2]; __pyx_result.R_square_root = __pyx_state[3]; __pyx_result.R_time_var_index = __pyx_state[4]; __pyx_result.dH = __pyx_state[5]; __pyx_result.dR = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Std_Measurement_Callables_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_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("GPy.models.state_space_cython.__pyx_unpickle_Std_Measurement_Callables_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(<Std_Measurement_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(Std_Measurement_Callables_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.H = __pyx_state[0]; __pyx_result.H_time_var_index = __pyx_state[1]; __pyx_result.R = __pyx_state[2]; __pyx_result.R_square_root = __pyx_state[3]; __pyx_result.R_time_var_index = __pyx_state[4]; __pyx_result.dH = __pyx_state[5]; __pyx_result.dR = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Std_Measurement_Callables_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  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("__pyx_unpickle_Std_Measurement_Callables_Cython__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(Std_Measurement_Callables_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.H = __pyx_state[0]; __pyx_result.H_time_var_index = __pyx_state[1]; __pyx_result.R = __pyx_state[2]; __pyx_result.R_square_root = __pyx_state[3]; __pyx_result.R_time_var_index = __pyx_state[4]; __pyx_result.dH = __pyx_state[5]; __pyx_result.dR = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->H);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->H));
  __pyx_v___pyx_result->H = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __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_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->H_time_var_index = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.R);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.R));
  __pyx_v___pyx_result->__pyx_base.R = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.R_square_root);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.R_square_root);
  __pyx_v___pyx_result->__pyx_base.R_square_root = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __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_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.R_time_var_index = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->dH);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->dH));
  __pyx_v___pyx_result->dH = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.dR);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.dR));
  __pyx_v___pyx_result->__pyx_base.dR = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.index);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.index));
  __pyx_v___pyx_result->__pyx_base.index = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.svd_each_time = __pyx_t_3;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(Std_Measurement_Callables_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.H = __pyx_state[0]; __pyx_result.H_time_var_index = __pyx_state[1]; __pyx_result.R = __pyx_state[2]; __pyx_result.R_square_root = __pyx_state[3]; __pyx_result.R_time_var_index = __pyx_state[4]; __pyx_result.dH = __pyx_state[5]; __pyx_result.dR = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 9) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result.H = __pyx_state[0]; __pyx_result.H_time_var_index = __pyx_state[1]; __pyx_result.R = __pyx_state[2]; __pyx_result.R_square_root = __pyx_state[3]; __pyx_result.R_time_var_index = __pyx_state[4]; __pyx_result.dH = __pyx_state[5]; __pyx_result.dR = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[9])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(Std_Measurement_Callables_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.H = __pyx_state[0]; __pyx_result.H_time_var_index = __pyx_state[1]; __pyx_result.R = __pyx_state[2]; __pyx_result.R_square_root = __pyx_state[3]; __pyx_result.R_time_var_index = __pyx_state[4]; __pyx_result.dH = __pyx_state[5]; __pyx_result.dR = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(<Std_Measurement_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Std_Measurement_Callables_Cython__set_state(Std_Measurement_Callables_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.H = __pyx_state[0]; __pyx_result.H_time_var_index = __pyx_state[1]; __pyx_result.R = __pyx_state[2]; __pyx_result.R_square_root = __pyx_state[3]; __pyx_result.R_time_var_index = __pyx_state[4]; __pyx_result.dH = __pyx_state[5]; __pyx_result.dR = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_Std_Measurement_Callables_Cython__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Q_handling_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_15__pyx_unpickle_Q_handling_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_15__pyx_unpickle_Q_handling_Cython = {"__pyx_unpickle_Q_handling_Cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_15__pyx_unpickle_Q_handling_Cython, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_15__pyx_unpickle_Q_handling_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Q_handling_Cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Q_handling_Cython", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Q_handling_Cython", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Q_handling_Cython") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Q_handling_Cython", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_Q_handling_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_14__pyx_unpickle_Q_handling_Cython(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_14__pyx_unpickle_Q_handling_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Q_handling_Cython", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x77b5360:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x77b5360 = (Q, Q_square_root, Q_time_var_index, dQ, index, svd_each_time))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x77b5360) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x77b5360:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x77b5360 = (Q, Q_square_root, Q_time_var_index, dQ, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Q_handling_Cython.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x77b5360:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x77b5360 = (Q, Q_square_root, Q_time_var_index, dQ, index, svd_each_time))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Q_handling_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x77, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x77b5360:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x77b5360 = (Q, Q_square_root, Q_time_var_index, dQ, index, svd_each_time))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x77b5360 = (Q, Q_square_root, Q_time_var_index, dQ, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Q_handling_Cython.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Q_handling_Cython__set_state(<Q_handling_Cython> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_Q_handling_Cython), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x77b5360 = (Q, Q_square_root, Q_time_var_index, dQ, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Q_handling_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Q_handling_Cython__set_state(<Q_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = Q_handling_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Q_handling_Cython__set_state(<Q_handling_Cython> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Q_handling_Cython__set_state(Q_handling_Cython __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Q_handling_Cython__set_state(((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x77b5360 = (Q, Q_square_root, Q_time_var_index, dQ, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Q_handling_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Q_handling_Cython__set_state(<Q_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Q_handling_Cython__set_state(<Q_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Q_handling_Cython__set_state(Q_handling_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.Q = __pyx_state[0]; __pyx_result.Q_square_root = __pyx_state[1]; __pyx_result.Q_time_var_index = __pyx_state[2]; __pyx_result.dQ = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Q_handling_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_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("GPy.models.state_space_cython.__pyx_unpickle_Q_handling_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Q_handling_Cython__set_state(<Q_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Q_handling_Cython__set_state(Q_handling_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.Q = __pyx_state[0]; __pyx_result.Q_square_root = __pyx_state[1]; __pyx_result.Q_time_var_index = __pyx_state[2]; __pyx_result.dQ = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Q_handling_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  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("__pyx_unpickle_Q_handling_Cython__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Q_handling_Cython__set_state(Q_handling_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.Q = __pyx_state[0]; __pyx_result.Q_square_root = __pyx_state[1]; __pyx_result.Q_time_var_index = __pyx_state[2]; __pyx_result.dQ = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->Q);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->Q));
  __pyx_v___pyx_result->Q = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->Q_square_root);
  __Pyx_DECREF(__pyx_v___pyx_result->Q_square_root);
  __pyx_v___pyx_result->Q_square_root = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __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_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->Q_time_var_index = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->dQ);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->dQ));
  __pyx_v___pyx_result->dQ = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->index);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->index));
  __pyx_v___pyx_result->index = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->svd_each_time = __pyx_t_3;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Q_handling_Cython__set_state(Q_handling_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.Q = __pyx_state[0]; __pyx_result.Q_square_root = __pyx_state[1]; __pyx_result.Q_time_var_index = __pyx_state[2]; __pyx_result.dQ = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 6) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result.Q = __pyx_state[0]; __pyx_result.Q_square_root = __pyx_state[1]; __pyx_result.Q_time_var_index = __pyx_state[2]; __pyx_result.dQ = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[6])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Q_handling_Cython__set_state(Q_handling_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.Q = __pyx_state[0]; __pyx_result.Q_square_root = __pyx_state[1]; __pyx_result.Q_time_var_index = __pyx_state[2]; __pyx_result.dQ = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Q_handling_Cython__set_state(<Q_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Q_handling_Cython__set_state(Q_handling_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.Q = __pyx_state[0]; __pyx_result.Q_square_root = __pyx_state[1]; __pyx_result.Q_time_var_index = __pyx_state[2]; __pyx_result.dQ = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_Q_handling_Cython__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Std_Dynamic_Callables_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17__pyx_unpickle_Std_Dynamic_Callables_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_17__pyx_unpickle_Std_Dynamic_Callables_Cython = {"__pyx_unpickle_Std_Dynamic_Callables_Cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_17__pyx_unpickle_Std_Dynamic_Callables_Cython, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17__pyx_unpickle_Std_Dynamic_Callables_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Std_Dynamic_Callables_Cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Std_Dynamic_Callables_Cython", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Std_Dynamic_Callables_Cython", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Std_Dynamic_Callables_Cython") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Std_Dynamic_Callables_Cython", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_Std_Dynamic_Callables_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_16__pyx_unpickle_Std_Dynamic_Callables_Cython(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_16__pyx_unpickle_Std_Dynamic_Callables_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Std_Dynamic_Callables_Cython", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xdff0f56:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xdff0f56 = (A, A_time_var_index, Q, Q_square_root, Q_time_var_index, dA, dQ, index, svd_each_time))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xdff0f56) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xdff0f56:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xdff0f56 = (A, A_time_var_index, Q, Q_square_root, Q_time_var_index, dA, dQ, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Std_Dynamic_Callables_Cython.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xdff0f56:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xdff0f56 = (A, A_time_var_index, Q, Q_square_root, Q_time_var_index, dA, dQ, index, svd_each_time))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Std_Dynamic_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xdf, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xdff0f56:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xdff0f56 = (A, A_time_var_index, Q, Q_square_root, Q_time_var_index, dA, dQ, index, svd_each_time))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xdff0f56 = (A, A_time_var_index, Q, Q_square_root, Q_time_var_index, dA, dQ, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Std_Dynamic_Callables_Cython.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(<Std_Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xdff0f56 = (A, A_time_var_index, Q, Q_square_root, Q_time_var_index, dA, dQ, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Std_Dynamic_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(<Std_Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = Std_Dynamic_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(<Std_Dynamic_Callables_Cython> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(Std_Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xdff0f56 = (A, A_time_var_index, Q, Q_square_root, Q_time_var_index, dA, dQ, index, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = Std_Dynamic_Callables_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(<Std_Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(<Std_Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(Std_Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.A = __pyx_state[0]; __pyx_result.A_time_var_index = __pyx_state[1]; __pyx_result.Q = __pyx_state[2]; __pyx_result.Q_square_root = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.dA = __pyx_state[5]; __pyx_result.dQ = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Std_Dynamic_Callables_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_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("GPy.models.state_space_cython.__pyx_unpickle_Std_Dynamic_Callables_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(<Std_Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(Std_Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.A = __pyx_state[0]; __pyx_result.A_time_var_index = __pyx_state[1]; __pyx_result.Q = __pyx_state[2]; __pyx_result.Q_square_root = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.dA = __pyx_state[5]; __pyx_result.dQ = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  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("__pyx_unpickle_Std_Dynamic_Callables_Cython__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(Std_Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.A = __pyx_state[0]; __pyx_result.A_time_var_index = __pyx_state[1]; __pyx_result.Q = __pyx_state[2]; __pyx_result.Q_square_root = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.dA = __pyx_state[5]; __pyx_result.dQ = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->A);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->A));
  __pyx_v___pyx_result->A = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __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_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->A_time_var_index = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.Q);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.Q));
  __pyx_v___pyx_result->__pyx_base.Q = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.Q_square_root);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.Q_square_root);
  __pyx_v___pyx_result->__pyx_base.Q_square_root = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __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_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.Q_time_var_index = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->dA);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->dA));
  __pyx_v___pyx_result->dA = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.dQ);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.dQ));
  __pyx_v___pyx_result->__pyx_base.dQ = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.index);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.index));
  __pyx_v___pyx_result->__pyx_base.index = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.svd_each_time = __pyx_t_3;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(Std_Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.A = __pyx_state[0]; __pyx_result.A_time_var_index = __pyx_state[1]; __pyx_result.Q = __pyx_state[2]; __pyx_result.Q_square_root = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.dA = __pyx_state[5]; __pyx_result.dQ = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 9) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result.A = __pyx_state[0]; __pyx_result.A_time_var_index = __pyx_state[1]; __pyx_result.Q = __pyx_state[2]; __pyx_result.Q_square_root = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.dA = __pyx_state[5]; __pyx_result.dQ = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[9])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(Std_Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.A = __pyx_state[0]; __pyx_result.A_time_var_index = __pyx_state[1]; __pyx_result.Q = __pyx_state[2]; __pyx_result.Q_square_root = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.dA = __pyx_state[5]; __pyx_result.dQ = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(<Std_Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Std_Dynamic_Callables_Cython__set_state(Std_Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.A = __pyx_state[0]; __pyx_result.A_time_var_index = __pyx_state[1]; __pyx_result.Q = __pyx_state[2]; __pyx_result.Q_square_root = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.dA = __pyx_state[5]; __pyx_result.dQ = __pyx_state[6]; __pyx_result.index = __pyx_state[7]; __pyx_result.svd_each_time = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_Std_Dynamic_Callables_Cython__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_AQcompute_batch_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_19__pyx_unpickle_AQcompute_batch_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_19__pyx_unpickle_AQcompute_batch_Cython = {"__pyx_unpickle_AQcompute_batch_Cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_19__pyx_unpickle_AQcompute_batch_Cython, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_19__pyx_unpickle_AQcompute_batch_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_AQcompute_batch_Cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_AQcompute_batch_Cython", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_AQcompute_batch_Cython", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_AQcompute_batch_Cython") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_AQcompute_batch_Cython", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_AQcompute_batch_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_18__pyx_unpickle_AQcompute_batch_Cython(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_18__pyx_unpickle_AQcompute_batch_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_AQcompute_batch_Cython", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x146e1f7:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x146e1f7 = (As, Q, Q_square_root, Q_svd_dict, Q_time_var_index, Qs, dAs, dQ, dQs, index, last_k, reconstruct_indices, svd_each_time))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x146e1f7) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x146e1f7:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x146e1f7 = (As, Q, Q_square_root, Q_svd_dict, Q_time_var_index, Qs, dAs, dQ, dQs, index, last_k, reconstruct_indices, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = AQcompute_batch_Cython.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x146e1f7:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x146e1f7 = (As, Q, Q_square_root, Q_svd_dict, Q_time_var_index, Qs, dAs, dQ, dQs, index, last_k, reconstruct_indices, svd_each_time))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = AQcompute_batch_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x14, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x146e1f7:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x146e1f7 = (As, Q, Q_square_root, Q_svd_dict, Q_time_var_index, Qs, dAs, dQ, dQs, index, last_k, reconstruct_indices, svd_each_time))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x146e1f7 = (As, Q, Q_square_root, Q_svd_dict, Q_time_var_index, Qs, dAs, dQ, dQs, index, last_k, reconstruct_indices, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = AQcompute_batch_Cython.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_AQcompute_batch_Cython__set_state(<AQcompute_batch_Cython> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_3GPy_6models_18state_space_cython_AQcompute_batch_Cython), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x146e1f7 = (As, Q, Q_square_root, Q_svd_dict, Q_time_var_index, Qs, dAs, dQ, dQs, index, last_k, reconstruct_indices, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = AQcompute_batch_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_AQcompute_batch_Cython__set_state(<AQcompute_batch_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = AQcompute_batch_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_AQcompute_batch_Cython__set_state(<AQcompute_batch_Cython> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_AQcompute_batch_Cython__set_state(AQcompute_batch_Cython __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_AQcompute_batch_Cython__set_state(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x146e1f7 = (As, Q, Q_square_root, Q_svd_dict, Q_time_var_index, Qs, dAs, dQ, dQs, index, last_k, reconstruct_indices, svd_each_time))" % __pyx_checksum)
 *     __pyx_result = AQcompute_batch_Cython.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_AQcompute_batch_Cython__set_state(<AQcompute_batch_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_AQcompute_batch_Cython__set_state(<AQcompute_batch_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_AQcompute_batch_Cython__set_state(AQcompute_batch_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.As = __pyx_state[0]; __pyx_result.Q = __pyx_state[1]; __pyx_result.Q_square_root = __pyx_state[2]; __pyx_result.Q_svd_dict = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.Qs = __pyx_state[5]; __pyx_result.dAs = __pyx_state[6]; __pyx_result.dQ = __pyx_state[7]; __pyx_result.dQs = __pyx_state[8]; __pyx_result.index = __pyx_state[9]; __pyx_result.last_k = __pyx_state[10]; __pyx_result.reconstruct_indices = __pyx_state[11]; __pyx_result.svd_each_time = __pyx_state[12]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_AQcompute_batch_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_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("GPy.models.state_space_cython.__pyx_unpickle_AQcompute_batch_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_AQcompute_batch_Cython__set_state(<AQcompute_batch_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_AQcompute_batch_Cython__set_state(AQcompute_batch_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.As = __pyx_state[0]; __pyx_result.Q = __pyx_state[1]; __pyx_result.Q_square_root = __pyx_state[2]; __pyx_result.Q_svd_dict = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.Qs = __pyx_state[5]; __pyx_result.dAs = __pyx_state[6]; __pyx_result.dQ = __pyx_state[7]; __pyx_result.dQs = __pyx_state[8]; __pyx_result.index = __pyx_state[9]; __pyx_result.last_k = __pyx_state[10]; __pyx_result.reconstruct_indices = __pyx_state[11]; __pyx_result.svd_each_time = __pyx_state[12]
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_3GPy_6models_18state_space_cython___pyx_unpickle_AQcompute_batch_Cython__set_state(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  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("__pyx_unpickle_AQcompute_batch_Cython__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_AQcompute_batch_Cython__set_state(AQcompute_batch_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.As = __pyx_state[0]; __pyx_result.Q = __pyx_state[1]; __pyx_result.Q_square_root = __pyx_state[2]; __pyx_result.Q_svd_dict = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.Qs = __pyx_state[5]; __pyx_result.dAs = __pyx_state[6]; __pyx_result.dQ = __pyx_state[7]; __pyx_result.dQs = __pyx_state[8]; __pyx_result.index = __pyx_state[9]; __pyx_result.last_k = __pyx_state[10]; __pyx_result.reconstruct_indices = __pyx_state[11]; __pyx_result.svd_each_time = __pyx_state[12]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[13])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->As);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->As));
  __pyx_v___pyx_result->As = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.Q);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.Q));
  __pyx_v___pyx_result->__pyx_base.Q = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.Q_square_root);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.Q_square_root);
  __pyx_v___pyx_result->__pyx_base.Q_square_root = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->Q_svd_dict);
  __Pyx_DECREF(__pyx_v___pyx_result->Q_svd_dict);
  __pyx_v___pyx_result->Q_svd_dict = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __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_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.Q_time_var_index = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->Qs);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->Qs));
  __pyx_v___pyx_result->Qs = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->dAs);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->dAs));
  __pyx_v___pyx_result->dAs = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.dQ);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.dQ));
  __pyx_v___pyx_result->__pyx_base.dQ = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->dQs);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->dQs));
  __pyx_v___pyx_result->dQs = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.index);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.index));
  __pyx_v___pyx_result->__pyx_base.index = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __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_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->last_k = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->reconstruct_indices);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->reconstruct_indices));
  __pyx_v___pyx_result->reconstruct_indices = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 12, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.svd_each_time = __pyx_t_3;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_AQcompute_batch_Cython__set_state(AQcompute_batch_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.As = __pyx_state[0]; __pyx_result.Q = __pyx_state[1]; __pyx_result.Q_square_root = __pyx_state[2]; __pyx_result.Q_svd_dict = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.Qs = __pyx_state[5]; __pyx_result.dAs = __pyx_state[6]; __pyx_result.dQ = __pyx_state[7]; __pyx_result.dQs = __pyx_state[8]; __pyx_result.index = __pyx_state[9]; __pyx_result.last_k = __pyx_state[10]; __pyx_result.reconstruct_indices = __pyx_state[11]; __pyx_result.svd_each_time = __pyx_state[12]
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[13])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 13) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result.As = __pyx_state[0]; __pyx_result.Q = __pyx_state[1]; __pyx_result.Q_square_root = __pyx_state[2]; __pyx_result.Q_svd_dict = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.Qs = __pyx_state[5]; __pyx_result.dAs = __pyx_state[6]; __pyx_result.dQ = __pyx_state[7]; __pyx_result.dQs = __pyx_state[8]; __pyx_result.index = __pyx_state[9]; __pyx_result.last_k = __pyx_state[10]; __pyx_result.reconstruct_indices = __pyx_state[11]; __pyx_result.svd_each_time = __pyx_state[12]
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[13])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 13, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_AQcompute_batch_Cython__set_state(AQcompute_batch_Cython __pyx_result, tuple __pyx_state):
 *     __pyx_result.As = __pyx_state[0]; __pyx_result.Q = __pyx_state[1]; __pyx_result.Q_square_root = __pyx_state[2]; __pyx_result.Q_svd_dict = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.Qs = __pyx_state[5]; __pyx_result.dAs = __pyx_state[6]; __pyx_result.dQ = __pyx_state[7]; __pyx_result.dQs = __pyx_state[8]; __pyx_result.index = __pyx_state[9]; __pyx_result.last_k = __pyx_state[10]; __pyx_result.reconstruct_indices = __pyx_state[11]; __pyx_result.svd_each_time = __pyx_state[12]
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[13])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_AQcompute_batch_Cython__set_state(<AQcompute_batch_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_AQcompute_batch_Cython__set_state(AQcompute_batch_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.As = __pyx_state[0]; __pyx_result.Q = __pyx_state[1]; __pyx_result.Q_square_root = __pyx_state[2]; __pyx_result.Q_svd_dict = __pyx_state[3]; __pyx_result.Q_time_var_index = __pyx_state[4]; __pyx_result.Qs = __pyx_state[5]; __pyx_result.dAs = __pyx_state[6]; __pyx_result.dQ = __pyx_state[7]; __pyx_result.dQs = __pyx_state[8]; __pyx_result.index = __pyx_state[9]; __pyx_result.last_k = __pyx_state[10]; __pyx_result.reconstruct_indices = __pyx_state[11]; __pyx_result.svd_each_time = __pyx_state[12]
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("GPy.models.state_space_cython.__pyx_unpickle_AQcompute_batch_Cython__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":735
 * 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);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":736
 * 
 * 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_ERR(2, 736, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":735
 * 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;
}

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":738
 *     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);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":739
 * 
 * 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_ERR(2, 739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":738
 *     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;
}

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":741
 *     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);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":742
 * 
 * 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_ERR(2, 742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":741
 *     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;
}

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":744
 *     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);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":745
 * 
 * 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_ERR(2, 745, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":744
 *     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;
}

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":747
 *     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);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":748
 * 
 * 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 tuple PyDataType_SHAPE(dtype d):
 */
  __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_ERR(2, 748, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":747
 *     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;
}

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":750
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
 *     if PyDataType_HASSUBARRAY(d):
 *         return <tuple>d.subarray.shape
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":751
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
 *         return <tuple>d.subarray.shape
 *     else:
 */
  __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
  if (__pyx_t_1) {

    /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":752
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 *     if PyDataType_HASSUBARRAY(d):
 *         return <tuple>d.subarray.shape             # <<<<<<<<<<<<<<
 *     else:
 *         return ()
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
    __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
    goto __pyx_L0;

    /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":751
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
 *         return <tuple>d.subarray.shape
 *     else:
 */
  }

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":754
 *         return <tuple>d.subarray.shape
 *     else:
 *         return ()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;
  }

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":750
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
 *     if PyDataType_HASSUBARRAY(d):
 *         return <tuple>d.subarray.shape
 */

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

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":931
 *     int _import_umath() except -1
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *     Py_INCREF(base) # important to do this before stealing the reference below!
 *     PyArray_SetBaseObject(arr, base)
 */

static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_array_base", 0);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":932
 * 
 * cdef inline void set_array_base(ndarray arr, object base):
 *     Py_INCREF(base) # important to do this before stealing the reference below!             # <<<<<<<<<<<<<<
 *     PyArray_SetBaseObject(arr, base)
 * 
 */
  Py_INCREF(__pyx_v_base);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":933
 * cdef inline void set_array_base(ndarray arr, object base):
 *     Py_INCREF(base) # important to do this before stealing the reference below!
 *     PyArray_SetBaseObject(arr, base)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object get_array_base(ndarray arr):
 */
  (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":931
 *     int _import_umath() except -1
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *     Py_INCREF(base) # important to do this before stealing the reference below!
 *     PyArray_SetBaseObject(arr, base)
 */

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

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":935
 *     PyArray_SetBaseObject(arr, base)
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     base = PyArray_BASE(arr)
 *     if base is NULL:
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
  PyObject *__pyx_v_base;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("get_array_base", 0);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":936
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     base = PyArray_BASE(arr)             # <<<<<<<<<<<<<<
 *     if base is NULL:
 *         return None
 */
  __pyx_v_base = PyArray_BASE(__pyx_v_arr);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":937
 * cdef inline object get_array_base(ndarray arr):
 *     base = PyArray_BASE(arr)
 *     if base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     return <object>base
 */
  __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
  if (__pyx_t_1) {

    /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":938
 *     base = PyArray_BASE(arr)
 *     if base is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     return <object>base
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":937
 * cdef inline object get_array_base(ndarray arr):
 *     base = PyArray_BASE(arr)
 *     if base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     return <object>base
 */
  }

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":939
 *     if base is NULL:
 *         return None
 *     return <object>base             # <<<<<<<<<<<<<<
 * 
 * # Versions of the import_* functions which are more suitable for
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_base));
  __pyx_r = ((PyObject *)__pyx_v_base);
  goto __pyx_L0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":935
 *     PyArray_SetBaseObject(arr, base)
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     base = PyArray_BASE(arr)
 *     if base is NULL:
 */

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

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":943
 * # Versions of the import_* functions which are more suitable for
 * # Cython code.
 * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         __pyx_import_array()
 */

static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  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("import_array", 0);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":944
 * # Cython code.
 * cdef inline int import_array() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         __pyx_import_array()
 *     except Exception:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":945
 * cdef inline int import_array() except -1:
 *     try:
 *         __pyx_import_array()             # <<<<<<<<<<<<<<
 *     except Exception:
 *         raise ImportError("numpy.core.multiarray failed to import")
 */
      __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 945, __pyx_L3_error)

      /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":944
 * # Cython code.
 * cdef inline int import_array() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         __pyx_import_array()
 *     except Exception:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;

    /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":946
 *     try:
 *         __pyx_import_array()
 *     except Exception:             # <<<<<<<<<<<<<<
 *         raise ImportError("numpy.core.multiarray failed to import")
 * 
 */
    __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_4) {
      __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 946, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":947
 *         __pyx_import_array()
 *     except Exception:
 *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_umath() except -1:
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 947, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(2, 947, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":944
 * # Cython code.
 * cdef inline int import_array() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         __pyx_import_array()
 *     except Exception:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":943
 * # Versions of the import_* functions which are more suitable for
 * # Cython code.
 * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         __pyx_import_array()
 */

  /* 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("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":949
 *         raise ImportError("numpy.core.multiarray failed to import")
 * 
 * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  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("import_umath", 0);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":950
 * 
 * cdef inline int import_umath() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":951
 * cdef inline int import_umath() except -1:
 *     try:
 *         _import_umath()             # <<<<<<<<<<<<<<
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")
 */
      __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 951, __pyx_L3_error)

      /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":950
 * 
 * cdef inline int import_umath() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;

    /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":952
 *     try:
 *         _import_umath()
 *     except Exception:             # <<<<<<<<<<<<<<
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 */
    __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_4) {
      __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 952, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":953
 *         _import_umath()
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_ufunc() except -1:
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 953, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(2, 953, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":950
 * 
 * cdef inline int import_umath() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":949
 *         raise ImportError("numpy.core.multiarray failed to import")
 * 
 * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

  /* 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("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":955
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  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("import_ufunc", 0);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":956
 * 
 * cdef inline int import_ufunc() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":957
 * cdef inline int import_ufunc() except -1:
 *     try:
 *         _import_umath()             # <<<<<<<<<<<<<<
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")
 */
      __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 957, __pyx_L3_error)

      /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":956
 * 
 * cdef inline int import_ufunc() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;

    /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":958
 *     try:
 *         _import_umath()
 *     except Exception:             # <<<<<<<<<<<<<<
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 */
    __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_4) {
      __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 958, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":959
 *         _import_umath()
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef extern from *:
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 959, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(2, 959, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":956
 * 
 * cdef inline int import_ufunc() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":955
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

  /* 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("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":969
 * 
 * 
 * cdef inline bint is_timedelta64_object(object obj):             # <<<<<<<<<<<<<<
 *     """
 *     Cython equivalent of `isinstance(obj, np.timedelta64)`
 */

static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_obj) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_timedelta64_object", 0);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":981
 *     bool
 *     """
 *     return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyTimedeltaArrType_Type));
  goto __pyx_L0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":969
 * 
 * 
 * cdef inline bint is_timedelta64_object(object obj):             # <<<<<<<<<<<<<<
 *     """
 *     Cython equivalent of `isinstance(obj, np.timedelta64)`
 */

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

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":984
 * 
 * 
 * cdef inline bint is_datetime64_object(object obj):             # <<<<<<<<<<<<<<
 *     """
 *     Cython equivalent of `isinstance(obj, np.datetime64)`
 */

static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_obj) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_datetime64_object", 0);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":996
 *     bool
 *     """
 *     return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyDatetimeArrType_Type));
  goto __pyx_L0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":984
 * 
 * 
 * cdef inline bint is_datetime64_object(object obj):             # <<<<<<<<<<<<<<
 *     """
 *     Cython equivalent of `isinstance(obj, np.datetime64)`
 */

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

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":999
 * 
 * 
 * cdef inline npy_datetime get_datetime64_value(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the int64 value underlying scalar numpy datetime64 object
 */

static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject *__pyx_v_obj) {
  npy_datetime __pyx_r;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":1006
 *     also needed.  That can be found using `get_datetime64_unit`.
 *     """
 *     return (<PyDatetimeScalarObject*>obj).obval             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((PyDatetimeScalarObject *)__pyx_v_obj)->obval;
  goto __pyx_L0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":999
 * 
 * 
 * cdef inline npy_datetime get_datetime64_value(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the int64 value underlying scalar numpy datetime64 object
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":1009
 * 
 * 
 * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the int64 value underlying scalar numpy timedelta64 object
 */

static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject *__pyx_v_obj) {
  npy_timedelta __pyx_r;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":1013
 *     returns the int64 value underlying scalar numpy timedelta64 object
 *     """
 *     return (<PyTimedeltaScalarObject*>obj).obval             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((PyTimedeltaScalarObject *)__pyx_v_obj)->obval;
  goto __pyx_L0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":1009
 * 
 * 
 * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the int64 value underlying scalar numpy timedelta64 object
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":1016
 * 
 * 
 * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the unit part of the dtype for a numpy datetime64 object.
 */

static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObject *__pyx_v_obj) {
  NPY_DATETIMEUNIT __pyx_r;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":1020
 *     returns the unit part of the dtype for a numpy datetime64 object.
 *     """
 *     return <NPY_DATETIMEUNIT>(<PyDatetimeScalarObject*>obj).obmeta.base             # <<<<<<<<<<<<<<
 */
  __pyx_r = ((NPY_DATETIMEUNIT)((PyDatetimeScalarObject *)__pyx_v_obj)->obmeta.base);
  goto __pyx_L0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":1016
 * 
 * 
 * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the unit part of the dtype for a numpy datetime64 object.
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython;

static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *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_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)o);
  p->__pyx_vtab = __pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython;
  return o;
}

static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython(PyObject *o) {
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython[] = {
  {"f_a", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_1f_a, METH_VARARGS|METH_KEYWORDS, 0},
  {"Ak", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_3Ak, METH_VARARGS|METH_KEYWORDS, 0},
  {"Qk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_5Qk, METH_O, 0},
  {"Q_srk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_7Q_srk, METH_O, 0},
  {"dAk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_9dAk, METH_O, 0},
  {"dQk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_11dQk, METH_O, 0},
  {"reset", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_13reset, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_15__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_17__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython = {
  PyVarObject_HEAD_INIT(0, 0)
  "GPy.models.state_space_cython.Dynamic_Callables_Cython", /*tp_name*/
  sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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, /*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_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython, /*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_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython, /*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
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython;

static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Measurement_Callables_Cython(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *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_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)o);
  p->__pyx_vtab = __pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython;
  return o;
}

static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Measurement_Callables_Cython(PyObject *o) {
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_Measurement_Callables_Cython[] = {
  {"f_h", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_1f_h, METH_VARARGS|METH_KEYWORDS, 0},
  {"Hk", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_3Hk, METH_VARARGS|METH_KEYWORDS, 0},
  {"Rk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_5Rk, METH_O, 0},
  {"R_isrk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_7R_isrk, METH_O, 0},
  {"dHk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_9dHk, METH_O, 0},
  {"dRk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_11dRk, METH_O, 0},
  {"reset", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_13reset, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_15__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_17__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython = {
  PyVarObject_HEAD_INIT(0, 0)
  "GPy.models.state_space_cython.Measurement_Callables_Cython", /*tp_name*/
  sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Measurement_Callables_Cython, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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, /*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_3GPy_6models_18state_space_cython_Measurement_Callables_Cython, /*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_3GPy_6models_18state_space_cython_Measurement_Callables_Cython, /*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
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_R_handling_Cython __pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython;

static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_R_handling_Cython(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *p;
  PyObject *o = __pyx_tp_new_3GPy_6models_18state_space_cython_Measurement_Callables_Cython(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython*)__pyx_vtabptr_3GPy_6models_18state_space_cython_R_handling_Cython;
  p->R = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->index = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->dR = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->R_square_root = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_R_handling_Cython(PyObject *o) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->R);
  Py_CLEAR(p->index);
  Py_CLEAR(p->dR);
  Py_CLEAR(p->R_square_root);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Measurement_Callables_Cython(o);
}

static int __pyx_tp_traverse_3GPy_6models_18state_space_cython_R_handling_Cython(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)o;
  e = ((likely(__pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython)) ? ((__pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython->tp_traverse) ? __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_3GPy_6models_18state_space_cython_R_handling_Cython)); if (e) return e;
  if (p->R) {
    e = (*v)(((PyObject *)p->R), a); if (e) return e;
  }
  if (p->index) {
    e = (*v)(((PyObject *)p->index), a); if (e) return e;
  }
  if (p->dR) {
    e = (*v)(((PyObject *)p->dR), a); if (e) return e;
  }
  if (p->R_square_root) {
    e = (*v)(p->R_square_root, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_3GPy_6models_18state_space_cython_R_handling_Cython(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)o;
  if (likely(__pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython)) { if (__pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython->tp_clear) __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_3GPy_6models_18state_space_cython_R_handling_Cython);
  tmp = ((PyObject*)p->R);
  p->R = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->index);
  p->index = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->dR);
  p->dR = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->R_square_root);
  p->R_square_root = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_R_handling_Cython[] = {
  {"Rk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_3Rk, METH_O, 0},
  {"dRk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_5dRk, METH_O, 0},
  {"R_isrk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_7R_isrk, METH_O, __pyx_doc_3GPy_6models_18state_space_cython_17R_handling_Cython_6R_isrk},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_9__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_11__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython = {
  PyVarObject_HEAD_INIT(0, 0)
  "GPy.models.state_space_cython.R_handling_Cython", /*tp_name*/
  sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_R_handling_Cython, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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*/
  "\n    The calss handles noise matrix R.\n    ", /*tp_doc*/
  __pyx_tp_traverse_3GPy_6models_18state_space_cython_R_handling_Cython, /*tp_traverse*/
  __pyx_tp_clear_3GPy_6models_18state_space_cython_R_handling_Cython, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3GPy_6models_18state_space_cython_R_handling_Cython, /*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_3GPy_6models_18state_space_cython_17R_handling_Cython_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3GPy_6models_18state_space_cython_R_handling_Cython, /*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
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython __pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython;

static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *p;
  PyObject *o = __pyx_tp_new_3GPy_6models_18state_space_cython_R_handling_Cython(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython*)__pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython;
  p->H = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->dH = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython(PyObject *o) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->H);
  Py_CLEAR(p->dH);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_R_handling_Cython(o);
}

static int __pyx_tp_traverse_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)o;
  e = __pyx_tp_traverse_3GPy_6models_18state_space_cython_R_handling_Cython(o, v, a); if (e) return e;
  if (p->H) {
    e = (*v)(((PyObject *)p->H), a); if (e) return e;
  }
  if (p->dH) {
    e = (*v)(((PyObject *)p->dH), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)o;
  __pyx_tp_clear_3GPy_6models_18state_space_cython_R_handling_Cython(o);
  tmp = ((PyObject*)p->H);
  p->H = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->dH);
  p->dH = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython[] = {
  {"f_h", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_3f_h, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_2f_h},
  {"Hk", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_5Hk, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_4Hk},
  {"dHk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_7dHk, METH_O, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_9__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_11__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython = {
  PyVarObject_HEAD_INIT(0, 0)
  "GPy.models.state_space_cython.Std_Measurement_Callables_Cython", /*tp_name*/
  sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython, /*tp_traverse*/
  __pyx_tp_clear_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython, /*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_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython, /*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
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Q_handling_Cython __pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython;

static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Q_handling_Cython(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *p;
  PyObject *o = __pyx_tp_new_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython*)__pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython;
  p->Q = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->index = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->dQ = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->Q_square_root = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Q_handling_Cython(PyObject *o) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->Q);
  Py_CLEAR(p->index);
  Py_CLEAR(p->dQ);
  Py_CLEAR(p->Q_square_root);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython(o);
}

static int __pyx_tp_traverse_3GPy_6models_18state_space_cython_Q_handling_Cython(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)o;
  e = ((likely(__pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython)) ? ((__pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython->tp_traverse) ? __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_3GPy_6models_18state_space_cython_Q_handling_Cython)); if (e) return e;
  if (p->Q) {
    e = (*v)(((PyObject *)p->Q), a); if (e) return e;
  }
  if (p->index) {
    e = (*v)(((PyObject *)p->index), a); if (e) return e;
  }
  if (p->dQ) {
    e = (*v)(((PyObject *)p->dQ), a); if (e) return e;
  }
  if (p->Q_square_root) {
    e = (*v)(p->Q_square_root, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_3GPy_6models_18state_space_cython_Q_handling_Cython(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)o;
  if (likely(__pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython)) { if (__pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython->tp_clear) __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_3GPy_6models_18state_space_cython_Q_handling_Cython);
  tmp = ((PyObject*)p->Q);
  p->Q = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->index);
  p->index = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->dQ);
  p->dQ = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->Q_square_root);
  p->Q_square_root = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_Q_handling_Cython[] = {
  {"Qk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_3Qk, METH_O, __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython_2Qk},
  {"dQk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_5dQk, METH_O, 0},
  {"Q_srk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_7Q_srk, METH_O, __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython_6Q_srk},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_9__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_11__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython = {
  PyVarObject_HEAD_INIT(0, 0)
  "GPy.models.state_space_cython.Q_handling_Cython", /*tp_name*/
  sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Q_handling_Cython, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_3GPy_6models_18state_space_cython_Q_handling_Cython, /*tp_traverse*/
  __pyx_tp_clear_3GPy_6models_18state_space_cython_Q_handling_Cython, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3GPy_6models_18state_space_cython_Q_handling_Cython, /*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_3GPy_6models_18state_space_cython_17Q_handling_Cython_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3GPy_6models_18state_space_cython_Q_handling_Cython, /*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
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython;

static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *p;
  PyObject *o = __pyx_tp_new_3GPy_6models_18state_space_cython_Q_handling_Cython(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython*)__pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython;
  p->A = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->dA = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython(PyObject *o) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->A);
  Py_CLEAR(p->dA);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Q_handling_Cython(o);
}

static int __pyx_tp_traverse_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)o;
  e = __pyx_tp_traverse_3GPy_6models_18state_space_cython_Q_handling_Cython(o, v, a); if (e) return e;
  if (p->A) {
    e = (*v)(((PyObject *)p->A), a); if (e) return e;
  }
  if (p->dA) {
    e = (*v)(((PyObject *)p->dA), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)o;
  __pyx_tp_clear_3GPy_6models_18state_space_cython_Q_handling_Cython(o);
  tmp = ((PyObject*)p->A);
  p->A = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->dA);
  p->dA = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython[] = {
  {"f_a", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_3f_a, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_2f_a},
  {"Ak", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_5Ak, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_4Ak},
  {"dAk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_7dAk, METH_O, 0},
  {"reset", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_9reset, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_8reset},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_11__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_13__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython = {
  PyVarObject_HEAD_INIT(0, 0)
  "GPy.models.state_space_cython.Std_Dynamic_Callables_Cython", /*tp_name*/
  sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython, /*tp_traverse*/
  __pyx_tp_clear_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython, /*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_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython, /*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
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_AQcompute_batch_Cython __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython;

static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_AQcompute_batch_Cython(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *p;
  PyObject *o = __pyx_tp_new_3GPy_6models_18state_space_cython_Q_handling_Cython(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython*)__pyx_vtabptr_3GPy_6models_18state_space_cython_AQcompute_batch_Cython;
  p->As = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->Qs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->dAs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->dQs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->reconstruct_indices = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->Q_svd_dict = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_AQcompute_batch_Cython(PyObject *o) {
  struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->As);
  Py_CLEAR(p->Qs);
  Py_CLEAR(p->dAs);
  Py_CLEAR(p->dQs);
  Py_CLEAR(p->reconstruct_indices);
  Py_CLEAR(p->Q_svd_dict);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Q_handling_Cython(o);
}

static int __pyx_tp_traverse_3GPy_6models_18state_space_cython_AQcompute_batch_Cython(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)o;
  e = __pyx_tp_traverse_3GPy_6models_18state_space_cython_Q_handling_Cython(o, v, a); if (e) return e;
  if (p->As) {
    e = (*v)(((PyObject *)p->As), a); if (e) return e;
  }
  if (p->Qs) {
    e = (*v)(((PyObject *)p->Qs), a); if (e) return e;
  }
  if (p->dAs) {
    e = (*v)(((PyObject *)p->dAs), a); if (e) return e;
  }
  if (p->dQs) {
    e = (*v)(((PyObject *)p->dQs), a); if (e) return e;
  }
  if (p->reconstruct_indices) {
    e = (*v)(((PyObject *)p->reconstruct_indices), a); if (e) return e;
  }
  if (p->Q_svd_dict) {
    e = (*v)(p->Q_svd_dict, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_3GPy_6models_18state_space_cython_AQcompute_batch_Cython(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)o;
  __pyx_tp_clear_3GPy_6models_18state_space_cython_Q_handling_Cython(o);
  tmp = ((PyObject*)p->As);
  p->As = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->Qs);
  p->Qs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->dAs);
  p->dAs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->dQs);
  p->dQs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->reconstruct_indices);
  p->reconstruct_indices = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->Q_svd_dict);
  p->Q_svd_dict = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_AQcompute_batch_Cython[] = {
  {"f_a", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_3f_a, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_2f_a},
  {"reset", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_5reset, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_4reset},
  {"Ak", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_7Ak, METH_VARARGS|METH_KEYWORDS, 0},
  {"Qk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_9Qk, METH_O, 0},
  {"dAk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_11dAk, METH_O, 0},
  {"dQk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_13dQk, METH_O, 0},
  {"Q_srk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_15Q_srk, METH_O, __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_14Q_srk},
  {"Q_inverse", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_17Q_inverse, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_16Q_inverse},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_19__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_21__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython = {
  PyVarObject_HEAD_INIT(0, 0)
  "GPy.models.state_space_cython.AQcompute_batch_Cython", /*tp_name*/
  sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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*/
  "\n        Class for calculating matrices A, Q, dA, dQ of the discrete Kalman Filter\n        from the matrices F, L, Qc, P_ing, dF, dQc, dP_inf of the continuos state\n        equation. dt - time steps.       \n        \n        It has the same interface as AQcompute_once.\n        \n        It computes matrices for all time steps. This object is used when\n        there are not so many (controlled by internal variable) \n        different time steps and storing all the matrices do not take too much memory.\n        \n        Since all the matrices are computed all together, this object can be used\n        in smoother without repeating the computations.        \n        ", /*tp_doc*/
  __pyx_tp_traverse_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, /*tp_traverse*/
  __pyx_tp_clear_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, /*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_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, /*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
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_state_space_cython(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_state_space_cython},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "state_space_cython",
    __pyx_k_Contains_some_cython_code_for_s, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
  {&__pyx_n_s_AQcompute_batch_Cython, __pyx_k_AQcompute_batch_Cython, sizeof(__pyx_k_AQcompute_batch_Cython), 0, 0, 1, 1},
  {&__pyx_n_s_A_time_var_index, __pyx_k_A_time_var_index, sizeof(__pyx_k_A_time_var_index), 0, 0, 1, 1},
  {&__pyx_n_s_Ak, __pyx_k_Ak, sizeof(__pyx_k_Ak), 0, 0, 1, 1},
  {&__pyx_n_s_As, __pyx_k_As, sizeof(__pyx_k_As), 0, 0, 1, 1},
  {&__pyx_n_s_DTYPE, __pyx_k_DTYPE, sizeof(__pyx_k_DTYPE), 0, 0, 1, 1},
  {&__pyx_n_s_DTYPE_int, __pyx_k_DTYPE_int, sizeof(__pyx_k_DTYPE_int), 0, 0, 1, 1},
  {&__pyx_n_s_Dynamic_Callables_Cython, __pyx_k_Dynamic_Callables_Cython, sizeof(__pyx_k_Dynamic_Callables_Cython), 0, 0, 1, 1},
  {&__pyx_n_s_GPy_models_state_space_cython, __pyx_k_GPy_models_state_space_cython, sizeof(__pyx_k_GPy_models_state_space_cython), 0, 0, 1, 1},
  {&__pyx_kp_s_GPy_models_state_space_cython_py, __pyx_k_GPy_models_state_space_cython_py, sizeof(__pyx_k_GPy_models_state_space_cython_py), 0, 0, 1, 0},
  {&__pyx_n_s_H, __pyx_k_H, sizeof(__pyx_k_H), 0, 0, 1, 1},
  {&__pyx_n_s_H_time_var_index, __pyx_k_H_time_var_index, sizeof(__pyx_k_H_time_var_index), 0, 0, 1, 1},
  {&__pyx_n_s_Hk, __pyx_k_Hk, sizeof(__pyx_k_Hk), 0, 0, 1, 1},
  {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x14, __pyx_k_Incompatible_checksums_s_vs_0x14, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x14), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x70, __pyx_k_Incompatible_checksums_s_vs_0x70, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x70), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x77, __pyx_k_Incompatible_checksums_s_vs_0x77, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x77), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x9e, __pyx_k_Incompatible_checksums_s_vs_0x9e, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x9e), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xd4, __pyx_k_Incompatible_checksums_s_vs_0xd4, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xd4), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xdf, __pyx_k_Incompatible_checksums_s_vs_0xdf, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xdf), 0, 0, 1, 0},
  {&__pyx_n_s_K, __pyx_k_K, sizeof(__pyx_k_K), 0, 0, 1, 1},
  {&__pyx_kp_s_Kalman_Filter_Update_SVD_S_is_ne, __pyx_k_Kalman_Filter_Update_SVD_S_is_ne, sizeof(__pyx_k_Kalman_Filter_Update_SVD_S_is_ne), 0, 0, 1, 0},
  {&__pyx_n_s_M, __pyx_k_M, sizeof(__pyx_k_M), 0, 0, 1, 1},
  {&__pyx_n_s_Measurement_Callables_Cython, __pyx_k_Measurement_Callables_Cython, sizeof(__pyx_k_Measurement_Callables_Cython), 0, 0, 1, 1},
  {&__pyx_kp_s_Measurement_dimension_larger_the, __pyx_k_Measurement_dimension_larger_the, sizeof(__pyx_k_Measurement_dimension_larger_the), 0, 0, 1, 0},
  {&__pyx_kp_s_Nan_measurements_are_currently_n, __pyx_k_Nan_measurements_are_currently_n, sizeof(__pyx_k_Nan_measurements_are_currently_n), 0, 0, 1, 0},
  {&__pyx_kp_s_Nan_values_in_likelihood_update, __pyx_k_Nan_values_in_likelihood_update, sizeof(__pyx_k_Nan_values_in_likelihood_update), 0, 0, 1, 0},
  {&__pyx_n_s_NotImplemented, __pyx_k_NotImplemented, sizeof(__pyx_k_NotImplemented), 0, 0, 1, 1},
  {&__pyx_n_s_P, __pyx_k_P, sizeof(__pyx_k_P), 0, 0, 1, 1},
  {&__pyx_n_s_P_init, __pyx_k_P_init, sizeof(__pyx_k_P_init), 0, 0, 1, 1},
  {&__pyx_n_s_P_pred, __pyx_k_P_pred, sizeof(__pyx_k_P_pred), 0, 0, 1, 1},
  {&__pyx_n_s_P_upd, __pyx_k_P_upd, sizeof(__pyx_k_P_upd), 0, 0, 1, 1},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_Prev_cov, __pyx_k_Prev_cov, sizeof(__pyx_k_Prev_cov), 0, 0, 1, 1},
  {&__pyx_n_s_Q, __pyx_k_Q, sizeof(__pyx_k_Q), 0, 0, 1, 1},
  {&__pyx_n_s_Q_handling_Cython, __pyx_k_Q_handling_Cython, sizeof(__pyx_k_Q_handling_Cython), 0, 0, 1, 1},
  {&__pyx_n_s_Q_inverse, __pyx_k_Q_inverse, sizeof(__pyx_k_Q_inverse), 0, 0, 1, 1},
  {&__pyx_n_s_Q_inverse_dict, __pyx_k_Q_inverse_dict, sizeof(__pyx_k_Q_inverse_dict), 0, 0, 1, 1},
  {&__pyx_n_s_Q_square_root_dict, __pyx_k_Q_square_root_dict, sizeof(__pyx_k_Q_square_root_dict), 0, 0, 1, 1},
  {&__pyx_n_s_Q_sr, __pyx_k_Q_sr, sizeof(__pyx_k_Q_sr), 0, 0, 1, 1},
  {&__pyx_n_s_Q_srk, __pyx_k_Q_srk, sizeof(__pyx_k_Q_srk), 0, 0, 1, 1},
  {&__pyx_n_s_Q_time_var_index, __pyx_k_Q_time_var_index, sizeof(__pyx_k_Q_time_var_index), 0, 0, 1, 1},
  {&__pyx_n_s_Qk, __pyx_k_Qk, sizeof(__pyx_k_Qk), 0, 0, 1, 1},
  {&__pyx_n_s_Qs, __pyx_k_Qs, sizeof(__pyx_k_Qs), 0, 0, 1, 1},
  {&__pyx_n_s_R, __pyx_k_R, sizeof(__pyx_k_R), 0, 0, 1, 1},
  {&__pyx_n_s_R_handling_Cython, __pyx_k_R_handling_Cython, sizeof(__pyx_k_R_handling_Cython), 0, 0, 1, 1},
  {&__pyx_n_s_R_isr, __pyx_k_R_isr, sizeof(__pyx_k_R_isr), 0, 0, 1, 1},
  {&__pyx_n_s_R_isrk, __pyx_k_R_isrk, sizeof(__pyx_k_R_isrk), 0, 0, 1, 1},
  {&__pyx_n_s_R_time_var_index, __pyx_k_R_time_var_index, sizeof(__pyx_k_R_time_var_index), 0, 0, 1, 1},
  {&__pyx_n_s_Rk, __pyx_k_Rk, sizeof(__pyx_k_Rk), 0, 0, 1, 1},
  {&__pyx_n_s_S, __pyx_k_S, sizeof(__pyx_k_S), 0, 0, 1, 1},
  {&__pyx_n_s_S_new, __pyx_k_S_new, sizeof(__pyx_k_S_new), 0, 0, 1, 1},
  {&__pyx_n_s_S_old, __pyx_k_S_old, sizeof(__pyx_k_S_old), 0, 0, 1, 1},
  {&__pyx_n_s_S_pred, __pyx_k_S_pred, sizeof(__pyx_k_S_pred), 0, 0, 1, 1},
  {&__pyx_n_s_S_svd, __pyx_k_S_svd, sizeof(__pyx_k_S_svd), 0, 0, 1, 1},
  {&__pyx_n_s_S_upd, __pyx_k_S_upd, sizeof(__pyx_k_S_upd), 0, 0, 1, 1},
  {&__pyx_n_s_Std_Dynamic_Callables_Cython, __pyx_k_Std_Dynamic_Callables_Cython, sizeof(__pyx_k_Std_Dynamic_Callables_Cython), 0, 0, 1, 1},
  {&__pyx_n_s_Std_Measurement_Callables_Cython, __pyx_k_Std_Measurement_Callables_Cython, sizeof(__pyx_k_Std_Measurement_Callables_Cython), 0, 0, 1, 1},
  {&__pyx_n_s_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 1, 1},
  {&__pyx_n_s_U, __pyx_k_U, sizeof(__pyx_k_U), 0, 0, 1, 1},
  {&__pyx_n_s_U_upd, __pyx_k_U_upd, sizeof(__pyx_k_U_upd), 0, 0, 1, 1},
  {&__pyx_n_s_V_new, __pyx_k_V_new, sizeof(__pyx_k_V_new), 0, 0, 1, 1},
  {&__pyx_n_s_V_old, __pyx_k_V_old, sizeof(__pyx_k_V_old), 0, 0, 1, 1},
  {&__pyx_n_s_V_pred, __pyx_k_V_pred, sizeof(__pyx_k_V_pred), 0, 0, 1, 1},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_n_s_Vh, __pyx_k_Vh, sizeof(__pyx_k_Vh), 0, 0, 1, 1},
  {&__pyx_n_s_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 0, 1, 1},
  {&__pyx_n_s_Y, __pyx_k_Y, sizeof(__pyx_k_Y), 0, 0, 1, 1},
  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  {&__pyx_n_s_any, __pyx_k_any, sizeof(__pyx_k_any), 0, 0, 1, 1},
  {&__pyx_n_s_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 0, 0, 1, 1},
  {&__pyx_n_s_calc_grad_log_likelihood, __pyx_k_calc_grad_log_likelihood, sizeof(__pyx_k_calc_grad_log_likelihood), 0, 0, 1, 1},
  {&__pyx_n_s_calc_log_likelihood, __pyx_k_calc_log_likelihood, sizeof(__pyx_k_calc_log_likelihood), 0, 0, 1, 1},
  {&__pyx_n_s_check_finite, __pyx_k_check_finite, sizeof(__pyx_k_check_finite), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_compute_derivatives, __pyx_k_compute_derivatives, sizeof(__pyx_k_compute_derivatives), 0, 0, 1, 1},
  {&__pyx_n_s_compute_uv, __pyx_k_compute_uv, sizeof(__pyx_k_compute_uv), 0, 0, 1, 1},
  {&__pyx_n_s_cont_discr_kalman_filter_raw_Cy, __pyx_k_cont_discr_kalman_filter_raw_Cy, sizeof(__pyx_k_cont_discr_kalman_filter_raw_Cy), 0, 0, 1, 1},
  {&__pyx_kp_s_cython_Ak_is_not_implemented, __pyx_k_cython_Ak_is_not_implemented, sizeof(__pyx_k_cython_Ak_is_not_implemented), 0, 0, 1, 0},
  {&__pyx_kp_s_cython_Hk_is_not_implemented, __pyx_k_cython_Hk_is_not_implemented, sizeof(__pyx_k_cython_Hk_is_not_implemented), 0, 0, 1, 0},
  {&__pyx_kp_s_cython_Q_srk_is_not_implemented, __pyx_k_cython_Q_srk_is_not_implemented, sizeof(__pyx_k_cython_Q_srk_is_not_implemented), 0, 0, 1, 0},
  {&__pyx_kp_s_cython_Qk_is_not_implemented, __pyx_k_cython_Qk_is_not_implemented, sizeof(__pyx_k_cython_Qk_is_not_implemented), 0, 0, 1, 0},
  {&__pyx_kp_s_cython_Rk_is_not_implemented, __pyx_k_cython_Rk_is_not_implemented, sizeof(__pyx_k_cython_Rk_is_not_implemented), 0, 0, 1, 0},
  {&__pyx_kp_s_cython_dAk_is_not_implemented, __pyx_k_cython_dAk_is_not_implemented, sizeof(__pyx_k_cython_dAk_is_not_implemented), 0, 0, 1, 0},
  {&__pyx_kp_s_cython_dQk_is_not_implemented, __pyx_k_cython_dQk_is_not_implemented, sizeof(__pyx_k_cython_dQk_is_not_implemented), 0, 0, 1, 0},
  {&__pyx_kp_s_cython_f_a_is_not_implemented, __pyx_k_cython_f_a_is_not_implemented, sizeof(__pyx_k_cython_f_a_is_not_implemented), 0, 0, 1, 0},
  {&__pyx_kp_s_cython_reset_is_not_implemented, __pyx_k_cython_reset_is_not_implemented, sizeof(__pyx_k_cython_reset_is_not_implemented), 0, 0, 1, 0},
  {&__pyx_n_s_dA, __pyx_k_dA, sizeof(__pyx_k_dA), 0, 0, 1, 1},
  {&__pyx_n_s_dA_all_params, __pyx_k_dA_all_params, sizeof(__pyx_k_dA_all_params), 0, 0, 1, 1},
  {&__pyx_kp_s_dA_derivative_is_None, __pyx_k_dA_derivative_is_None, sizeof(__pyx_k_dA_derivative_is_None), 0, 0, 1, 0},
  {&__pyx_n_s_dAk, __pyx_k_dAk, sizeof(__pyx_k_dAk), 0, 0, 1, 1},
  {&__pyx_n_s_dAs, __pyx_k_dAs, sizeof(__pyx_k_dAs), 0, 0, 1, 1},
  {&__pyx_n_s_dH, __pyx_k_dH, sizeof(__pyx_k_dH), 0, 0, 1, 1},
  {&__pyx_n_s_dH_all_params, __pyx_k_dH_all_params, sizeof(__pyx_k_dH_all_params), 0, 0, 1, 1},
  {&__pyx_kp_s_dH_derivative_is_None, __pyx_k_dH_derivative_is_None, sizeof(__pyx_k_dH_derivative_is_None), 0, 0, 1, 0},
  {&__pyx_n_s_dHk, __pyx_k_dHk, sizeof(__pyx_k_dHk), 0, 0, 1, 1},
  {&__pyx_n_s_dK, __pyx_k_dK, sizeof(__pyx_k_dK), 0, 0, 1, 1},
  {&__pyx_n_s_dP_init, __pyx_k_dP_init, sizeof(__pyx_k_dP_init), 0, 0, 1, 1},
  {&__pyx_n_s_dP_pred, __pyx_k_dP_pred, sizeof(__pyx_k_dP_pred), 0, 0, 1, 1},
  {&__pyx_n_s_dP_pred_all_params, __pyx_k_dP_pred_all_params, sizeof(__pyx_k_dP_pred_all_params), 0, 0, 1, 1},
  {&__pyx_n_s_dP_upd, __pyx_k_dP_upd, sizeof(__pyx_k_dP_upd), 0, 0, 1, 1},
  {&__pyx_n_s_dQ, __pyx_k_dQ, sizeof(__pyx_k_dQ), 0, 0, 1, 1},
  {&__pyx_n_s_dQ_all_params, __pyx_k_dQ_all_params, sizeof(__pyx_k_dQ_all_params), 0, 0, 1, 1},
  {&__pyx_kp_s_dQ_derivative_is_None, __pyx_k_dQ_derivative_is_None, sizeof(__pyx_k_dQ_derivative_is_None), 0, 0, 1, 0},
  {&__pyx_n_s_dQk, __pyx_k_dQk, sizeof(__pyx_k_dQk), 0, 0, 1, 1},
  {&__pyx_n_s_dQs, __pyx_k_dQs, sizeof(__pyx_k_dQs), 0, 0, 1, 1},
  {&__pyx_n_s_dR, __pyx_k_dR, sizeof(__pyx_k_dR), 0, 0, 1, 1},
  {&__pyx_n_s_dR_all_params, __pyx_k_dR_all_params, sizeof(__pyx_k_dR_all_params), 0, 0, 1, 1},
  {&__pyx_kp_s_dR_derivative_is_None, __pyx_k_dR_derivative_is_None, sizeof(__pyx_k_dR_derivative_is_None), 0, 0, 1, 0},
  {&__pyx_n_s_dRk, __pyx_k_dRk, sizeof(__pyx_k_dRk), 0, 0, 1, 1},
  {&__pyx_n_s_dS, __pyx_k_dS, sizeof(__pyx_k_dS), 0, 0, 1, 1},
  {&__pyx_n_s_d_log_likelihood_update, __pyx_k_d_log_likelihood_update, sizeof(__pyx_k_d_log_likelihood_update), 0, 0, 1, 1},
  {&__pyx_n_s_diag, __pyx_k_diag, sizeof(__pyx_k_diag), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_dm_init, __pyx_k_dm_init, sizeof(__pyx_k_dm_init), 0, 0, 1, 1},
  {&__pyx_n_s_dm_pred, __pyx_k_dm_pred, sizeof(__pyx_k_dm_pred), 0, 0, 1, 1},
  {&__pyx_n_s_dm_pred_all_params, __pyx_k_dm_pred_all_params, sizeof(__pyx_k_dm_pred_all_params), 0, 0, 1, 1},
  {&__pyx_n_s_dm_upd, __pyx_k_dm_upd, sizeof(__pyx_k_dm_upd), 0, 0, 1, 1},
  {&__pyx_n_s_dot, __pyx_k_dot, sizeof(__pyx_k_dot), 0, 0, 1, 1},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_dv, __pyx_k_dv, sizeof(__pyx_k_dv), 0, 0, 1, 1},
  {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
  {&__pyx_n_s_f_a, __pyx_k_f_a, sizeof(__pyx_k_f_a), 0, 0, 1, 1},
  {&__pyx_n_s_f_h, __pyx_k_f_h, sizeof(__pyx_k_f_h), 0, 0, 1, 1},
  {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1},
  {&__pyx_n_s_full_matrices, __pyx_k_full_matrices, sizeof(__pyx_k_full_matrices), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_n_s_grad_log_likelihood, __pyx_k_grad_log_likelihood, sizeof(__pyx_k_grad_log_likelihood), 0, 0, 1, 1},
  {&__pyx_n_s_grad_params_no, __pyx_k_grad_params_no, sizeof(__pyx_k_grad_params_no), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1},
  {&__pyx_n_s_isnan, __pyx_k_isnan, sizeof(__pyx_k_isnan), 0, 0, 1, 1},
  {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1},
  {&__pyx_n_s_jitter, __pyx_k_jitter, sizeof(__pyx_k_jitter), 0, 0, 1, 1},
  {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
  {&__pyx_n_s_k_measurment, __pyx_k_k_measurment, sizeof(__pyx_k_k_measurment), 0, 0, 1, 1},
  {&__pyx_n_s_kalman_prediction_step_SVD_Cyth, __pyx_k_kalman_prediction_step_SVD_Cyth, sizeof(__pyx_k_kalman_prediction_step_SVD_Cyth), 0, 0, 1, 1},
  {&__pyx_n_s_kalman_update_step_SVD_Cython, __pyx_k_kalman_update_step_SVD_Cython, sizeof(__pyx_k_kalman_update_step_SVD_Cython), 0, 0, 1, 1},
  {&__pyx_n_s_linalg, __pyx_k_linalg, sizeof(__pyx_k_linalg), 0, 0, 1, 1},
  {&__pyx_n_s_log, __pyx_k_log, sizeof(__pyx_k_log), 0, 0, 1, 1},
  {&__pyx_n_s_log_likelihood, __pyx_k_log_likelihood, sizeof(__pyx_k_log_likelihood), 0, 0, 1, 1},
  {&__pyx_n_s_log_likelihood_update, __pyx_k_log_likelihood_update, sizeof(__pyx_k_log_likelihood_update), 0, 0, 1, 1},
  {&__pyx_n_s_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 0, 1, 1},
  {&__pyx_n_s_m_init, __pyx_k_m_init, sizeof(__pyx_k_m_init), 0, 0, 1, 1},
  {&__pyx_n_s_m_pred, __pyx_k_m_pred, sizeof(__pyx_k_m_pred), 0, 0, 1, 1},
  {&__pyx_n_s_m_upd, __pyx_k_m_upd, sizeof(__pyx_k_m_upd), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_measurement, __pyx_k_measurement, sizeof(__pyx_k_measurement), 0, 0, 1, 1},
  {&__pyx_n_s_measurement_dim_gt_one, __pyx_k_measurement_dim_gt_one, sizeof(__pyx_k_measurement_dim_gt_one), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_nbytes, __pyx_k_nbytes, sizeof(__pyx_k_nbytes), 0, 0, 1, 1},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0},
  {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0},
  {&__pyx_n_s_overwrite_a, __pyx_k_overwrite_a, sizeof(__pyx_k_overwrite_a), 0, 0, 1, 1},
  {&__pyx_n_s_p_P, __pyx_k_p_P, sizeof(__pyx_k_p_P), 0, 0, 1, 1},
  {&__pyx_n_s_p_dP, __pyx_k_p_dP, sizeof(__pyx_k_p_dP), 0, 0, 1, 1},
  {&__pyx_n_s_p_dm, __pyx_k_p_dm, sizeof(__pyx_k_p_dm), 0, 0, 1, 1},
  {&__pyx_n_s_p_dynamic_callables, __pyx_k_p_dynamic_callables, sizeof(__pyx_k_p_dynamic_callables), 0, 0, 1, 1},
  {&__pyx_n_s_p_kalman_filter_type, __pyx_k_p_kalman_filter_type, sizeof(__pyx_k_p_kalman_filter_type), 0, 0, 1, 1},
  {&__pyx_n_s_p_m, __pyx_k_p_m, sizeof(__pyx_k_p_m), 0, 0, 1, 1},
  {&__pyx_n_s_p_measurement_callables, __pyx_k_p_measurement_callables, sizeof(__pyx_k_p_measurement_callables), 0, 0, 1, 1},
  {&__pyx_n_s_p_unique_Q_number, __pyx_k_p_unique_Q_number, sizeof(__pyx_k_p_unique_Q_number), 0, 0, 1, 1},
  {&__pyx_n_s_p_unique_R_number, __pyx_k_p_unique_R_number, sizeof(__pyx_k_p_unique_R_number), 0, 0, 1, 1},
  {&__pyx_n_s_param, __pyx_k_param, sizeof(__pyx_k_param), 0, 0, 1, 1},
  {&__pyx_n_s_param_number, __pyx_k_param_number, sizeof(__pyx_k_param_number), 0, 0, 1, 1},
  {&__pyx_n_s_pi, __pyx_k_pi, sizeof(__pyx_k_pi), 0, 0, 1, 1},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_prev_mean, __pyx_k_prev_mean, sizeof(__pyx_k_prev_mean), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_AQcompute_batch_C, __pyx_k_pyx_unpickle_AQcompute_batch_C, sizeof(__pyx_k_pyx_unpickle_AQcompute_batch_C), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Dynamic_Callables, __pyx_k_pyx_unpickle_Dynamic_Callables, sizeof(__pyx_k_pyx_unpickle_Dynamic_Callables), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Measurement_Calla, __pyx_k_pyx_unpickle_Measurement_Calla, sizeof(__pyx_k_pyx_unpickle_Measurement_Calla), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Q_handling_Cython, __pyx_k_pyx_unpickle_Q_handling_Cython, sizeof(__pyx_k_pyx_unpickle_Q_handling_Cython), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_R_handling_Cython, __pyx_k_pyx_unpickle_R_handling_Cython, sizeof(__pyx_k_pyx_unpickle_R_handling_Cython), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Std_Dynamic_Calla, __pyx_k_pyx_unpickle_Std_Dynamic_Calla, sizeof(__pyx_k_pyx_unpickle_Std_Dynamic_Calla), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Std_Measurement_C, __pyx_k_pyx_unpickle_Std_Measurement_C, sizeof(__pyx_k_pyx_unpickle_Std_Measurement_C), 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_reconstruct_indices, __pyx_k_reconstruct_indices, sizeof(__pyx_k_reconstruct_indices), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_regular, __pyx_k_regular, sizeof(__pyx_k_regular), 0, 0, 1, 1},
  {&__pyx_n_s_res, __pyx_k_res, sizeof(__pyx_k_res), 0, 0, 1, 1},
  {&__pyx_n_s_reset, __pyx_k_reset, sizeof(__pyx_k_reset), 0, 0, 1, 1},
  {&__pyx_n_s_ret, __pyx_k_ret, sizeof(__pyx_k_ret), 0, 0, 1, 1},
  {&__pyx_n_s_scipy, __pyx_k_scipy, sizeof(__pyx_k_scipy), 0, 0, 1, 1},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
  {&__pyx_n_s_sp, __pyx_k_sp, sizeof(__pyx_k_sp), 0, 0, 1, 1},
  {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1},
  {&__pyx_n_s_state_dim, __pyx_k_state_dim, sizeof(__pyx_k_state_dim), 0, 0, 1, 1},
  {&__pyx_n_s_steps_no, __pyx_k_steps_no, sizeof(__pyx_k_steps_no), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
  {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
  {&__pyx_n_s_svd, __pyx_k_svd, sizeof(__pyx_k_svd), 0, 0, 1, 1},
  {&__pyx_n_s_svd_1_matr, __pyx_k_svd_1_matr, sizeof(__pyx_k_svd_1_matr), 0, 0, 1, 1},
  {&__pyx_n_s_svd_2_matr, __pyx_k_svd_2_matr, sizeof(__pyx_k_svd_2_matr), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_time_series_no, __pyx_k_time_series_no, sizeof(__pyx_k_time_series_no), 0, 0, 1, 1},
  {&__pyx_n_s_tmp1, __pyx_k_tmp1, sizeof(__pyx_k_tmp1), 0, 0, 1, 1},
  {&__pyx_n_s_tmp2, __pyx_k_tmp2, sizeof(__pyx_k_tmp2), 0, 0, 1, 1},
  {&__pyx_n_s_tmp3, __pyx_k_tmp3, sizeof(__pyx_k_tmp3), 0, 0, 1, 1},
  {&__pyx_n_s_tmp5, __pyx_k_tmp5, sizeof(__pyx_k_tmp5), 0, 0, 1, 1},
  {&__pyx_n_s_total_size_of_data, __pyx_k_total_size_of_data, sizeof(__pyx_k_total_size_of_data), 0, 0, 1, 1},
  {&__pyx_n_s_unique, __pyx_k_unique, sizeof(__pyx_k_unique), 0, 0, 1, 1},
  {&__pyx_n_s_unique_Q_number, __pyx_k_unique_Q_number, sizeof(__pyx_k_unique_Q_number), 0, 0, 1, 1},
  {&__pyx_n_s_unique_R_number, __pyx_k_unique_R_number, sizeof(__pyx_k_unique_R_number), 0, 0, 1, 1},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
  {&__pyx_n_s_vstack, __pyx_k_vstack, sizeof(__pyx_k_vstack), 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 CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s_NotImplemented); if (!__pyx_builtin_NotImplemented) __PYX_ERR(0, 23, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 124, __pyx_L1_error)
  __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 177, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 664, __pyx_L1_error)
  __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 947, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "GPy/models/state_space_cython.pyx":23
 * cdef class Dynamic_Callables_Cython:
 *     cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A):
 *         raise NotImplemented("(cython) f_a is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_cython_f_a_is_not_implemented); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "GPy/models/state_space_cython.pyx":26
 * 
 *     cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix
 *         raise NotImplemented("(cython) Ak is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef Qk(self, int k):
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_cython_Ak_is_not_implemented); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "GPy/models/state_space_cython.pyx":29
 * 
 *     cpdef Qk(self, int k):
 *         raise NotImplemented("(cython) Qk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef Q_srk(self, int k):
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_cython_Qk_is_not_implemented); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "GPy/models/state_space_cython.pyx":32
 * 
 *     cpdef Q_srk(self, int k):
 *         raise NotImplemented("(cython) Q_srk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef dAk(self, int k):
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_cython_Q_srk_is_not_implemented); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "GPy/models/state_space_cython.pyx":35
 * 
 *     cpdef dAk(self, int k):
 *         raise NotImplemented("(cython) dAk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef dQk(self, int k):
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_cython_dAk_is_not_implemented); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "GPy/models/state_space_cython.pyx":38
 * 
 *     cpdef dQk(self, int k):
 *         raise NotImplemented("(cython) dQk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef reset(self, bint compute_derivatives = False):
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_cython_dQk_is_not_implemented); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "GPy/models/state_space_cython.pyx":41
 * 
 *     cpdef reset(self, bint compute_derivatives = False):
 *         raise NotImplemented("(cython) reset is not implemented!")             # <<<<<<<<<<<<<<
 * 
 * # Template class for measurement callables
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_cython_reset_is_not_implemented); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "GPy/models/state_space_cython.pyx":49
 * 
 *     cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix
 *         raise NotImplemented("(cython) Hk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef Rk(self, int k):
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_cython_Hk_is_not_implemented); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "GPy/models/state_space_cython.pyx":52
 * 
 *     cpdef Rk(self, int k):
 *         raise NotImplemented("(cython) Rk is not implemented!")             # <<<<<<<<<<<<<<
 * 
 *     cpdef R_isrk(self, int k):
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_cython_Rk_is_not_implemented); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "GPy/models/state_space_cython.pyx":119
 * 
 *     cpdef Rk(self, int k):
 *         return self.R[:,:, <int>self.index[self.R_time_var_index, k]]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_slice__10 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__10)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);

  /* "GPy/models/state_space_cython.pyx":124
 *     cpdef dRk(self,int k):
 *         if self.dR is None:
 *             raise ValueError("dR derivative is None")             # <<<<<<<<<<<<<<
 * 
 *         return self.dR # the same dirivative on each iteration
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_dR_derivative_is_None); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "GPy/models/state_space_cython.pyx":206
 *     cpdef dHk(self,int k):
 *         if self.dH is None:
 *             raise ValueError("dH derivative is None")             # <<<<<<<<<<<<<<
 * 
 *         return self.dH # the same dirivative on each iteration
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_dH_derivative_is_None); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "GPy/models/state_space_cython.pyx":273
 *     cpdef dQk(self, int k):
 *         if self.dQ is None:
 *             raise ValueError("dQ derivative is None")             # <<<<<<<<<<<<<<
 * 
 *         return self.dQ # the same dirivative on each iteration
 */
  __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_dQ_derivative_is_None); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "GPy/models/state_space_cython.pyx":360
 *     cpdef dAk(self, int k):
 *         if self.dA is None:
 *             raise ValueError("dA derivative is None")             # <<<<<<<<<<<<<<
 * 
 *         return self.dA # the same dirivative on each iteration
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_dA_derivative_is_None); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "GPy/models/state_space_cython.pyx":817
 *             #log_likelihood_update = log_likelihood_update[0,0] # to make int
 *             if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None.
 *                 raise ValueError("Nan values in likelihood update!")             # <<<<<<<<<<<<<<
 *         else:
 *             log_likelihood_update = None
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Nan_values_in_likelihood_update); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 817, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "GPy/models/state_space_cython.pyx":823
 *     else:
 *         measurement_dim_gt_one = True
 *         raise ValueError("""Measurement dimension larger then 1 is currently not supported""")             # <<<<<<<<<<<<<<
 * 
 *     # Old  method of computing updated covariance (for testing) ->
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Measurement_dimension_larger_the); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 823, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "GPy/models/state_space_cython.pyx":928
 *     # Mean estimations. Initial values will be included
 *     cdef np.ndarray[DTYPE_t, ndim=3] M = np.empty(((steps_no+1),state_dim,time_series_no), dtype=DTYPE)
 *     M[0,:,:] = m_init # Initialize mean values             # <<<<<<<<<<<<<<
 *     # Variance estimations. Initial values will be included
 *     cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim))
 */
  __pyx_tuple__17 = PyTuple_Pack(3, __pyx_int_0, __pyx_slice__10, __pyx_slice__10); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 928, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "GPy/models/state_space_cython.pyx":982
 *         else:
 *             if not np.all(np.isnan(k_measurment)):
 *                     raise ValueError("""Nan measurements are currently not supported if             # <<<<<<<<<<<<<<
 *                                      they are intermixed with not NaN measurements""")
 *             else:
 */
  __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Nan_measurements_are_currently_n); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 982, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":947
 *         __pyx_import_array()
 *     except Exception:
 *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_umath() except -1:
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(2, 947, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":953
 *         _import_umath()
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_ufunc() except -1:
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(2, 953, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "GPy/models/state_space_cython.pyx":547
 * 
 * @cython.boundscheck(False)
 * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P,             # <<<<<<<<<<<<<<
 *                                 Dynamic_Callables_Cython p_dynamic_callables,
 *                                 bint calc_grad_log_likelihood=False,
 */
  __pyx_tuple__21 = PyTuple_Pack(31, __pyx_n_s_k, __pyx_n_s_p_m, __pyx_n_s_p_P, __pyx_n_s_p_dynamic_callables, __pyx_n_s_calc_grad_log_likelihood, __pyx_n_s_p_dm, __pyx_n_s_p_dP, __pyx_n_s_Prev_cov, __pyx_n_s_S_old, __pyx_n_s_V_old, __pyx_n_s_A, __pyx_n_s_Q, __pyx_n_s_Q_sr, __pyx_n_s_m_pred, __pyx_n_s_svd_1_matr, __pyx_n_s_res, __pyx_n_s_U, __pyx_n_s_S, __pyx_n_s_Vh, __pyx_n_s_V_new, __pyx_n_s_S_new, __pyx_n_s_P_pred, __pyx_n_s_dA_all_params, __pyx_n_s_dQ_all_params, __pyx_n_s_dm_pred, __pyx_n_s_dP_pred, __pyx_n_s_param_number, __pyx_n_s_j, __pyx_n_s_ret, __pyx_n_s_dA, __pyx_n_s_dQ); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);
  __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(7, 0, 31, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_GPy_models_state_space_cython_py, __pyx_n_s_kalman_prediction_step_SVD_Cyth, 547, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 547, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":686
 * 
 * @cython.boundscheck(False)
 * def _kalman_update_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m, tuple p_P,             # <<<<<<<<<<<<<<
 *                             Measurement_Callables_Cython p_measurement_callables,
 *                             np.ndarray[DTYPE_t, ndim=2] measurement,
 */
  __pyx_tuple__23 = PyTuple_Pack(52, __pyx_n_s_k, __pyx_n_s_p_m, __pyx_n_s_p_P, __pyx_n_s_p_measurement_callables, __pyx_n_s_measurement, __pyx_n_s_calc_log_likelihood, __pyx_n_s_calc_grad_log_likelihood, __pyx_n_s_p_dm, __pyx_n_s_p_dP, __pyx_n_s_m_pred, __pyx_n_s_P_pred, __pyx_n_s_S_pred, __pyx_n_s_V_pred, __pyx_n_s_H, __pyx_n_s_R, __pyx_n_s_R_isr, __pyx_n_s_time_series_no, __pyx_n_s_log_likelihood_update, __pyx_n_s_v, __pyx_n_s_svd_2_matr, __pyx_n_s_res, __pyx_n_s_U, __pyx_n_s_S_svd, __pyx_n_s_Vh, __pyx_n_s_U_upd, __pyx_n_s_S_upd, __pyx_n_s_P_upd, __pyx_n_s_S, __pyx_n_s_K, __pyx_n_s_measurement_dim_gt_one, __pyx_n_s_dm_upd, __pyx_n_s_dP_upd, __pyx_n_s_d_log_likelihood_update, __pyx_n_s_dm_pred_all_params, __pyx_n_s_dP_pred_all_params, __pyx_n_s_param_number, __pyx_n_s_dH_all_params, __pyx_n_s_dR_all_params, __pyx_n_s_param, __pyx_n_s_dH, __pyx_n_s_dR, __pyx_n_s_dm_pred, __pyx_n_s_dP_pred, __pyx_n_s_dv, __pyx_n_s_dS, __pyx_n_s_tmp1, __pyx_n_s_tmp2, __pyx_n_s_tmp3, __pyx_n_s_dK, __pyx_n_s_tmp5, __pyx_n_s_ret, __pyx_n_s_m_upd); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);
  __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(9, 0, 52, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_GPy_models_state_space_cython_py, __pyx_n_s_kalman_update_step_SVD_Cython, 686, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 686, __pyx_L1_error)

  /* "GPy/models/state_space_cython.pyx":912
 * 
 * @cython.boundscheck(False)
 * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables,             # <<<<<<<<<<<<<<
 *                                   Measurement_Callables_Cython p_measurement_callables, X, Y,
 *                                   np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None,
 */
  __pyx_tuple__25 = PyTuple_Pack(35, __pyx_n_s_state_dim, __pyx_n_s_p_dynamic_callables, __pyx_n_s_p_measurement_callables, __pyx_n_s_X, __pyx_n_s_Y, __pyx_n_s_m_init, __pyx_n_s_P_init, __pyx_n_s_p_kalman_filter_type, __pyx_n_s_calc_log_likelihood, __pyx_n_s_calc_grad_log_likelihood, __pyx_n_s_grad_params_no, __pyx_n_s_dm_init, __pyx_n_s_dP_init, __pyx_n_s_steps_no, __pyx_n_s_time_series_no, __pyx_n_s_M, __pyx_n_s_P, __pyx_n_s_U, __pyx_n_s_S, __pyx_n_s_Vh, __pyx_n_s_P_upd, __pyx_n_s_log_likelihood, __pyx_n_s_grad_log_likelihood, __pyx_n_s_dm_upd, __pyx_n_s_dP_upd, __pyx_n_s_prev_mean, __pyx_n_s_k_measurment, __pyx_n_s_m_pred, __pyx_n_s_m_upd, __pyx_n_s_P_pred, __pyx_n_s_dm_pred, __pyx_n_s_dP_pred, __pyx_n_s_log_likelihood_update, __pyx_n_s_d_log_likelihood_update, __pyx_n_s_k); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);
  __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(13, 0, 35, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_GPy_models_state_space_cython_py, __pyx_n_s_cont_discr_kalman_filter_raw_Cy, 912, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 912, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __pyx_unpickle_Dynamic_Callables_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_tuple__27 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);
  __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Dynamic_Callables, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__29 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);
  __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Measurement_Calla, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__31 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);
  __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_R_handling_Cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__33 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);
  __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Std_Measurement_C, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__35 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);
  __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Q_handling_Cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__37 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);
  __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Std_Dynamic_Calla, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__39 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);
  __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_AQcompute_batch_C, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_float_0_5 = PyFloat_FromDouble(0.5); if (unlikely(!__pyx_float_0_5)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_1eneg_17 = PyFloat_FromDouble(1e-17); if (unlikely(!__pyx_float_1eneg_17)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_neg_0_5 = PyFloat_FromDouble(-0.5); if (unlikely(!__pyx_float_neg_0_5)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_21422583 = PyInt_FromLong(21422583L); if (unlikely(!__pyx_int_21422583)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_117883743 = PyInt_FromLong(117883743L); if (unlikely(!__pyx_int_117883743)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_125522784 = PyInt_FromLong(125522784L); if (unlikely(!__pyx_int_125522784)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_166296743 = PyInt_FromLong(166296743L); if (unlikely(!__pyx_int_166296743)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_222419149 = PyInt_FromLong(222419149L); if (unlikely(!__pyx_int_222419149)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_234819414 = PyInt_FromLong(234819414L); if (unlikely(!__pyx_int_234819414)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  __pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.f_a = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a;
  __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.Ak = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Ak;
  __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.Qk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Qk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.Q_srk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Q_srk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.dAk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dAk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.dQk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dQk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.reset = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset;
  if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.tp_dictoffset && __pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Dynamic_Callables_Cython, (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
  __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython = &__pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython;
  __pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.f_h = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h;
  __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.Hk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Hk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.Rk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Rk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.R_isrk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_R_isrk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.dHk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dHk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.dRk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dRk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.reset = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset *__pyx_optional_args))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset;
  if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.tp_dictoffset && __pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Measurement_Callables_Cython, (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
  __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython = &__pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython;
  __pyx_vtabptr_3GPy_6models_18state_space_cython_R_handling_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython.__pyx_base = *__pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython.__pyx_base.Rk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_Rk;
  __pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython.__pyx_base.R_isrk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_R_isrk;
  __pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython.__pyx_base.dRk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_dRk;
  __pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython.tp_base = __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython;
  if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython) < 0) __PYX_ERR(0, 66, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython.tp_dictoffset && __pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 66, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_3GPy_6models_18state_space_cython_17R_handling_Cython___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_3GPy_6models_18state_space_cython_17R_handling_Cython___init__.doc = __pyx_doc_3GPy_6models_18state_space_cython_17R_handling_Cython___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_3GPy_6models_18state_space_cython_17R_handling_Cython___init__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_R_handling_Cython) < 0) __PYX_ERR(0, 66, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_R_handling_Cython, (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython) < 0) __PYX_ERR(0, 66, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython) < 0) __PYX_ERR(0, 66, __pyx_L1_error)
  __pyx_ptype_3GPy_6models_18state_space_cython_R_handling_Cython = &__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython;
  __pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.__pyx_base = *__pyx_vtabptr_3GPy_6models_18state_space_cython_R_handling_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.__pyx_base.__pyx_base.f_h = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_f_h;
  __pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.__pyx_base.__pyx_base.Hk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_Hk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.__pyx_base.__pyx_base.dHk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_dHk;
  __pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.tp_base = __pyx_ptype_3GPy_6models_18state_space_cython_R_handling_Cython;
  if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython) < 0) __PYX_ERR(0, 165, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.tp_dictoffset && __pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython) < 0) __PYX_ERR(0, 165, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Std_Measurement_Callables_Cython, (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython) < 0) __PYX_ERR(0, 165, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython) < 0) __PYX_ERR(0, 165, __pyx_L1_error)
  __pyx_ptype_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython = &__pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython;
  __pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython.__pyx_base = *__pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython.__pyx_base.Qk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Qk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython.__pyx_base.Q_srk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Q_srk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython.__pyx_base.dQk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_dQk;
  __pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython.tp_base = __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython;
  if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython) < 0) __PYX_ERR(0, 212, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython.tp_dictoffset && __pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 212, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__.doc = __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython) < 0) __PYX_ERR(0, 212, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Q_handling_Cython, (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython) < 0) __PYX_ERR(0, 212, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython) < 0) __PYX_ERR(0, 212, __pyx_L1_error)
  __pyx_ptype_3GPy_6models_18state_space_cython_Q_handling_Cython = &__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython;
  __pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.__pyx_base = *__pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.__pyx_base.__pyx_base.f_a = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_f_a;
  __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.__pyx_base.__pyx_base.Ak = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_Ak;
  __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.__pyx_base.__pyx_base.dAk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_dAk;
  __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.__pyx_base.__pyx_base.reset = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args))__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset;
  __pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.tp_base = __pyx_ptype_3GPy_6models_18state_space_cython_Q_handling_Cython;
  if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython) < 0) __PYX_ERR(0, 318, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.tp_dictoffset && __pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython) < 0) __PYX_ERR(0, 318, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Std_Dynamic_Callables_Cython, (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython) < 0) __PYX_ERR(0, 318, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython) < 0) __PYX_ERR(0, 318, __pyx_L1_error)
  __pyx_ptype_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython = &__pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython;
  __pyx_vtabptr_3GPy_6models_18state_space_cython_AQcompute_batch_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base = *__pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython;
  __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.f_a = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_f_a;
  __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.Ak = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Ak;
  __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.Qk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Qk;
  __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.Q_srk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_srk;
  __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.dAk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dAk;
  __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.dQk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dQk;
  __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.reset = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset;
  __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.Q_inverse = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *, int, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_inverse *__pyx_optional_args))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_inverse;
  __pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.tp_base = __pyx_ptype_3GPy_6models_18state_space_cython_Q_handling_Cython;
  if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.tp_dictoffset && __pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 373, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__.doc = __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_AQcompute_batch_Cython) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_AQcompute_batch_Cython, (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
  __pyx_ptype_3GPy_6models_18state_space_cython_AQcompute_batch_Cython = &__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", 
  #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(2, 200, __pyx_L1_error)
  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(2, 223, __pyx_L1_error)
  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(2, 227, __pyx_L1_error)
  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(2, 239, __pyx_L1_error)
  __pyx_ptype_5numpy_generic = __Pyx_ImportType(__pyx_t_1, "numpy", "generic", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_generic) __PYX_ERR(2, 771, __pyx_L1_error)
  __pyx_ptype_5numpy_number = __Pyx_ImportType(__pyx_t_1, "numpy", "number", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_number) __PYX_ERR(2, 773, __pyx_L1_error)
  __pyx_ptype_5numpy_integer = __Pyx_ImportType(__pyx_t_1, "numpy", "integer", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_integer) __PYX_ERR(2, 775, __pyx_L1_error)
  __pyx_ptype_5numpy_signedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "signedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_signedinteger) __PYX_ERR(2, 777, __pyx_L1_error)
  __pyx_ptype_5numpy_unsignedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "unsignedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_unsignedinteger) __PYX_ERR(2, 779, __pyx_L1_error)
  __pyx_ptype_5numpy_inexact = __Pyx_ImportType(__pyx_t_1, "numpy", "inexact", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_inexact) __PYX_ERR(2, 781, __pyx_L1_error)
  __pyx_ptype_5numpy_floating = __Pyx_ImportType(__pyx_t_1, "numpy", "floating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_floating) __PYX_ERR(2, 783, __pyx_L1_error)
  __pyx_ptype_5numpy_complexfloating = __Pyx_ImportType(__pyx_t_1, "numpy", "complexfloating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_complexfloating) __PYX_ERR(2, 785, __pyx_L1_error)
  __pyx_ptype_5numpy_flexible = __Pyx_ImportType(__pyx_t_1, "numpy", "flexible", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_flexible) __PYX_ERR(2, 787, __pyx_L1_error)
  __pyx_ptype_5numpy_character = __Pyx_ImportType(__pyx_t_1, "numpy", "character", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_character) __PYX_ERR(2, 789, __pyx_L1_error)
  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(2, 827, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}


#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initstate_space_cython(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initstate_space_cython(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_state_space_cython(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_state_space_cython(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_state_space_cython(PyObject *__pyx_pyinit_module)
#endif
#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_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'state_space_cython' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #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("__Pyx_PyMODINIT_FUNC PyInit_state_space_cython(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __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 CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("state_space_cython", __pyx_methods, __pyx_k_Contains_some_cython_code_for_s, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_b);
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_cython_runtime);
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __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_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_GPy__models__state_space_cython) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "GPy.models.state_space_cython")) {
      if (unlikely(PyDict_SetItemString(modules, "GPy.models.state_space_cython", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  (void)__Pyx_modinit_function_export_code();
  if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  (void)__Pyx_modinit_variable_import_code();
  (void)__Pyx_modinit_function_import_code();
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "GPy/models/state_space_cython.pyx":5
 * Contains some cython code for state space modelling.
 * """
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * import scipy as sp
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":7
 * import numpy as np
 * cimport numpy as np
 * import scipy as sp             # <<<<<<<<<<<<<<
 * cimport cython
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_scipy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sp, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":14
 *     bint npy_isnan(double x)
 * 
 * DTYPE = np.float64             # <<<<<<<<<<<<<<
 * DTYPE_int = np.int64
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GPy/models/state_space_cython.pyx":15
 * 
 * DTYPE = np.float64
 * DTYPE_int = np.int64             # <<<<<<<<<<<<<<
 * 
 * ctypedef np.float64_t DTYPE_t
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE_int, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":547
 * 
 * @cython.boundscheck(False)
 * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P,             # <<<<<<<<<<<<<<
 *                                 Dynamic_Callables_Cython p_dynamic_callables,
 *                                 bint calc_grad_log_likelihood=False,
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_1_kalman_prediction_step_SVD_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_kalman_prediction_step_SVD_Cyth, __pyx_t_1) < 0) __PYX_ERR(0, 547, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":686
 * 
 * @cython.boundscheck(False)
 * def _kalman_update_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m, tuple p_P,             # <<<<<<<<<<<<<<
 *                             Measurement_Callables_Cython p_measurement_callables,
 *                             np.ndarray[DTYPE_t, ndim=2] measurement,
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_3_kalman_update_step_SVD_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_kalman_update_step_SVD_Cython, __pyx_t_1) < 0) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":912
 * 
 * @cython.boundscheck(False)
 * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables,             # <<<<<<<<<<<<<<
 *                                   Measurement_Callables_Cython p_measurement_callables, X, Y,
 *                                   np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None,
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_5_cont_discr_kalman_filter_raw_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cont_discr_kalman_filter_raw_Cy, __pyx_t_1) < 0) __PYX_ERR(0, 912, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Dynamic_Callables_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_7__pyx_unpickle_Dynamic_Callables_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Dynamic_Callables, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_Dynamic_Callables_Cython__set_state(<Dynamic_Callables_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Dynamic_Callables_Cython__set_state(Dynamic_Callables_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_9__pyx_unpickle_Measurement_Callables_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Measurement_Calla, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_R_handling_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_11__pyx_unpickle_R_handling_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_R_handling_Cython, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_R_handling_Cython__set_state(<R_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_R_handling_Cython__set_state(R_handling_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.R = __pyx_state[0]; __pyx_result.R_square_root = __pyx_state[1]; __pyx_result.R_time_var_index = __pyx_state[2]; __pyx_result.dR = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_13__pyx_unpickle_Std_Measurement_Callables_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Std_Measurement_C, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Q_handling_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_15__pyx_unpickle_Q_handling_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Q_handling_Cython, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_Q_handling_Cython__set_state(<Q_handling_Cython> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Q_handling_Cython__set_state(Q_handling_Cython __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.Q = __pyx_state[0]; __pyx_result.Q_square_root = __pyx_state[1]; __pyx_result.Q_time_var_index = __pyx_state[2]; __pyx_result.dQ = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.svd_each_time = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_17__pyx_unpickle_Std_Dynamic_Callables_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Std_Dynamic_Calla, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_AQcompute_batch_Cython(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_19__pyx_unpickle_AQcompute_batch_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_AQcompute_batch_C, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GPy/models/state_space_cython.pyx":1
 * # -*- coding: utf-8 -*-             # <<<<<<<<<<<<<<
 * """
 * Contains some cython code for state space modelling.
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "../../.pyenv/versions/gpy391/lib/python3.9/site-packages/numpy/__init__.pxd":1016
 * 
 * 
 * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the unit part of the dtype for a numpy datetime64 object.
 */

  /*--- 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 GPy.models.state_space_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init GPy.models.state_space_cython");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
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);
}
#endif

/* GetBuiltinName */
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;
}

/* IsLittleEndian */
static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
{
  union {
    uint32_t u32;
    uint8_t u8[4];
  } S;
  S.u32 = 0x01020304;
  return S.u8[0] == 4;
}

/* BufferFormatCheck */
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 '?': return "'bool'";
    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 '?': 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 '?': 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 PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
{
    const char *ts = *tsp;
    int i = 0, number, 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;
    ndim = ctx->head->field->type->ndim;
    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_Is_Little_Endian()) {
          PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '>':
      case '!':
        if (__Pyx_Is_Little_Endian()) {
          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;
        }
        CYTHON_FALLTHROUGH;
      case '?': 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->is_valid_array)) {
          ctx->enc_count += ctx->new_count;
          ctx->new_count = 1;
          got_Z = 0;
          ++ts;
          break;
        }
        CYTHON_FALLTHROUGH;
      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;
        }
    }
  }
}

/* BufferGetAndValidate */
  static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  if (unlikely(info->buf == NULL)) return;
  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  __Pyx_ReleaseBuffer(info);
}
static 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 int __Pyx__GetBufferAndValidate(
        Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
        int nd, int cast, __Pyx_BufFmt_StackElem* stack)
{
  buf->buf = NULL;
  if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) {
    __Pyx_ZeroBuffer(buf);
    return -1;
  }
  if (unlikely(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 (unlikely((size_t)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_SafeReleaseBuffer(buf);
  return -1;
}

/* PyDictVersioning */
  #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* PyFunctionFastCall */
  #if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyCFunctionFastCall */
  #if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyObjectCall */
  #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

/* PyErrFetchRestore */
  #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    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);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* RaiseException */
  #if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    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_PyThreadState_assign
    __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) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        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 (cause) {
        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 = __Pyx_PyThreadState_Current;
        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

/* RaiseArgTupleInvalid */
  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);
}

/* RaiseDoubleKeywords */
  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
}

/* ParseKeywords */
  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_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
                    (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(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
                        (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(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;
}

/* ArgTypeTest */
  static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* PyObjectCall2Args */
  static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* PyObjectCallMethO */
  #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

/* PyObjectCallOneArg */
  #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) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyErrExceptionMatches */
  #if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetAttr */
  static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#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);
}

/* GetAttr3 */
  static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}

/* GetModuleGlobalName */
  #if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* GetItemInt */
  static 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,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_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,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_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,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(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(__Pyx_is_valid_index(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))
                        return NULL;
                    PyErr_Clear();
                }
            }
            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));
}

/* ObjectGetItem */
  #if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* ExtTypeTest */
  static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* BufferFallbackError */
  static void __Pyx_RaiseBufferFallbackError(void) {
  PyErr_SetString(PyExc_ValueError,
     "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
}

/* RaiseTooManyValuesToUnpack */
  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);
}

/* RaiseNeedMoreValuesToUnpack */
  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");
}

/* IterFinish */
  static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_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
}

/* UnpackItemEndCheck */
  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;
}

/* DictGetItem */
  #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            if (unlikely(PyTuple_Check(key))) {
                PyObject* args = PyTuple_Pack(1, key);
                if (likely(args)) {
                    PyErr_SetObject(PyExc_KeyError, args);
                    Py_DECREF(args);
                }
            } else {
                PyErr_SetObject(PyExc_KeyError, key);
            }
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* PyObjectSetAttrStr */
  #if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#endif

/* SetItemInt */
  static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_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))
                        return -1;
                    PyErr_Clear();
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o)))
#else
    if (is_list || PySequence_Check(o))
#endif
    {
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

/* PyFloatBinop */
  #if !CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyFloat_DivideCObj_ZeroDivisionError(operand) if (unlikely(zerodivision_check && ((operand) == 0))) {\
    PyErr_SetString(PyExc_ZeroDivisionError, "float division by zero");\
    return NULL;\
}
static PyObject* __Pyx_PyFloat_DivideCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) {
    const double a = floatval;
    double b, result;
    (void)inplace;
    (void)zerodivision_check;
    if (likely(PyFloat_CheckExact(op2))) {
        b = PyFloat_AS_DOUBLE(op2);
        __Pyx_PyFloat_DivideCObj_ZeroDivisionError(b)
    } else
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        b = (double) PyInt_AS_LONG(op2);
        __Pyx_PyFloat_DivideCObj_ZeroDivisionError(b)
    } else
    #endif
    if (likely(PyLong_CheckExact(op2))) {
        #if CYTHON_USE_PYLONG_INTERNALS
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        switch (size) {
            case  0: __Pyx_PyFloat_DivideCObj_ZeroDivisionError(0) break;
            case -1: b = -(double) digits[0]; break;
            case  1: b = (double) digits[0]; break;
            case -2:
            case 2:
                if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) {
                    b = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -2)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            case -3:
            case 3:
                if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -3)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            case -4:
            case 4:
                if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -4)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            default:
        #else
        {
        #endif
            b = PyLong_AsDouble(op2);
            if (unlikely(b == -1.0 && PyErr_Occurred())) return NULL;
            __Pyx_PyFloat_DivideCObj_ZeroDivisionError(b)
        }
    } else {
        return (inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2));
    }
        __Pyx_PyFloat_DivideCObj_ZeroDivisionError(b)
        PyFPE_START_PROTECT("divide", return NULL)
        result = a / b;
        PyFPE_END_PROTECT(result)
        return PyFloat_FromDouble(result);
}
#endif

/* Import */
    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_MAJOR_VERSION < 3
    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 ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
    static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* HasAttr */
    static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* GetTopmostException */
    #if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
    #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    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;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* GetException */
    #if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    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_FAST_THREAD_STATE
    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_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    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;
    #endif
    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;
}

/* CallNextTpTraverse */
    static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_traverse != current_tp_traverse)
        type = type->tp_base;
    while (type && type->tp_traverse == current_tp_traverse)
        type = type->tp_base;
    if (type && type->tp_traverse)
        return type->tp_traverse(obj, v, a);
    return 0;
}

/* CallNextTpClear */
    static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_clear != current_tp_clear)
        type = type->tp_base;
    while (type && type->tp_clear == current_tp_clear)
        type = type->tp_base;
    if (type && type->tp_clear)
        type->tp_clear(obj);
}

/* PyObject_GenericGetAttrNoDict */
    #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PyObject_GenericGetAttr */
    #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

/* SetVTable */
    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;
}

/* PyObjectGetAttrStrNoError */
    static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        __Pyx_PyErr_Clear();
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
        return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
    }
#endif
    result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
    if (unlikely(!result)) {
        __Pyx_PyObject_GetAttrStr_ClearAttributeError();
    }
    return result;
}

/* SetupReduce */
    static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
            if (likely(reduce_cython)) {
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
            } else if (reduce == object_reduce || PyErr_Occurred()) {
                goto __PYX_BAD;
            }
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
                if (likely(setstate_cython)) {
                    ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                    ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                } else if (!setstate || PyErr_Occurred()) {
                    goto __PYX_BAD;
                }
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto __PYX_GOOD;
__PYX_BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
__PYX_GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* TypeImport */
    #ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    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 ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif

/* CLineInTraceback */
    #ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
    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 - start) / 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);
}

/* AddTraceback */
    #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;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    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(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 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);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntFromPyVerify */
    #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        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 (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

#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);
    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 ((0)) {}
    view->obj = NULL;
    Py_DECREF(obj);
}
#endif


    /* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 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);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) {
    const Py_intptr_t neg_one = (Py_intptr_t) ((Py_intptr_t) 0 - (Py_intptr_t) 1), const_zero = (Py_intptr_t) 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);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(Py_intptr_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        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);
    }
}

/* Declarations */
    #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

/* Arithmetic */
    #if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq_float(__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_sum_float(__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_diff_float(__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_prod_float(__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;
    }
    #if 1
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        if (b.imag == 0) {
            return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else if (fabsf(b.real) >= fabsf(b.imag)) {
            if (b.real == 0 && b.imag == 0) {
                return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
            } else {
                float r = b.imag / b.real;
                float s = (float)(1.0) / (b.real + b.imag * r);
                return __pyx_t_float_complex_from_parts(
                    (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
            }
        } else {
            float r = b.real / b.imag;
            float s = (float)(1.0) / (b.imag + b.real * r);
            return __pyx_t_float_complex_from_parts(
                (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
        }
    }
    #else
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        if (b.imag == 0) {
            return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else {
            float denom = b.real * b.real + b.imag * b.imag;
            return __pyx_t_float_complex_from_parts(
                (a.real * b.real + a.imag * b.imag) / denom,
                (a.imag * b.real - a.real * b.imag) / denom);
        }
    }
    #endif
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__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_zero_float(__pyx_t_float_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__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_abs_float(__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_pow_float(__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:
                        return __Pyx_c_prod_float(a, a);
                    case 3:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(z, a);
                    case 4:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                } else if (b.imag == 0) {
                    z.real = powf(a.real, b.real);
                    z.imag = 0;
                    return z;
                } else if (a.real > 0) {
                    r = a.real;
                    theta = 0;
                } else {
                    r = -a.real;
                    theta = atan2f(0.0, -1.0);
                }
            } else {
                r = __Pyx_c_abs_float(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

/* Declarations */
    #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

/* Arithmetic */
    #if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq_double(__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_double(__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_double(__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_double(__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;
    }
    #if 1
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        if (b.imag == 0) {
            return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else if (fabs(b.real) >= fabs(b.imag)) {
            if (b.real == 0 && b.imag == 0) {
                return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
            } else {
                double r = b.imag / b.real;
                double s = (double)(1.0) / (b.real + b.imag * r);
                return __pyx_t_double_complex_from_parts(
                    (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
            }
        } else {
            double r = b.real / b.imag;
            double s = (double)(1.0) / (b.imag + b.real * r);
            return __pyx_t_double_complex_from_parts(
                (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
        }
    }
    #else
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        if (b.imag == 0) {
            return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else {
            double denom = b.real * b.real + b.imag * b.imag;
            return __pyx_t_double_complex_from_parts(
                (a.real * b.real + a.imag * b.imag) / denom,
                (a.imag * b.real - a.real * b.imag) / denom);
        }
    }
    #endif
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__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_double(__pyx_t_double_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__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_double(__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_double(__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:
                        return __Pyx_c_prod_double(a, a);
                    case 3:
                        z = __Pyx_c_prod_double(a, a);
                        return __Pyx_c_prod_double(z, a);
                    case 4:
                        z = __Pyx_c_prod_double(a, a);
                        return __Pyx_c_prod_double(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                } else if (b.imag == 0) {
                    z.real = pow(a.real, b.real);
                    z.imag = 0;
                    return z;
                } else if (a.real > 0) {
                    r = a.real;
                    theta = 0;
                } else {
                    r = -a.real;
                    theta = atan2(0.0, -1.0);
                }
            } else {
                r = __Pyx_c_abs_double(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

/* CIntFromPy */
    static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 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_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#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_IntOrLong(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_IntOrLong(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;
}

/* CIntFromPy */
    static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 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_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#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_IntOrLong(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_IntOrLong(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;
}

/* FastTypeChecks */
    #if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* CheckBinaryVersion */
    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;
}

/* InitStrings */
    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;
        if (PyObject_Hash(*t->p) == -1)
            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 const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    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
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(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
#endif
static CYTHON_INLINE const 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)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    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 int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  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))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #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_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
