/* Generated by Cython 0.29.22 */

#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_22"
#define CYTHON_HEX_VERSION 0x001D16F0
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#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__libpetsc4py
#define __PYX_HAVE_API__libpetsc4py
/* Early includes */
#include "petsc.h"
#include "custom.h"
#include "scalar.h"
#include "string.h"
#include "petsc4py/numpy.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;


static const char *__pyx_f[] = {
  "libpetsc4py/libpetsc4py.pyx",
  "include/arraynpy.pxi",
  "include/petsc4py/PETSc.pxd",
};
/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

/* NoFastGil.proto */
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
#define __Pyx_PyGILState_Release PyGILState_Release
#define __Pyx_FastGIL_Remember()
#define __Pyx_FastGIL_Forget()
#define __Pyx_FastGilFuncInit()


/*--- Type declarations ---*/
struct PyPetscCommObject;
struct PyPetscObjectObject;
struct PyPetscViewerObject;
struct PyPetscRandomObject;
struct PyPetscISObject;
struct PyPetscLGMapObject;
struct PyPetscSFObject;
struct PyPetscVecObject;
struct PyPetscFEObject;
struct PyPetscQuadObject;
struct PyPetscScatterObject;
struct PyPetscSectionObject;
struct PyPetscMatObject;
struct PyPetscNullSpaceObject;
struct PyPetscPCObject;
struct PyPetscKSPObject;
struct PyPetscSNESObject;
struct PyPetscTSObject;
struct PyPetscTAOObject;
struct PyPetscAOObject;
struct PyPetscDMObject;
struct PyPetscDSObject;
struct PyPetscPartitionerObject;
struct PyPetscDMLabelObject;
struct __pyx_obj_11libpetsc4py__PyObj;
struct __pyx_obj_11libpetsc4py__PyMat;
struct __pyx_obj_11libpetsc4py__PyPC;
struct __pyx_obj_11libpetsc4py__PyKSP;
struct __pyx_obj_11libpetsc4py__PySNES;
struct __pyx_obj_11libpetsc4py__PyTS;

/* "petsc4py/PETSc.pxd":91
 * # --------------------------------------------------------------------
 * 
 * ctypedef public api class Comm [             # <<<<<<<<<<<<<<
 *     type   PyPetscComm_Type,
 *     object PyPetscCommObject,
 */
struct PyPetscCommObject {
  PyObject_HEAD
  MPI_Comm comm;
  int isdup;
  PyObject *base;
};
typedef struct PyPetscCommObject PyPetscCommObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscComm_Type;

/* "petsc4py/PETSc.pxd":99
 *     cdef object base
 * 
 * ctypedef public api class Object [             # <<<<<<<<<<<<<<
 *     type   PyPetscObject_Type,
 *     object PyPetscObjectObject,
 */
struct PyPetscObjectObject {
  PyObject_HEAD
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object *__pyx_vtab;
  PyObject *__weakref__;
  PyObject *__pyx___dummy__;
  PetscObject oval;
  PetscObject *obj;
};
typedef struct PyPetscObjectObject PyPetscObjectObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscObject_Type;

/* "petsc4py/PETSc.pxd":111
 *     cdef object get_dict(self)
 * 
 * ctypedef public api class Viewer(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscViewer_Type,
 *     object PyPetscViewerObject,
 */
struct PyPetscViewerObject {
  struct PyPetscObjectObject __pyx_base;
  PetscViewer vwr;
};
typedef struct PyPetscViewerObject PyPetscViewerObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscViewer_Type;

/* "petsc4py/PETSc.pxd":117
 *     cdef PetscViewer vwr
 * 
 * ctypedef public api class Random(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscRandom_Type,
 *     object PyPetscRandomObject,
 */
struct PyPetscRandomObject {
  struct PyPetscObjectObject __pyx_base;
  PetscRandom rnd;
};
typedef struct PyPetscRandomObject PyPetscRandomObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscRandom_Type;

/* "petsc4py/PETSc.pxd":123
 *     cdef PetscRandom rnd
 * 
 * ctypedef public api class IS(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscIS_Type,
 *     object PyPetscISObject,
 */
struct PyPetscISObject {
  struct PyPetscObjectObject __pyx_base;
  IS iset;
};
typedef struct PyPetscISObject PyPetscISObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscIS_Type;

/* "petsc4py/PETSc.pxd":129
 *     cdef PetscIS iset
 * 
 * ctypedef public api class LGMap(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscLGMap_Type,
 *     object PyPetscLGMapObject,
 */
struct PyPetscLGMapObject {
  struct PyPetscObjectObject __pyx_base;
  ISLocalToGlobalMapping lgm;
};
typedef struct PyPetscLGMapObject PyPetscLGMapObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscLGMap_Type;

/* "petsc4py/PETSc.pxd":135
 *     cdef PetscLGMap lgm
 * 
 * ctypedef public api class SF(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscSF_Type,
 *     object PyPetscSFObject,
 */
struct PyPetscSFObject {
  struct PyPetscObjectObject __pyx_base;
  PetscSF sf;
};
typedef struct PyPetscSFObject PyPetscSFObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscSF_Type;

/* "petsc4py/PETSc.pxd":141
 *     cdef PetscSF sf
 * 
 * ctypedef public api class Vec(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscVec_Type,
 *     object PyPetscVecObject,
 */
struct PyPetscVecObject {
  struct PyPetscObjectObject __pyx_base;
  Vec vec;
};
typedef struct PyPetscVecObject PyPetscVecObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscVec_Type;

/* "petsc4py/PETSc.pxd":147
 *     cdef PetscVec vec
 * 
 * ctypedef public api class FE(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscFE_Type,
 *     object PyPetscFEObject,
 */
struct PyPetscFEObject {
  struct PyPetscObjectObject __pyx_base;
  PetscFE fe;
};
typedef struct PyPetscFEObject PyPetscFEObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscFE_Type;

/* "petsc4py/PETSc.pxd":153
 *     cdef PetscFE fe
 * 
 * ctypedef public api class Quad(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscQuad_Type,
 *     object PyPetscQuadObject,
 */
struct PyPetscQuadObject {
  struct PyPetscObjectObject __pyx_base;
  PetscQuadrature quad;
};
typedef struct PyPetscQuadObject PyPetscQuadObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscQuad_Type;

/* "petsc4py/PETSc.pxd":159
 *     cdef PetscQuadrature quad
 * 
 * ctypedef public api class Scatter(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscScatter_Type,
 *     object PyPetscScatterObject,
 */
struct PyPetscScatterObject {
  struct PyPetscObjectObject __pyx_base;
  VecScatter sct;
};
typedef struct PyPetscScatterObject PyPetscScatterObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscScatter_Type;

/* "petsc4py/PETSc.pxd":165
 *     cdef PetscScatter sct
 * 
 * ctypedef public api class Section(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscSection_Type,
 *     object PyPetscSectionObject,
 */
struct PyPetscSectionObject {
  struct PyPetscObjectObject __pyx_base;
  PetscSection sec;
};
typedef struct PyPetscSectionObject PyPetscSectionObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscSection_Type;

/* "petsc4py/PETSc.pxd":171
 *     cdef PetscSection sec
 * 
 * ctypedef public api class Mat(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscMat_Type,
 *     object PyPetscMatObject,
 */
struct PyPetscMatObject {
  struct PyPetscObjectObject __pyx_base;
  Mat mat;
};
typedef struct PyPetscMatObject PyPetscMatObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscMat_Type;

/* "petsc4py/PETSc.pxd":177
 *     cdef PetscMat mat
 * 
 * ctypedef public api class NullSpace(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscNullSpace_Type,
 *     object PyPetscNullSpaceObject,
 */
struct PyPetscNullSpaceObject {
  struct PyPetscObjectObject __pyx_base;
  MatNullSpace nsp;
};
typedef struct PyPetscNullSpaceObject PyPetscNullSpaceObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscNullSpace_Type;

/* "petsc4py/PETSc.pxd":183
 *     cdef PetscNullSpace nsp
 * 
 * ctypedef public api class PC(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscPC_Type,
 *     object PyPetscPCObject,
 */
struct PyPetscPCObject {
  struct PyPetscObjectObject __pyx_base;
  PC pc;
};
typedef struct PyPetscPCObject PyPetscPCObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscPC_Type;

/* "petsc4py/PETSc.pxd":189
 *     cdef PetscPC pc
 * 
 * ctypedef public api class KSP(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscKSP_Type,
 *     object PyPetscKSPObject,
 */
struct PyPetscKSPObject {
  struct PyPetscObjectObject __pyx_base;
  KSP ksp;
};
typedef struct PyPetscKSPObject PyPetscKSPObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscKSP_Type;

/* "petsc4py/PETSc.pxd":195
 *     cdef PetscKSP ksp
 * 
 * ctypedef public api class SNES(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscSNES_Type,
 *     object PyPetscSNESObject,
 */
struct PyPetscSNESObject {
  struct PyPetscObjectObject __pyx_base;
  SNES snes;
};
typedef struct PyPetscSNESObject PyPetscSNESObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscSNES_Type;

/* "petsc4py/PETSc.pxd":201
 *     cdef PetscSNES snes
 * 
 * ctypedef public api class TS(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscTS_Type,
 *     object PyPetscTSObject,
 */
struct PyPetscTSObject {
  struct PyPetscObjectObject __pyx_base;
  TS ts;
};
typedef struct PyPetscTSObject PyPetscTSObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscTS_Type;

/* "petsc4py/PETSc.pxd":207
 *     cdef PetscTS ts
 * 
 * ctypedef public api class TAO(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscTAO_Type,
 *     object PyPetscTAOObject,
 */
struct PyPetscTAOObject {
  struct PyPetscObjectObject __pyx_base;
  Tao tao;
};
typedef struct PyPetscTAOObject PyPetscTAOObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscTAO_Type;

/* "petsc4py/PETSc.pxd":213
 *     cdef PetscTAO tao
 * 
 * ctypedef public api class AO(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscAO_Type,
 *     object PyPetscAOObject,
 */
struct PyPetscAOObject {
  struct PyPetscObjectObject __pyx_base;
  AO ao;
};
typedef struct PyPetscAOObject PyPetscAOObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscAO_Type;

/* "petsc4py/PETSc.pxd":219
 *     cdef PetscAO ao
 * 
 * ctypedef public api class DM(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscDM_Type,
 *     object PyPetscDMObject,
 */
struct PyPetscDMObject {
  struct PyPetscObjectObject __pyx_base;
  DM dm;
};
typedef struct PyPetscDMObject PyPetscDMObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscDM_Type;

/* "petsc4py/PETSc.pxd":225
 *     cdef PetscDM dm
 * 
 * ctypedef public api class DS(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscDS_Type,
 *     object PyPetscDSObject,
 */
struct PyPetscDSObject {
  struct PyPetscObjectObject __pyx_base;
  PetscDS ds;
};
typedef struct PyPetscDSObject PyPetscDSObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscDS_Type;

/* "petsc4py/PETSc.pxd":231
 *     cdef PetscDS ds
 * 
 * ctypedef public api class Partitioner(Object) [             # <<<<<<<<<<<<<<
 *     type PyPetscPartitioner_Type,
 *     object PyPetscPartitionerObject,
 */
struct PyPetscPartitionerObject {
  struct PyPetscObjectObject __pyx_base;
  PetscPartitioner part;
};
typedef struct PyPetscPartitionerObject PyPetscPartitionerObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscPartitioner_Type;

/* "petsc4py/PETSc.pxd":237
 *     cdef PetscPartitioner part
 * 
 * ctypedef public api class DMLabel(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscDMLabel_Type,
 *     object PyPetscDMLabelObject,
 */
struct PyPetscDMLabelObject {
  struct PyPetscObjectObject __pyx_base;
  DMLabel dmlabel;
};
typedef struct PyPetscDMLabelObject PyPetscDMLabelObject;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscDMLabel_Type;

/* "libpetsc4py.pyx":296
 * 
 * @cython.internal
 * cdef class _PyObj:             # <<<<<<<<<<<<<<
 * 
 *     cdef object self
 */
struct __pyx_obj_11libpetsc4py__PyObj {
  PyObject_HEAD
  struct __pyx_vtabstruct_11libpetsc4py__PyObj *__pyx_vtab;
  PyObject *self;
  PyObject *name;
};


/* "libpetsc4py.pyx":527
 * 
 * @cython.internal
 * cdef class _PyMat(_PyObj): pass             # <<<<<<<<<<<<<<
 * cdef inline _PyMat PyMat(PetscMat mat):
 *     if mat != NULL and mat.data != NULL:
 */
struct __pyx_obj_11libpetsc4py__PyMat {
  struct __pyx_obj_11libpetsc4py__PyObj __pyx_base;
};


/* "libpetsc4py.pyx":1201
 * 
 * @cython.internal
 * cdef class _PyPC(_PyObj): pass             # <<<<<<<<<<<<<<
 * cdef inline _PyPC PyPC(PetscPC pc):
 *     if pc != NULL and pc.data != NULL:
 */
struct __pyx_obj_11libpetsc4py__PyPC {
  struct __pyx_obj_11libpetsc4py__PyObj __pyx_base;
};


/* "libpetsc4py.pyx":1477
 * 
 * @cython.internal
 * cdef class _PyKSP(_PyObj): pass             # <<<<<<<<<<<<<<
 * cdef inline _PyKSP PyKSP(PetscKSP ksp):
 *     if ksp != NULL and ksp.data != NULL:
 */
struct __pyx_obj_11libpetsc4py__PyKSP {
  struct __pyx_obj_11libpetsc4py__PyObj __pyx_base;
};


/* "libpetsc4py.pyx":1839
 * 
 * @cython.internal
 * cdef class _PySNES(_PyObj): pass             # <<<<<<<<<<<<<<
 * cdef inline _PySNES PySNES(PetscSNES snes):
 *     if snes != NULL and snes.data != NULL:
 */
struct __pyx_obj_11libpetsc4py__PySNES {
  struct __pyx_obj_11libpetsc4py__PyObj __pyx_base;
};


/* "libpetsc4py.pyx":2185
 * 
 * @cython.internal
 * cdef class _PyTS(_PyObj): pass             # <<<<<<<<<<<<<<
 * cdef inline _PyTS PyTS(PetscTS ts):
 *     if ts != NULL and ts.data != NULL:
 */
struct __pyx_obj_11libpetsc4py__PyTS {
  struct __pyx_obj_11libpetsc4py__PyObj __pyx_base;
};


__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscObject_Type;

/* "petsc4py/PETSc.pxd":99
 *     cdef object base
 * 
 * ctypedef public api class Object [             # <<<<<<<<<<<<<<
 *     type   PyPetscObject_Type,
 *     object PyPetscObjectObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_Object {
  PyObject *(*get_attr)(struct PyPetscObjectObject *, char *);
  PyObject *(*set_attr)(struct PyPetscObjectObject *, char *, PyObject *);
  PyObject *(*get_dict)(struct PyPetscObjectObject *);
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_Object *__pyx_vtabptr_8petsc4py_5PETSc_Object;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscViewer_Type;

/* "petsc4py/PETSc.pxd":111
 *     cdef object get_dict(self)
 * 
 * ctypedef public api class Viewer(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscViewer_Type,
 *     object PyPetscViewerObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_Viewer {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_Viewer *__pyx_vtabptr_8petsc4py_5PETSc_Viewer;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscRandom_Type;

/* "petsc4py/PETSc.pxd":117
 *     cdef PetscViewer vwr
 * 
 * ctypedef public api class Random(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscRandom_Type,
 *     object PyPetscRandomObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_Random {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_Random *__pyx_vtabptr_8petsc4py_5PETSc_Random;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscIS_Type;

/* "petsc4py/PETSc.pxd":123
 *     cdef PetscRandom rnd
 * 
 * ctypedef public api class IS(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscIS_Type,
 *     object PyPetscISObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_IS {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_IS *__pyx_vtabptr_8petsc4py_5PETSc_IS;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscLGMap_Type;

/* "petsc4py/PETSc.pxd":129
 *     cdef PetscIS iset
 * 
 * ctypedef public api class LGMap(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscLGMap_Type,
 *     object PyPetscLGMapObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_LGMap {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_LGMap *__pyx_vtabptr_8petsc4py_5PETSc_LGMap;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscSF_Type;

/* "petsc4py/PETSc.pxd":135
 *     cdef PetscLGMap lgm
 * 
 * ctypedef public api class SF(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscSF_Type,
 *     object PyPetscSFObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_SF {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_SF *__pyx_vtabptr_8petsc4py_5PETSc_SF;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscVec_Type;

/* "petsc4py/PETSc.pxd":141
 *     cdef PetscSF sf
 * 
 * ctypedef public api class Vec(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscVec_Type,
 *     object PyPetscVecObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_Vec {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_Vec *__pyx_vtabptr_8petsc4py_5PETSc_Vec;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscFE_Type;

/* "petsc4py/PETSc.pxd":147
 *     cdef PetscVec vec
 * 
 * ctypedef public api class FE(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscFE_Type,
 *     object PyPetscFEObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_FE {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_FE *__pyx_vtabptr_8petsc4py_5PETSc_FE;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscQuad_Type;

/* "petsc4py/PETSc.pxd":153
 *     cdef PetscFE fe
 * 
 * ctypedef public api class Quad(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscQuad_Type,
 *     object PyPetscQuadObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_Quad {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_Quad *__pyx_vtabptr_8petsc4py_5PETSc_Quad;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscScatter_Type;

/* "petsc4py/PETSc.pxd":159
 *     cdef PetscQuadrature quad
 * 
 * ctypedef public api class Scatter(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscScatter_Type,
 *     object PyPetscScatterObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_Scatter {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_Scatter *__pyx_vtabptr_8petsc4py_5PETSc_Scatter;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscSection_Type;

/* "petsc4py/PETSc.pxd":165
 *     cdef PetscScatter sct
 * 
 * ctypedef public api class Section(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscSection_Type,
 *     object PyPetscSectionObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_Section {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_Section *__pyx_vtabptr_8petsc4py_5PETSc_Section;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscMat_Type;

/* "petsc4py/PETSc.pxd":171
 *     cdef PetscSection sec
 * 
 * ctypedef public api class Mat(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscMat_Type,
 *     object PyPetscMatObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_Mat {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_Mat *__pyx_vtabptr_8petsc4py_5PETSc_Mat;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscNullSpace_Type;

/* "petsc4py/PETSc.pxd":177
 *     cdef PetscMat mat
 * 
 * ctypedef public api class NullSpace(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscNullSpace_Type,
 *     object PyPetscNullSpaceObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_NullSpace {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_NullSpace *__pyx_vtabptr_8petsc4py_5PETSc_NullSpace;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscPC_Type;

/* "petsc4py/PETSc.pxd":183
 *     cdef PetscNullSpace nsp
 * 
 * ctypedef public api class PC(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscPC_Type,
 *     object PyPetscPCObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_PC {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_PC *__pyx_vtabptr_8petsc4py_5PETSc_PC;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscKSP_Type;

/* "petsc4py/PETSc.pxd":189
 *     cdef PetscPC pc
 * 
 * ctypedef public api class KSP(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscKSP_Type,
 *     object PyPetscKSPObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_KSP {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_KSP *__pyx_vtabptr_8petsc4py_5PETSc_KSP;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscSNES_Type;

/* "petsc4py/PETSc.pxd":195
 *     cdef PetscKSP ksp
 * 
 * ctypedef public api class SNES(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscSNES_Type,
 *     object PyPetscSNESObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_SNES {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_SNES *__pyx_vtabptr_8petsc4py_5PETSc_SNES;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscTS_Type;

/* "petsc4py/PETSc.pxd":201
 *     cdef PetscSNES snes
 * 
 * ctypedef public api class TS(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscTS_Type,
 *     object PyPetscTSObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_TS {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_TS *__pyx_vtabptr_8petsc4py_5PETSc_TS;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscTAO_Type;

/* "petsc4py/PETSc.pxd":207
 *     cdef PetscTS ts
 * 
 * ctypedef public api class TAO(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscTAO_Type,
 *     object PyPetscTAOObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_TAO {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_TAO *__pyx_vtabptr_8petsc4py_5PETSc_TAO;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscAO_Type;

/* "petsc4py/PETSc.pxd":213
 *     cdef PetscTAO tao
 * 
 * ctypedef public api class AO(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscAO_Type,
 *     object PyPetscAOObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_AO {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_AO *__pyx_vtabptr_8petsc4py_5PETSc_AO;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscDM_Type;

/* "petsc4py/PETSc.pxd":219
 *     cdef PetscAO ao
 * 
 * ctypedef public api class DM(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscDM_Type,
 *     object PyPetscDMObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_DM {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_DM *__pyx_vtabptr_8petsc4py_5PETSc_DM;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscDS_Type;

/* "petsc4py/PETSc.pxd":225
 *     cdef PetscDM dm
 * 
 * ctypedef public api class DS(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscDS_Type,
 *     object PyPetscDSObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_DS {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_DS *__pyx_vtabptr_8petsc4py_5PETSc_DS;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscPartitioner_Type;

/* "petsc4py/PETSc.pxd":231
 *     cdef PetscDS ds
 * 
 * ctypedef public api class Partitioner(Object) [             # <<<<<<<<<<<<<<
 *     type PyPetscPartitioner_Type,
 *     object PyPetscPartitionerObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_Partitioner {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_Partitioner *__pyx_vtabptr_8petsc4py_5PETSc_Partitioner;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyPetscDMLabel_Type;

/* "petsc4py/PETSc.pxd":237
 *     cdef PetscPartitioner part
 * 
 * ctypedef public api class DMLabel(Object) [             # <<<<<<<<<<<<<<
 *     type   PyPetscDMLabel_Type,
 *     object PyPetscDMLabelObject,
 */

struct __pyx_vtabstruct_8petsc4py_5PETSc_DMLabel {
  struct __pyx_vtabstruct_8petsc4py_5PETSc_Object __pyx_base;
};
static struct __pyx_vtabstruct_8petsc4py_5PETSc_DMLabel *__pyx_vtabptr_8petsc4py_5PETSc_DMLabel;


/* "libpetsc4py.pyx":296
 * 
 * @cython.internal
 * cdef class _PyObj:             # <<<<<<<<<<<<<<
 * 
 *     cdef object self
 */

struct __pyx_vtabstruct_11libpetsc4py__PyObj {
  int (*setcontext)(struct __pyx_obj_11libpetsc4py__PyObj *, void *, struct PyPetscObjectObject *);
  int (*getcontext)(struct __pyx_obj_11libpetsc4py__PyObj *, void **);
  int (*setname)(struct __pyx_obj_11libpetsc4py__PyObj *, char *);
  char *(*getname)(struct __pyx_obj_11libpetsc4py__PyObj *);
};
static struct __pyx_vtabstruct_11libpetsc4py__PyObj *__pyx_vtabptr_11libpetsc4py__PyObj;


/* "libpetsc4py.pyx":527
 * 
 * @cython.internal
 * cdef class _PyMat(_PyObj): pass             # <<<<<<<<<<<<<<
 * cdef inline _PyMat PyMat(PetscMat mat):
 *     if mat != NULL and mat.data != NULL:
 */

struct __pyx_vtabstruct_11libpetsc4py__PyMat {
  struct __pyx_vtabstruct_11libpetsc4py__PyObj __pyx_base;
};
static struct __pyx_vtabstruct_11libpetsc4py__PyMat *__pyx_vtabptr_11libpetsc4py__PyMat;


/* "libpetsc4py.pyx":1201
 * 
 * @cython.internal
 * cdef class _PyPC(_PyObj): pass             # <<<<<<<<<<<<<<
 * cdef inline _PyPC PyPC(PetscPC pc):
 *     if pc != NULL and pc.data != NULL:
 */

struct __pyx_vtabstruct_11libpetsc4py__PyPC {
  struct __pyx_vtabstruct_11libpetsc4py__PyObj __pyx_base;
};
static struct __pyx_vtabstruct_11libpetsc4py__PyPC *__pyx_vtabptr_11libpetsc4py__PyPC;


/* "libpetsc4py.pyx":1477
 * 
 * @cython.internal
 * cdef class _PyKSP(_PyObj): pass             # <<<<<<<<<<<<<<
 * cdef inline _PyKSP PyKSP(PetscKSP ksp):
 *     if ksp != NULL and ksp.data != NULL:
 */

struct __pyx_vtabstruct_11libpetsc4py__PyKSP {
  struct __pyx_vtabstruct_11libpetsc4py__PyObj __pyx_base;
};
static struct __pyx_vtabstruct_11libpetsc4py__PyKSP *__pyx_vtabptr_11libpetsc4py__PyKSP;


/* "libpetsc4py.pyx":1839
 * 
 * @cython.internal
 * cdef class _PySNES(_PyObj): pass             # <<<<<<<<<<<<<<
 * cdef inline _PySNES PySNES(PetscSNES snes):
 *     if snes != NULL and snes.data != NULL:
 */

struct __pyx_vtabstruct_11libpetsc4py__PySNES {
  struct __pyx_vtabstruct_11libpetsc4py__PyObj __pyx_base;
};
static struct __pyx_vtabstruct_11libpetsc4py__PySNES *__pyx_vtabptr_11libpetsc4py__PySNES;


/* "libpetsc4py.pyx":2185
 * 
 * @cython.internal
 * cdef class _PyTS(_PyObj): pass             # <<<<<<<<<<<<<<
 * cdef inline _PyTS PyTS(PetscTS ts):
 *     if ts != NULL and ts.data != NULL:
 */

struct __pyx_vtabstruct_11libpetsc4py__PyTS {
  struct __pyx_vtabstruct_11libpetsc4py__PyObj __pyx_base;
};
static struct __pyx_vtabstruct_11libpetsc4py__PyTS *__pyx_vtabptr_11libpetsc4py__PyTS;

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

/* 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

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* tp_new.proto */
#define __Pyx_tp_new(type_obj, args) __Pyx_tp_new_kwargs(type_obj, args, NULL)
static CYTHON_INLINE PyObject* __Pyx_tp_new_kwargs(PyObject* type_obj, PyObject* args, PyObject* kwargs) {
    return (PyObject*) (((PyTypeObject*)type_obj)->tp_new((PyTypeObject*)type_obj, args, kwargs));
}

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

/* decode_c_string_utf16.proto */
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 0;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = -1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}

/* decode_c_bytes.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
         const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));

/* decode_bytes.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
         PyObject* string, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    return __Pyx_decode_c_bytes(
        PyBytes_AS_STRING(string), PyBytes_GET_SIZE(string),
        start, stop, encoding, errors, decode_func);
}

/* 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

/* 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

/* 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

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

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* 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

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

/* 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

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* 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

/* PyExec.proto */
static PyObject* __Pyx_PyExec3(PyObject*, PyObject*, PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyExec2(PyObject*, PyObject*);

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

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

/* 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));
}

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

/* 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

/* 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

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

/* GetVTable.proto */
static void* __Pyx_GetVtable(PyObject *dict);

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

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

/* RegisterModuleCleanup.proto */
static void __pyx_module_cleanup(PyObject *self);
#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static int __Pyx_RegisterCleanup(void);
#else
#define __Pyx_RegisterCleanup() (0)
#endif

/* 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

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

/* None.proto */
static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void); /* proto */

/* GCCDiagnostics.proto */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define __Pyx_HAS_GCC_DIAGNOSTIC
#endif

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_PetscInt(PetscInt value);

/* CIntFromPy.proto */
static CYTHON_INLINE PetscInt __Pyx_PyInt_As_PetscInt(PyObject *);

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

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

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_MatSORType(MatSORType value);

/* CIntFromPy.proto */
static CYTHON_INLINE PetscBool __Pyx_PyInt_As_PetscBool(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_NormType(NormType value);

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

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(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);

/* FunctionImport.proto */
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);

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

static int __pyx_f_11libpetsc4py_6_PyObj_setcontext(struct __pyx_obj_11libpetsc4py__PyObj *__pyx_v_self, void *__pyx_v_ctx, struct PyPetscObjectObject *__pyx_v_base); /* proto*/
static int __pyx_f_11libpetsc4py_6_PyObj_getcontext(struct __pyx_obj_11libpetsc4py__PyObj *__pyx_v_self, void **__pyx_v_ctx); /* proto*/
static int __pyx_f_11libpetsc4py_6_PyObj_setname(struct __pyx_obj_11libpetsc4py__PyObj *__pyx_v_self, char *__pyx_v_name); /* proto*/
static char *__pyx_f_11libpetsc4py_6_PyObj_getname(struct __pyx_obj_11libpetsc4py__PyObj *__pyx_v_self); /* proto*/

/* Module declarations from 'cython' */

/* Module declarations from 'petsc4py.PETSc' */
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_Comm = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_Object = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_Viewer = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_Random = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_IS = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_LGMap = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_SF = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_Vec = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_FE = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_Quad = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_Scatter = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_Section = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_Mat = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_NullSpace = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_PC = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_KSP = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_SNES = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_TS = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_TAO = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_AO = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_DM = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_DS = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_Partitioner = 0;
static PyTypeObject *__pyx_ptype_8petsc4py_5PETSc_DMLabel = 0;
static PyTypeObject *(*__pyx_f_8petsc4py_5PETSc_PyPetscType_Lookup)(int); /*proto*/

/* Module declarations from 'numpy' */

/* Module declarations from 'libpetsc4py' */
static PyTypeObject *__pyx_ptype_11libpetsc4py_dtype = 0;
static PyTypeObject *__pyx_ptype_11libpetsc4py_ndarray = 0;
static PyTypeObject *__pyx_ptype_11libpetsc4py__PyObj = 0;
static PyTypeObject *__pyx_ptype_11libpetsc4py__PyMat = 0;
static PyTypeObject *__pyx_ptype_11libpetsc4py__PyPC = 0;
static PyTypeObject *__pyx_ptype_11libpetsc4py__PyKSP = 0;
static PyTypeObject *__pyx_ptype_11libpetsc4py__PySNES = 0;
static PyTypeObject *__pyx_ptype_11libpetsc4py__PyTS = 0;
static char *__pyx_v_11libpetsc4py_FUNCT;
static char *__pyx_v_11libpetsc4py_fstack[0x400];
static int __pyx_v_11libpetsc4py_istack;
static PyObject *__pyx_v_11libpetsc4py_PetscError = 0;
static PyObject *__pyx_v_11libpetsc4py_module_cache = 0;
__PYX_EXTERN_C int import_libpetsc4py(void); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_11libpetsc4py_toInt(PetscInt); /*proto*/
static CYTHON_INLINE PetscInt __pyx_f_11libpetsc4py_asInt(PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_11libpetsc4py_toReal(PetscReal); /*proto*/
static CYTHON_INLINE PetscReal __pyx_f_11libpetsc4py_asReal(PyObject *); /*proto*/
static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_array_i(PetscInt, PetscInt const *); /*proto*/
static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_iarray(PyObject *, int); /*proto*/
static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_oarray(PyObject *, int); /*proto*/
static CYTHON_INLINE void __pyx_f_11libpetsc4py_FunctionBegin(char *); /*proto*/
static CYTHON_INLINE PetscErrorCode __pyx_f_11libpetsc4py_FunctionEnd(void); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PetscSETERR(PetscErrorCode, char *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PetscCHKERR(PetscErrorCode); /*proto*/
static CYTHON_INLINE void __pyx_f_11libpetsc4py_PythonSETERR(PetscErrorCode); /*proto*/
static CYTHON_INLINE int __pyx_f_11libpetsc4py_CHKERR(PetscErrorCode); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_UNSUPPORTED(char *); /*proto*/
static CYTHON_INLINE PetscInt __pyx_f_11libpetsc4py_getRef(void *); /*proto*/
static CYTHON_INLINE void __pyx_f_11libpetsc4py_addRef(void *); /*proto*/
static CYTHON_INLINE void __pyx_f_11libpetsc4py_delRef(void *); /*proto*/
static CYTHON_INLINE PetscObject __pyx_f_11libpetsc4py_newRef(void *); /*proto*/
static CYTHON_INLINE char *__pyx_f_11libpetsc4py_getPrefix(void *); /*proto*/
static CYTHON_INLINE int __pyx_f_11libpetsc4py_getCommSize(void *); /*proto*/
static CYTHON_INLINE struct PyPetscViewerObject *__pyx_f_11libpetsc4py_Viewer_(PetscViewer); /*proto*/
static CYTHON_INLINE struct PyPetscISObject *__pyx_f_11libpetsc4py_IS_(IS); /*proto*/
static CYTHON_INLINE struct PyPetscVecObject *__pyx_f_11libpetsc4py_Vec_(Vec); /*proto*/
static CYTHON_INLINE struct PyPetscMatObject *__pyx_f_11libpetsc4py_Mat_(Mat); /*proto*/
static CYTHON_INLINE struct PyPetscPCObject *__pyx_f_11libpetsc4py_PC_(PC); /*proto*/
static CYTHON_INLINE struct PyPetscKSPObject *__pyx_f_11libpetsc4py_KSP_(KSP); /*proto*/
static CYTHON_INLINE struct PyPetscSNESObject *__pyx_f_11libpetsc4py_SNES_(SNES); /*proto*/
static CYTHON_INLINE struct PyPetscTSObject *__pyx_f_11libpetsc4py_TS_(TS); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_11libpetsc4py_bytes2str(char const *); /*proto*/
static PyObject *__pyx_f_11libpetsc4py_parse_url(PyObject *); /*proto*/
static PyObject *__pyx_f_11libpetsc4py_load_module(PyObject *); /*proto*/
static PyObject *__pyx_f_11libpetsc4py_createcontext(char *); /*proto*/
static int __pyx_f_11libpetsc4py_viewcontext(struct __pyx_obj_11libpetsc4py__PyObj *, PetscViewer); /*proto*/
static CYTHON_INLINE struct __pyx_obj_11libpetsc4py__PyMat *__pyx_f_11libpetsc4py_PyMat(Mat); /*proto*/
__PYX_EXTERN_C PetscErrorCode MatPythonGetContext(Mat, void **); /*proto*/
__PYX_EXTERN_C PetscErrorCode MatPythonSetContext(Mat, void *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatPythonSetType_PYTHON(Mat, char *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatCreate_Python(Mat); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatDestroy_Python(Mat); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatSetFromOptions_Python(PetscOptionItems *, Mat); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatView_Python(Mat, PetscViewer); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatDuplicate_Python(Mat, MatDuplicateOption, Mat *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatCopy_Python(Mat, Mat, MatStructure); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatGetDiagonalBlock_Python(Mat, Mat *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatCreateSubMatrix_Python(Mat, IS, IS, MatReuse, Mat *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatSetOption_Python(Mat, MatOption, PetscBool); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatSetUp_Python(Mat); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatAssemblyBegin_Python(Mat, MatAssemblyType); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatAssemblyEnd_Python(Mat, MatAssemblyType); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatZeroEntries_Python(Mat); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatZeroRowsColumns_Python(Mat, PetscInt, PetscInt const *, PetscScalar, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatScale_Python(Mat, PetscScalar); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatShift_Python(Mat, PetscScalar); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatCreateVecs_Python(Mat, Vec *, Vec *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatMult_Python(Mat, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatMultTranspose_Python(Mat, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatMultHermitian_Python(Mat, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatMultAdd_Python(Mat, Vec, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatMultTransposeAdd_Python(Mat, Vec, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatMultHermitianAdd_Python(Mat, Vec, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatMultDiagonalBlock_Python(Mat, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatSolve_Python(Mat, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatSolveTranspose_Python(Mat, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatSolveAdd_Python(Mat, Vec, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatSolveTransposeAdd_Python(Mat, Vec, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatSOR_Python(Mat, Vec, PetscReal, MatSORType, PetscReal, PetscInt, PetscInt, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatGetDiagonal_Python(Mat, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatSetDiagonal_Python(Mat, Vec, InsertMode); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatDiagonalScale_Python(Mat, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatMissingDiagonal_Python(Mat, PetscBool *, PetscInt *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatNorm_Python(Mat, NormType, PetscReal *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatRealPart_Python(Mat); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatImagPart_Python(Mat); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_MatConjugate_Python(Mat); /*proto*/
static CYTHON_INLINE struct __pyx_obj_11libpetsc4py__PyPC *__pyx_f_11libpetsc4py_PyPC(PC); /*proto*/
__PYX_EXTERN_C PetscErrorCode PCPythonGetContext(PC, void **); /*proto*/
__PYX_EXTERN_C PetscErrorCode PCPythonSetContext(PC, void *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCPythonSetType_PYTHON(PC, char *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCCreate_Python(PC); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCDestroy_Python(PC); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCSetUp_Python(PC); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCReset_Python(PC); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCSetFromOptions_Python(PetscOptionItems *, PC); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCView_Python(PC, PetscViewer); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCPreSolve_Python(PC, KSP, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCPostSolve_Python(PC, KSP, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCApply_Python(PC, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCApplyTranspose_Python(PC, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCApplySymmetricLeft_Python(PC, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PCApplySymmetricRight_Python(PC, Vec, Vec); /*proto*/
static CYTHON_INLINE struct __pyx_obj_11libpetsc4py__PyKSP *__pyx_f_11libpetsc4py_PyKSP(KSP); /*proto*/
__PYX_EXTERN_C PetscErrorCode KSPPythonGetContext(KSP, void **); /*proto*/
__PYX_EXTERN_C PetscErrorCode KSPPythonSetContext(KSP, void *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPPythonSetType_PYTHON(KSP, char *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPCreate_Python(KSP); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPDestroy_Python(KSP); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPSetUp_Python(KSP); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPReset_Python(KSP); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPSetFromOptions_Python(PetscOptionItems *, KSP); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPView_Python(KSP, PetscViewer); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPBuildSolution_Python(KSP, Vec, Vec *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPBuildResidual_Python(KSP, Vec, Vec, Vec *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPSolve_Python(KSP); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPSolve_Python_default(KSP, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPPreStep_Python(KSP); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPPostStep_Python(KSP); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_KSPStep_Python(KSP, Vec, Vec); /*proto*/
static CYTHON_INLINE struct __pyx_obj_11libpetsc4py__PySNES *__pyx_f_11libpetsc4py_PySNES(SNES); /*proto*/
__PYX_EXTERN_C PetscErrorCode SNESPythonGetContext(SNES, void **); /*proto*/
__PYX_EXTERN_C PetscErrorCode SNESPythonSetContext(SNES, void *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESPythonSetType_PYTHON(SNES, char *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESCreate_Python(SNES); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESDestroy_Python(SNES); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESSetUp_Python(SNES); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESReset_Python(SNES); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESSetFromOptions_Python(PetscOptionItems *, SNES); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESView_Python(SNES, PetscViewer); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESSolve_Python(SNES); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESSolve_Python_default(SNES); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESPreStep_Python(SNES); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESPostStep_Python(SNES); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESStep_Python(SNES, Vec, Vec, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESStep_Python_default(SNES, Vec, Vec, Vec); /*proto*/
static CYTHON_INLINE struct __pyx_obj_11libpetsc4py__PyTS *__pyx_f_11libpetsc4py_PyTS(TS); /*proto*/
__PYX_EXTERN_C PetscErrorCode TSPythonGetContext(TS, void **); /*proto*/
__PYX_EXTERN_C PetscErrorCode TSPythonSetContext(TS, void *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSPythonSetType_PYTHON(TS, char *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSCreate_Python(TS); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSDestroy_Python(TS); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSSetUp_Python(TS); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSReset_Python(TS); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSSetFromOptions_Python(PetscOptionItems *, TS); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSView_Python(TS, PetscViewer); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSStep_Python(TS); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSRollBack_Python(TS); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSInterpolate_Python(TS, PetscReal, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSEvaluateStep_Python(TS, PetscInt, Vec, PetscBool *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESTSFormFunction_Python(SNES, Vec, Vec, TS); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_SNESTSFormJacobian_Python(SNES, Vec, Mat, Mat, TS); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSSolveStep_Python(TS, PetscReal, Vec); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSAdaptStep_Python(TS, PetscReal, Vec, PetscReal *, PetscBool *); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_TSStep_Python_default(TS); /*proto*/
static PetscErrorCode __pyx_f_11libpetsc4py_PetscPythonMonitorSet_Python(PetscObject, char const *); /*proto*/
__PYX_EXTERN_C PetscErrorCode PetscPythonRegisterAll(void); /*proto*/
#define __Pyx_MODULE_NAME "libpetsc4py"
extern int __pyx_module_is_main_libpetsc4py;
int __pyx_module_is_main_libpetsc4py = 0;

/* Implementation of 'libpetsc4py' */
static PyObject *__pyx_builtin_open;
static PyObject *__pyx_builtin_compile;
static const char __pyx_k_[] = ":";
static const char __pyx_k__3[] = ".";
static const char __pyx_k__5[] = ",";
static const char __pyx_k_rU[] = "rU";
static const char __pyx_k_SOR[] = "SOR";
static const char __pyx_k_copy[] = "copy";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_exec[] = "exec";
static const char __pyx_k_file[] = "__file__";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mult[] = "mult";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_norm[] = "norm";
static const char __pyx_k_open[] = "open";
static const char __pyx_k_read[] = "read";
static const char __pyx_k_step[] = "step";
static const char __pyx_k_view[] = "view";
static const char __pyx_k_Error[] = "Error";
static const char __pyx_k_apply[] = "apply";
static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_close[] = "close";
static const char __pyx_k_reset[] = "reset";
static const char __pyx_k_scale[] = "scale";
static const char __pyx_k_setUp[] = "setUp";
static const char __pyx_k_shift[] = "shift";
static const char __pyx_k_solve[] = "solve";
static const char __pyx_k_split[] = "split";
static const char __pyx_k_create[] = "create";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_module[] = "__module__";
static const char __pyx_k_rsplit[] = "rsplit";
static const char __pyx_k_compile[] = "compile";
static const char __pyx_k_destroy[] = "destroy";
static const char __pyx_k_monitor[] = "monitor";
static const char __pyx_k_multAdd[] = "multAdd";
static const char __pyx_k_package[] = "__package__";
static const char __pyx_k_preStep[] = "preStep";
static const char __pyx_k_assembly[] = "assembly";
static const char __pyx_k_builtins[] = "__builtins__";
static const char __pyx_k_imagPart[] = "imagPart";
static const char __pyx_k_postStep[] = "postStep";
static const char __pyx_k_preSolve[] = "preSolve";
static const char __pyx_k_realPart[] = "realPart";
static const char __pyx_k_rollback[] = "rollback";
static const char __pyx_k_solveAdd[] = "solveAdd";
static const char __pyx_k_adaptStep[] = "adaptStep";
static const char __pyx_k_conjugate[] = "conjugate";
static const char __pyx_k_duplicate[] = "duplicate";
static const char __pyx_k_postSolve[] = "postSolve";
static const char __pyx_k_setOption[] = "setOption";
static const char __pyx_k_solveStep[] = "solveStep";
static const char __pyx_k_createVecs[] = "createVecs";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_setMonitor[] = "setMonitor";
static const char __pyx_k_assemblyEnd[] = "assemblyEnd";
static const char __pyx_k_getDiagonal[] = "getDiagonal";
static const char __pyx_k_interpolate[] = "interpolate";
static const char __pyx_k_setDiagonal[] = "setDiagonal";
static const char __pyx_k_zeroEntries[] = "zeroEntries";
static const char __pyx_k_evaluatestep[] = "evaluatestep";
static const char __pyx_k_assemblyBegin[] = "assemblyBegin";
static const char __pyx_k_buildResidual[] = "buildResidual";
static const char __pyx_k_buildSolution[] = "buildSolution";
static const char __pyx_k_diagonalScale[] = "diagonalScale";
static const char __pyx_k_multHermitian[] = "multHermitian";
static const char __pyx_k_multTranspose[] = "multTranspose";
static const char __pyx_k_stepTranspose[] = "stepTranspose";
static const char __pyx_k_applyTranspose[] = "applyTranspose";
static const char __pyx_k_petsc4py_PETSc[] = "petsc4py.PETSc";
static const char __pyx_k_setFromOptions[] = "setFromOptions";
static const char __pyx_k_solveTranspose[] = "solveTranspose";
static const char __pyx_k_createSubMatrix[] = "createSubMatrix";
static const char __pyx_k_missingDiagonal[] = "missingDiagonal";
static const char __pyx_k_zeroRowsColumns[] = "zeroRowsColumns";
static const char __pyx_k_formSNESFunction[] = "formSNESFunction";
static const char __pyx_k_formSNESJacobian[] = "formSNESJacobian";
static const char __pyx_k_getDiagonalBlock[] = "getDiagonalBlock";
static const char __pyx_k_multHermitianAdd[] = "multHermitianAdd";
static const char __pyx_k_multTransposeAdd[] = "multTransposeAdd";
static const char __pyx_k_multDiagonalBlock[] = "multDiagonalBlock";
static const char __pyx_k_solveTransposeAdd[] = "solveTransposeAdd";
static const char __pyx_k_applySymmetricLeft[] = "applySymmetricLeft";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_applySymmetricRight[] = "applySymmetricRight";
static PyObject *__pyx_kp_s_;
static PyObject *__pyx_n_s_Error;
static PyObject *__pyx_n_s_SOR;
static PyObject *__pyx_kp_s__3;
static PyObject *__pyx_kp_s__5;
static PyObject *__pyx_n_s_adaptStep;
static PyObject *__pyx_n_s_apply;
static PyObject *__pyx_n_s_applySymmetricLeft;
static PyObject *__pyx_n_s_applySymmetricRight;
static PyObject *__pyx_n_s_applyTranspose;
static PyObject *__pyx_n_s_assembly;
static PyObject *__pyx_n_s_assemblyBegin;
static PyObject *__pyx_n_s_assemblyEnd;
static PyObject *__pyx_n_s_buildResidual;
static PyObject *__pyx_n_s_buildSolution;
static PyObject *__pyx_n_s_builtins;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_compile;
static PyObject *__pyx_n_s_conjugate;
static PyObject *__pyx_n_s_copy;
static PyObject *__pyx_n_s_create;
static PyObject *__pyx_n_s_createSubMatrix;
static PyObject *__pyx_n_s_createVecs;
static PyObject *__pyx_n_s_destroy;
static PyObject *__pyx_n_s_diagonalScale;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_duplicate;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_evaluatestep;
static PyObject *__pyx_n_s_exec;
static PyObject *__pyx_n_s_file;
static PyObject *__pyx_n_s_formSNESFunction;
static PyObject *__pyx_n_s_formSNESJacobian;
static PyObject *__pyx_n_s_getDiagonal;
static PyObject *__pyx_n_s_getDiagonalBlock;
static PyObject *__pyx_n_s_imagPart;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_interpolate;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_missingDiagonal;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_n_s_monitor;
static PyObject *__pyx_n_s_mult;
static PyObject *__pyx_n_s_multAdd;
static PyObject *__pyx_n_s_multDiagonalBlock;
static PyObject *__pyx_n_s_multHermitian;
static PyObject *__pyx_n_s_multHermitianAdd;
static PyObject *__pyx_n_s_multTranspose;
static PyObject *__pyx_n_s_multTransposeAdd;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_norm;
static PyObject *__pyx_n_s_open;
static PyObject *__pyx_n_s_package;
static PyObject *__pyx_n_s_petsc4py_PETSc;
static PyObject *__pyx_n_s_postSolve;
static PyObject *__pyx_n_s_postStep;
static PyObject *__pyx_n_s_preSolve;
static PyObject *__pyx_n_s_preStep;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_rU;
static PyObject *__pyx_n_s_read;
static PyObject *__pyx_n_s_realPart;
static PyObject *__pyx_n_s_reset;
static PyObject *__pyx_n_s_rollback;
static PyObject *__pyx_n_s_rsplit;
static PyObject *__pyx_n_s_scale;
static PyObject *__pyx_n_s_setDiagonal;
static PyObject *__pyx_n_s_setFromOptions;
static PyObject *__pyx_n_s_setMonitor;
static PyObject *__pyx_n_s_setOption;
static PyObject *__pyx_n_s_setUp;
static PyObject *__pyx_n_s_shift;
static PyObject *__pyx_n_s_solve;
static PyObject *__pyx_n_s_solveAdd;
static PyObject *__pyx_n_s_solveStep;
static PyObject *__pyx_n_s_solveTranspose;
static PyObject *__pyx_n_s_solveTransposeAdd;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_n_s_step;
static PyObject *__pyx_n_s_stepTranspose;
static PyObject *__pyx_n_s_view;
static PyObject *__pyx_n_s_zeroEntries;
static PyObject *__pyx_n_s_zeroRowsColumns;
static PyObject *__pyx_pf_11libpetsc4py_6_PyObj___getattr__(struct __pyx_obj_11libpetsc4py__PyObj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
static PyObject *__pyx_tp_new_11libpetsc4py__PyObj(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11libpetsc4py__PyMat(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11libpetsc4py__PyPC(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11libpetsc4py__PyKSP(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11libpetsc4py__PySNES(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11libpetsc4py__PyTS(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_int_1;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__4;
/* Late includes */

/* "libpetsc4py.pyx":30
 *     void initlibpetsc4py() nogil except *
 * 
 * cdef public int import_libpetsc4py() nogil except -1:             # <<<<<<<<<<<<<<
 *     initlibpetsc4py()
 *     return 0
 */

int import_libpetsc4py(void) {
  int __pyx_r;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "libpetsc4py.pyx":31
 * 
 * cdef public int import_libpetsc4py() nogil except -1:
 *     initlibpetsc4py()             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  initlibpetsc4py(); if (unlikely(__Pyx_ErrOccurredWithGIL())) __PYX_ERR(0, 31, __pyx_L1_error)

  /* "libpetsc4py.pyx":32
 * cdef public int import_libpetsc4py() nogil except -1:
 *     initlibpetsc4py()
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":30
 *     void initlibpetsc4py() nogil except *
 * 
 * cdef public int import_libpetsc4py() nogil except -1:             # <<<<<<<<<<<<<<
 *     initlibpetsc4py()
 *     return 0
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("libpetsc4py.import_libpetsc4py", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "libpetsc4py.pyx":84
 *     PetscErrorCode PetscViewerStringSPrintf(PetscViewer,char[],...)
 * 
 * cdef inline object      toInt(PetscInt value):          return value             # <<<<<<<<<<<<<<
 * cdef inline PetscInt    asInt(object value)  except?-1: return value
 * cdef inline object      toReal(PetscReal value):        return value
 */

static CYTHON_INLINE PyObject *__pyx_f_11libpetsc4py_toInt(PetscInt __pyx_v_value) {
  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("toInt", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_PetscInt(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __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("libpetsc4py.toInt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":85
 * 
 * cdef inline object      toInt(PetscInt value):          return value
 * cdef inline PetscInt    asInt(object value)  except?-1: return value             # <<<<<<<<<<<<<<
 * cdef inline object      toReal(PetscReal value):        return value
 * cdef inline PetscReal   asReal(object value) except?-1: return value
 */

static CYTHON_INLINE PetscInt __pyx_f_11libpetsc4py_asInt(PyObject *__pyx_v_value) {
  PetscInt __pyx_r;
  __Pyx_RefNannyDeclarations
  PetscInt __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("asInt", 0);
  __pyx_t_1 = __Pyx_PyInt_As_PetscInt(__pyx_v_value); if (unlikely((__pyx_t_1 == ((PetscInt)-1)) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error)
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.asInt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1L;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":86
 * cdef inline object      toInt(PetscInt value):          return value
 * cdef inline PetscInt    asInt(object value)  except?-1: return value
 * cdef inline object      toReal(PetscReal value):        return value             # <<<<<<<<<<<<<<
 * cdef inline PetscReal   asReal(object value) except?-1: return value
 * cdef extern from "scalar.h":
 */

static CYTHON_INLINE PyObject *__pyx_f_11libpetsc4py_toReal(PetscReal __pyx_v_value) {
  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("toReal", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __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("libpetsc4py.toReal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":87
 * cdef inline PetscInt    asInt(object value)  except?-1: return value
 * cdef inline object      toReal(PetscReal value):        return value
 * cdef inline PetscReal   asReal(object value) except?-1: return value             # <<<<<<<<<<<<<<
 * cdef extern from "scalar.h":
 *     object      toScalar"PyPetscScalar_FromPetscScalar"(PetscScalar)
 */

static CYTHON_INLINE PetscReal __pyx_f_11libpetsc4py_asReal(PyObject *__pyx_v_value) {
  PetscReal __pyx_r;
  __Pyx_RefNannyDeclarations
  PetscReal __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("asReal", 0);
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == ((PetscReal)-1)) && PyErr_Occurred())) __PYX_ERR(0, 87, __pyx_L1_error)
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.asReal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1.0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":68
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray asarray(object ob):             # <<<<<<<<<<<<<<
 *     return PyArray_FROM_O(ob)
 * 
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_asarray(PyObject *__pyx_v_ob) {
  PyArrayObject *__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("asarray", 0);

  /* "include/arraynpy.pxi":69
 * 
 * cdef inline ndarray asarray(object ob):
 *     return PyArray_FROM_O(ob)             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray arange(start, stop, stride):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)PyArray_FROM_O(__pyx_v_ob)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":68
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray asarray(object ob):             # <<<<<<<<<<<<<<
 *     return PyArray_FROM_O(ob)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.asarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":71
 *     return PyArray_FROM_O(ob)
 * 
 * cdef inline ndarray arange(start, stop, stride):             # <<<<<<<<<<<<<<
 *     cdef dtype descr = <dtype> PyArray_DescrFromType(NPY_PETSC_INT)
 *     return PyArray_ArangeObj(start, stop, stride, descr)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_arange(PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_stride) {
  PyArray_Descr *__pyx_v_descr = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("arange", 0);

  /* "include/arraynpy.pxi":72
 * 
 * cdef inline ndarray arange(start, stop, stride):
 *     cdef dtype descr = <dtype> PyArray_DescrFromType(NPY_PETSC_INT)             # <<<<<<<<<<<<<<
 *     return PyArray_ArangeObj(start, stop, stride, descr)
 * 
 */
  __pyx_t_1 = ((PyObject *)PyArray_DescrFromType(NPY_PETSC_INT)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_t_1;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_descr = ((PyArray_Descr *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "include/arraynpy.pxi":73
 * cdef inline ndarray arange(start, stop, stride):
 *     cdef dtype descr = <dtype> PyArray_DescrFromType(NPY_PETSC_INT)
 *     return PyArray_ArangeObj(start, stop, stride, descr)             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = ((PyObject *)PyArray_ArangeObj(__pyx_v_start, __pyx_v_stop, __pyx_v_stride, __pyx_v_descr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":71
 *     return PyArray_FROM_O(ob)
 * 
 * cdef inline ndarray arange(start, stop, stride):             # <<<<<<<<<<<<<<
 *     cdef dtype descr = <dtype> PyArray_DescrFromType(NPY_PETSC_INT)
 *     return PyArray_ArangeObj(start, stop, stride, descr)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.arange", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_descr);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":77
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray empty_i(PetscInt size):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_empty_i(PetscInt __pyx_v_size) {
  npy_intp __pyx_v_s;
  PyArrayObject *__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("empty_i", 0);

  /* "include/arraynpy.pxi":78
 * 
 * cdef inline ndarray empty_i(PetscInt size):
 *     cdef npy_intp s = <npy_intp> size             # <<<<<<<<<<<<<<
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)
 * 
 */
  __pyx_v_s = ((npy_intp)__pyx_v_size);

  /* "include/arraynpy.pxi":79
 * cdef inline ndarray empty_i(PetscInt size):
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray empty_r(PetscInt size):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)PyArray_EMPTY(1, (&__pyx_v_s), NPY_PETSC_INT, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":77
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray empty_i(PetscInt size):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.empty_i", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":81
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)
 * 
 * cdef inline ndarray empty_r(PetscInt size):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_empty_r(PetscInt __pyx_v_size) {
  npy_intp __pyx_v_s;
  PyArrayObject *__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("empty_r", 0);

  /* "include/arraynpy.pxi":82
 * 
 * cdef inline ndarray empty_r(PetscInt size):
 *     cdef npy_intp s = <npy_intp> size             # <<<<<<<<<<<<<<
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)
 * 
 */
  __pyx_v_s = ((npy_intp)__pyx_v_size);

  /* "include/arraynpy.pxi":83
 * cdef inline ndarray empty_r(PetscInt size):
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray empty_s(PetscInt size):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)PyArray_EMPTY(1, (&__pyx_v_s), NPY_PETSC_REAL, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":81
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)
 * 
 * cdef inline ndarray empty_r(PetscInt size):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.empty_r", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":85
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)
 * 
 * cdef inline ndarray empty_s(PetscInt size):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_empty_s(PetscInt __pyx_v_size) {
  npy_intp __pyx_v_s;
  PyArrayObject *__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("empty_s", 0);

  /* "include/arraynpy.pxi":86
 * 
 * cdef inline ndarray empty_s(PetscInt size):
 *     cdef npy_intp s = <npy_intp> size             # <<<<<<<<<<<<<<
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)
 * 
 */
  __pyx_v_s = ((npy_intp)__pyx_v_size);

  /* "include/arraynpy.pxi":87
 * cdef inline ndarray empty_s(PetscInt size):
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray empty_c(PetscInt size):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)PyArray_EMPTY(1, (&__pyx_v_s), NPY_PETSC_SCALAR, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":85
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)
 * 
 * cdef inline ndarray empty_s(PetscInt size):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.empty_s", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":89
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)
 * 
 * cdef inline ndarray empty_c(PetscInt size):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_COMPLEX, 0)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_empty_c(PetscInt __pyx_v_size) {
  npy_intp __pyx_v_s;
  PyArrayObject *__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("empty_c", 0);

  /* "include/arraynpy.pxi":90
 * 
 * cdef inline ndarray empty_c(PetscInt size):
 *     cdef npy_intp s = <npy_intp> size             # <<<<<<<<<<<<<<
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_COMPLEX, 0)
 * 
 */
  __pyx_v_s = ((npy_intp)__pyx_v_size);

  /* "include/arraynpy.pxi":91
 * cdef inline ndarray empty_c(PetscInt size):
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_COMPLEX, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray empty_p(PetscInt size):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)PyArray_EMPTY(1, (&__pyx_v_s), NPY_PETSC_COMPLEX, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 91, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":89
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)
 * 
 * cdef inline ndarray empty_c(PetscInt size):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_COMPLEX, 0)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.empty_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":93
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_COMPLEX, 0)
 * 
 * cdef inline ndarray empty_p(PetscInt size):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_INTP, 0)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_empty_p(PetscInt __pyx_v_size) {
  npy_intp __pyx_v_s;
  PyArrayObject *__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("empty_p", 0);

  /* "include/arraynpy.pxi":94
 * 
 * cdef inline ndarray empty_p(PetscInt size):
 *     cdef npy_intp s = <npy_intp> size             # <<<<<<<<<<<<<<
 *     return PyArray_EMPTY(1, &s, NPY_INTP, 0)
 * 
 */
  __pyx_v_s = ((npy_intp)__pyx_v_size);

  /* "include/arraynpy.pxi":95
 * cdef inline ndarray empty_p(PetscInt size):
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_INTP, 0)             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)PyArray_EMPTY(1, (&__pyx_v_s), NPY_INTP, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 95, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":93
 *     return PyArray_EMPTY(1, &s, NPY_PETSC_COMPLEX, 0)
 * 
 * cdef inline ndarray empty_p(PetscInt size):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     return PyArray_EMPTY(1, &s, NPY_INTP, 0)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.empty_p", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":99
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray array_i(PetscInt size, const PetscInt* data):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_array_i(PetscInt __pyx_v_size, PetscInt const *__pyx_v_data) {
  npy_intp __pyx_v_s;
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("array_i", 0);

  /* "include/arraynpy.pxi":100
 * 
 * cdef inline ndarray array_i(PetscInt size, const PetscInt* data):
 *     cdef npy_intp s = <npy_intp> size             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)
 *     if data != NULL:
 */
  __pyx_v_s = ((npy_intp)__pyx_v_size);

  /* "include/arraynpy.pxi":101
 * cdef inline ndarray array_i(PetscInt size, const PetscInt* data):
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)             # <<<<<<<<<<<<<<
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscInt))
 */
  __pyx_t_1 = ((PyObject *)PyArray_EMPTY(1, (&__pyx_v_s), NPY_PETSC_INT, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":102
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)
 *     if data != NULL:             # <<<<<<<<<<<<<<
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscInt))
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {

    /* "include/arraynpy.pxi":103
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscInt))             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
    (void)(memcpy(PyArray_DATA(__pyx_v_ary), __pyx_v_data, (((size_t)__pyx_v_size) * (sizeof(PetscInt)))));

    /* "include/arraynpy.pxi":102
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)
 *     if data != NULL:             # <<<<<<<<<<<<<<
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscInt))
 *     return ary
 */
  }

  /* "include/arraynpy.pxi":104
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscInt))
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray array_r(PetscInt size, const PetscReal* data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":99
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray array_i(PetscInt size, const PetscInt* data):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_INT, 0)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.array_i", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":106
 *     return ary
 * 
 * cdef inline ndarray array_r(PetscInt size, const PetscReal* data):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_array_r(PetscInt __pyx_v_size, PetscReal const *__pyx_v_data) {
  npy_intp __pyx_v_s;
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("array_r", 0);

  /* "include/arraynpy.pxi":107
 * 
 * cdef inline ndarray array_r(PetscInt size, const PetscReal* data):
 *     cdef npy_intp s = <npy_intp> size             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)
 *     if data != NULL:
 */
  __pyx_v_s = ((npy_intp)__pyx_v_size);

  /* "include/arraynpy.pxi":108
 * cdef inline ndarray array_r(PetscInt size, const PetscReal* data):
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)             # <<<<<<<<<<<<<<
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscReal))
 */
  __pyx_t_1 = ((PyObject *)PyArray_EMPTY(1, (&__pyx_v_s), NPY_PETSC_REAL, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":109
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)
 *     if data != NULL:             # <<<<<<<<<<<<<<
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscReal))
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {

    /* "include/arraynpy.pxi":110
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscReal))             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
    (void)(memcpy(PyArray_DATA(__pyx_v_ary), __pyx_v_data, (((size_t)__pyx_v_size) * (sizeof(PetscReal)))));

    /* "include/arraynpy.pxi":109
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)
 *     if data != NULL:             # <<<<<<<<<<<<<<
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscReal))
 *     return ary
 */
  }

  /* "include/arraynpy.pxi":111
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscReal))
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray array_b(PetscInt size, const PetscBool* data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":106
 *     return ary
 * 
 * cdef inline ndarray array_r(PetscInt size, const PetscReal* data):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_REAL, 0)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.array_r", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":113
 *     return ary
 * 
 * cdef inline ndarray array_b(PetscInt size, const PetscBool* data):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_BOOL, 0)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_array_b(PetscInt __pyx_v_size, PetscBool const *__pyx_v_data) {
  npy_intp __pyx_v_s;
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("array_b", 0);

  /* "include/arraynpy.pxi":114
 * 
 * cdef inline ndarray array_b(PetscInt size, const PetscBool* data):
 *     cdef npy_intp s = <npy_intp> size             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_BOOL, 0)
 *     if data != NULL:
 */
  __pyx_v_s = ((npy_intp)__pyx_v_size);

  /* "include/arraynpy.pxi":115
 * cdef inline ndarray array_b(PetscInt size, const PetscBool* data):
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_BOOL, 0)             # <<<<<<<<<<<<<<
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscBool))
 */
  __pyx_t_1 = ((PyObject *)PyArray_EMPTY(1, (&__pyx_v_s), NPY_PETSC_BOOL, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":116
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_BOOL, 0)
 *     if data != NULL:             # <<<<<<<<<<<<<<
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscBool))
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {

    /* "include/arraynpy.pxi":117
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_BOOL, 0)
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscBool))             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
    (void)(memcpy(PyArray_DATA(__pyx_v_ary), __pyx_v_data, (((size_t)__pyx_v_size) * (sizeof(PetscBool)))));

    /* "include/arraynpy.pxi":116
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_BOOL, 0)
 *     if data != NULL:             # <<<<<<<<<<<<<<
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscBool))
 *     return ary
 */
  }

  /* "include/arraynpy.pxi":118
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscBool))
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray array_s(PetscInt size, const PetscScalar* data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":113
 *     return ary
 * 
 * cdef inline ndarray array_b(PetscInt size, const PetscBool* data):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_BOOL, 0)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.array_b", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":120
 *     return ary
 * 
 * cdef inline ndarray array_s(PetscInt size, const PetscScalar* data):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_array_s(PetscInt __pyx_v_size, PetscScalar const *__pyx_v_data) {
  npy_intp __pyx_v_s;
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("array_s", 0);

  /* "include/arraynpy.pxi":121
 * 
 * cdef inline ndarray array_s(PetscInt size, const PetscScalar* data):
 *     cdef npy_intp s = <npy_intp> size             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)
 *     if data != NULL:
 */
  __pyx_v_s = ((npy_intp)__pyx_v_size);

  /* "include/arraynpy.pxi":122
 * cdef inline ndarray array_s(PetscInt size, const PetscScalar* data):
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)             # <<<<<<<<<<<<<<
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscScalar))
 */
  __pyx_t_1 = ((PyObject *)PyArray_EMPTY(1, (&__pyx_v_s), NPY_PETSC_SCALAR, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 122, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":123
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)
 *     if data != NULL:             # <<<<<<<<<<<<<<
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscScalar))
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {

    /* "include/arraynpy.pxi":124
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscScalar))             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
    (void)(memcpy(PyArray_DATA(__pyx_v_ary), __pyx_v_data, (((size_t)__pyx_v_size) * (sizeof(PetscScalar)))));

    /* "include/arraynpy.pxi":123
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)
 *     if data != NULL:             # <<<<<<<<<<<<<<
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscScalar))
 *     return ary
 */
  }

  /* "include/arraynpy.pxi":125
 *     if data != NULL:
 *         memcpy(PyArray_DATA(ary), data, <size_t>size*sizeof(PetscScalar))
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":120
 *     return ary
 * 
 * cdef inline ndarray array_s(PetscInt size, const PetscScalar* data):             # <<<<<<<<<<<<<<
 *     cdef npy_intp s = <npy_intp> size
 *     cdef ndarray ary = PyArray_EMPTY(1, &s, NPY_PETSC_SCALAR, 0)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.array_s", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":129
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray iarray(object ob, int typenum):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, typenum, NPY_ARRAY_ALIGNED|NPY_ARRAY_NOTSWAPPED)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_iarray(PyObject *__pyx_v_ob, int __pyx_v_typenum) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iarray", 0);

  /* "include/arraynpy.pxi":130
 * 
 * cdef inline ndarray iarray(object ob, int typenum):
 *     cdef ndarray ary = PyArray_FROM_OTF(             # <<<<<<<<<<<<<<
 *         ob, typenum, NPY_ARRAY_ALIGNED|NPY_ARRAY_NOTSWAPPED)
 *     if PyArray_ISCONTIGUOUS(ary): return ary
 */
  __pyx_t_1 = ((PyObject *)PyArray_FROM_OTF(__pyx_v_ob, __pyx_v_typenum, (NPY_ARRAY_ALIGNED | NPY_ARRAY_NOTSWAPPED))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":132
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, typenum, NPY_ARRAY_ALIGNED|NPY_ARRAY_NOTSWAPPED)
 *     if PyArray_ISCONTIGUOUS(ary): return ary             # <<<<<<<<<<<<<<
 *     if PyArray_ISFORTRAN(ary):    return ary
 *     return PyArray_Copy(ary)
 */
  __pyx_t_2 = (PyArray_ISCONTIGUOUS(__pyx_v_ary) != 0);
  if (__pyx_t_2) {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ary));
    __pyx_r = __pyx_v_ary;
    goto __pyx_L0;
  }

  /* "include/arraynpy.pxi":133
 *         ob, typenum, NPY_ARRAY_ALIGNED|NPY_ARRAY_NOTSWAPPED)
 *     if PyArray_ISCONTIGUOUS(ary): return ary
 *     if PyArray_ISFORTRAN(ary):    return ary             # <<<<<<<<<<<<<<
 *     return PyArray_Copy(ary)
 * 
 */
  __pyx_t_2 = (PyArray_ISFORTRAN(__pyx_v_ary) != 0);
  if (__pyx_t_2) {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ary));
    __pyx_r = __pyx_v_ary;
    goto __pyx_L0;
  }

  /* "include/arraynpy.pxi":134
 *     if PyArray_ISCONTIGUOUS(ary): return ary
 *     if PyArray_ISFORTRAN(ary):    return ary
 *     return PyArray_Copy(ary)             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray iarray_i(object ob, PetscInt* size, PetscInt** data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)PyArray_Copy(__pyx_v_ary)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":129
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray iarray(object ob, int typenum):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, typenum, NPY_ARRAY_ALIGNED|NPY_ARRAY_NOTSWAPPED)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.iarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":136
 *     return PyArray_Copy(ary)
 * 
 * cdef inline ndarray iarray_i(object ob, PetscInt* size, PetscInt** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_INT)
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_iarray_i(PyObject *__pyx_v_ob, PetscInt *__pyx_v_size, PetscInt **__pyx_v_data) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iarray_i", 0);

  /* "include/arraynpy.pxi":137
 * 
 * cdef inline ndarray iarray_i(object ob, PetscInt* size, PetscInt** data):
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_INT)             # <<<<<<<<<<<<<<
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscInt*> PyArray_DATA(ary)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_iarray(__pyx_v_ob, NPY_PETSC_INT)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":138
 * cdef inline ndarray iarray_i(object ob, PetscInt* size, PetscInt** data):
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_INT)
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)             # <<<<<<<<<<<<<<
 *     if data != NULL: data[0] = <PetscInt*> PyArray_DATA(ary)
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_size != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_size[0]) = ((PetscInt)PyArray_SIZE(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":139
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_INT)
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscInt*> PyArray_DATA(ary)             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_data[0]) = ((PetscInt *)PyArray_DATA(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":140
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscInt*> PyArray_DATA(ary)
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray iarray_r(object ob, PetscInt* size, PetscReal** data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":136
 *     return PyArray_Copy(ary)
 * 
 * cdef inline ndarray iarray_i(object ob, PetscInt* size, PetscInt** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_INT)
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.iarray_i", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":142
 *     return ary
 * 
 * cdef inline ndarray iarray_r(object ob, PetscInt* size, PetscReal** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_REAL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_iarray_r(PyObject *__pyx_v_ob, PetscInt *__pyx_v_size, PetscReal **__pyx_v_data) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iarray_r", 0);

  /* "include/arraynpy.pxi":143
 * 
 * cdef inline ndarray iarray_r(object ob, PetscInt* size, PetscReal** data):
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_REAL)             # <<<<<<<<<<<<<<
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscReal*> PyArray_DATA(ary)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_iarray(__pyx_v_ob, NPY_PETSC_REAL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":144
 * cdef inline ndarray iarray_r(object ob, PetscInt* size, PetscReal** data):
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_REAL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)             # <<<<<<<<<<<<<<
 *     if data != NULL: data[0] = <PetscReal*> PyArray_DATA(ary)
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_size != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_size[0]) = ((PetscInt)PyArray_SIZE(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":145
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_REAL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscReal*> PyArray_DATA(ary)             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_data[0]) = ((PetscReal *)PyArray_DATA(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":146
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscReal*> PyArray_DATA(ary)
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray iarray_b(object ob, PetscInt* size, PetscBool** data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":142
 *     return ary
 * 
 * cdef inline ndarray iarray_r(object ob, PetscInt* size, PetscReal** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_REAL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.iarray_r", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":148
 *     return ary
 * 
 * cdef inline ndarray iarray_b(object ob, PetscInt* size, PetscBool** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_BOOL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_iarray_b(PyObject *__pyx_v_ob, PetscInt *__pyx_v_size, PetscBool **__pyx_v_data) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iarray_b", 0);

  /* "include/arraynpy.pxi":149
 * 
 * cdef inline ndarray iarray_b(object ob, PetscInt* size, PetscBool** data):
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_BOOL)             # <<<<<<<<<<<<<<
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscBool*> PyArray_DATA(ary)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_iarray(__pyx_v_ob, NPY_PETSC_BOOL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":150
 * cdef inline ndarray iarray_b(object ob, PetscInt* size, PetscBool** data):
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_BOOL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)             # <<<<<<<<<<<<<<
 *     if data != NULL: data[0] = <PetscBool*> PyArray_DATA(ary)
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_size != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_size[0]) = ((PetscInt)PyArray_SIZE(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":151
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_BOOL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscBool*> PyArray_DATA(ary)             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_data[0]) = ((PetscBool *)PyArray_DATA(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":152
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscBool*> PyArray_DATA(ary)
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray iarray_s(object ob, PetscInt* size, PetscScalar** data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":148
 *     return ary
 * 
 * cdef inline ndarray iarray_b(object ob, PetscInt* size, PetscBool** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_BOOL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.iarray_b", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":154
 *     return ary
 * 
 * cdef inline ndarray iarray_s(object ob, PetscInt* size, PetscScalar** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_SCALAR)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_iarray_s(PyObject *__pyx_v_ob, PetscInt *__pyx_v_size, PetscScalar **__pyx_v_data) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iarray_s", 0);

  /* "include/arraynpy.pxi":155
 * 
 * cdef inline ndarray iarray_s(object ob, PetscInt* size, PetscScalar** data):
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_SCALAR)             # <<<<<<<<<<<<<<
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_iarray(__pyx_v_ob, NPY_PETSC_SCALAR)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":156
 * cdef inline ndarray iarray_s(object ob, PetscInt* size, PetscScalar** data):
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_SCALAR)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)             # <<<<<<<<<<<<<<
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_size != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_size[0]) = ((PetscInt)PyArray_SIZE(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":157
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_SCALAR)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_data[0]) = ((PetscScalar *)PyArray_DATA(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":158
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":154
 *     return ary
 * 
 * cdef inline ndarray iarray_s(object ob, PetscInt* size, PetscScalar** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = iarray(ob, NPY_PETSC_SCALAR)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.iarray_s", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":162
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray oarray(object ob, int typenum):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, typenum, NPY_ARRAY_ALIGNED|NPY_ARRAY_WRITEABLE|NPY_ARRAY_NOTSWAPPED)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_oarray(PyObject *__pyx_v_ob, int __pyx_v_typenum) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("oarray", 0);

  /* "include/arraynpy.pxi":163
 * 
 * cdef inline ndarray oarray(object ob, int typenum):
 *     cdef ndarray ary = PyArray_FROM_OTF(             # <<<<<<<<<<<<<<
 *         ob, typenum, NPY_ARRAY_ALIGNED|NPY_ARRAY_WRITEABLE|NPY_ARRAY_NOTSWAPPED)
 *     if PyArray_ISCONTIGUOUS(ary): return ary
 */
  __pyx_t_1 = ((PyObject *)PyArray_FROM_OTF(__pyx_v_ob, __pyx_v_typenum, ((NPY_ARRAY_ALIGNED | NPY_ARRAY_WRITEABLE) | NPY_ARRAY_NOTSWAPPED))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":165
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, typenum, NPY_ARRAY_ALIGNED|NPY_ARRAY_WRITEABLE|NPY_ARRAY_NOTSWAPPED)
 *     if PyArray_ISCONTIGUOUS(ary): return ary             # <<<<<<<<<<<<<<
 *     if PyArray_ISFORTRAN(ary):    return ary
 *     return PyArray_Copy(ary)
 */
  __pyx_t_2 = (PyArray_ISCONTIGUOUS(__pyx_v_ary) != 0);
  if (__pyx_t_2) {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ary));
    __pyx_r = __pyx_v_ary;
    goto __pyx_L0;
  }

  /* "include/arraynpy.pxi":166
 *         ob, typenum, NPY_ARRAY_ALIGNED|NPY_ARRAY_WRITEABLE|NPY_ARRAY_NOTSWAPPED)
 *     if PyArray_ISCONTIGUOUS(ary): return ary
 *     if PyArray_ISFORTRAN(ary):    return ary             # <<<<<<<<<<<<<<
 *     return PyArray_Copy(ary)
 * 
 */
  __pyx_t_2 = (PyArray_ISFORTRAN(__pyx_v_ary) != 0);
  if (__pyx_t_2) {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ary));
    __pyx_r = __pyx_v_ary;
    goto __pyx_L0;
  }

  /* "include/arraynpy.pxi":167
 *     if PyArray_ISCONTIGUOUS(ary): return ary
 *     if PyArray_ISFORTRAN(ary):    return ary
 *     return PyArray_Copy(ary)             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray oarray_i(object ob, PetscInt* size, PetscInt** data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = ((PyObject *)PyArray_Copy(__pyx_v_ary)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":162
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray oarray(object ob, int typenum):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, typenum, NPY_ARRAY_ALIGNED|NPY_ARRAY_WRITEABLE|NPY_ARRAY_NOTSWAPPED)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.oarray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":169
 *     return PyArray_Copy(ary)
 * 
 * cdef inline ndarray oarray_i(object ob, PetscInt* size, PetscInt** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_INT)
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_oarray_i(PyObject *__pyx_v_ob, PetscInt *__pyx_v_size, PetscInt **__pyx_v_data) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("oarray_i", 0);

  /* "include/arraynpy.pxi":170
 * 
 * cdef inline ndarray oarray_i(object ob, PetscInt* size, PetscInt** data):
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_INT)             # <<<<<<<<<<<<<<
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscInt*> PyArray_DATA(ary)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_oarray(__pyx_v_ob, NPY_PETSC_INT)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":171
 * cdef inline ndarray oarray_i(object ob, PetscInt* size, PetscInt** data):
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_INT)
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)             # <<<<<<<<<<<<<<
 *     if data != NULL: data[0] = <PetscInt*> PyArray_DATA(ary)
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_size != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_size[0]) = ((PetscInt)PyArray_SIZE(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":172
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_INT)
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscInt*> PyArray_DATA(ary)             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_data[0]) = ((PetscInt *)PyArray_DATA(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":173
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscInt*> PyArray_DATA(ary)
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray oarray_r(object ob, PetscInt* size, PetscReal** data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":169
 *     return PyArray_Copy(ary)
 * 
 * cdef inline ndarray oarray_i(object ob, PetscInt* size, PetscInt** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_INT)
 *     if size != NULL: size[0] = <PetscInt>  PyArray_SIZE(ary)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.oarray_i", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":175
 *     return ary
 * 
 * cdef inline ndarray oarray_r(object ob, PetscInt* size, PetscReal** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_REAL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_oarray_r(PyObject *__pyx_v_ob, PetscInt *__pyx_v_size, PetscReal **__pyx_v_data) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("oarray_r", 0);

  /* "include/arraynpy.pxi":176
 * 
 * cdef inline ndarray oarray_r(object ob, PetscInt* size, PetscReal** data):
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_REAL)             # <<<<<<<<<<<<<<
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscReal*> PyArray_DATA(ary)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_oarray(__pyx_v_ob, NPY_PETSC_REAL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 176, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":177
 * cdef inline ndarray oarray_r(object ob, PetscInt* size, PetscReal** data):
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_REAL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)             # <<<<<<<<<<<<<<
 *     if data != NULL: data[0] = <PetscReal*> PyArray_DATA(ary)
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_size != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_size[0]) = ((PetscInt)PyArray_SIZE(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":178
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_REAL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscReal*> PyArray_DATA(ary)             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_data[0]) = ((PetscReal *)PyArray_DATA(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":179
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscReal*> PyArray_DATA(ary)
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray oarray_s(object ob, PetscInt* size, PetscScalar** data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":175
 *     return ary
 * 
 * cdef inline ndarray oarray_r(object ob, PetscInt* size, PetscReal** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_REAL)
 *     if size != NULL: size[0] = <PetscInt>   PyArray_SIZE(ary)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.oarray_r", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":181
 *     return ary
 * 
 * cdef inline ndarray oarray_s(object ob, PetscInt* size, PetscScalar** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_SCALAR)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_oarray_s(PyObject *__pyx_v_ob, PetscInt *__pyx_v_size, PetscScalar **__pyx_v_data) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("oarray_s", 0);

  /* "include/arraynpy.pxi":182
 * 
 * cdef inline ndarray oarray_s(object ob, PetscInt* size, PetscScalar** data):
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_SCALAR)             # <<<<<<<<<<<<<<
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_oarray(__pyx_v_ob, NPY_PETSC_SCALAR)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 182, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":183
 * cdef inline ndarray oarray_s(object ob, PetscInt* size, PetscScalar** data):
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_SCALAR)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)             # <<<<<<<<<<<<<<
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_size != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_size[0]) = ((PetscInt)PyArray_SIZE(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":184
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_SCALAR)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_data[0]) = ((PetscScalar *)PyArray_DATA(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":185
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray oarray_p(object ob, PetscInt* size, void** data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":181
 *     return ary
 * 
 * cdef inline ndarray oarray_s(object ob, PetscInt* size, PetscScalar** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = oarray(ob, NPY_PETSC_SCALAR)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.oarray_s", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":187
 *     return ary
 * 
 * cdef inline ndarray oarray_p(object ob, PetscInt* size, void** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = oarray(ob, NPY_INTP)
 *     if size != NULL: size[0] = <PetscInt> PyArray_SIZE(ary)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_oarray_p(PyObject *__pyx_v_ob, PetscInt *__pyx_v_size, void **__pyx_v_data) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("oarray_p", 0);

  /* "include/arraynpy.pxi":188
 * 
 * cdef inline ndarray oarray_p(object ob, PetscInt* size, void** data):
 *     cdef ndarray ary = oarray(ob, NPY_INTP)             # <<<<<<<<<<<<<<
 *     if size != NULL: size[0] = <PetscInt> PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <void*>    PyArray_DATA(ary)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_oarray(__pyx_v_ob, NPY_INTP)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":189
 * cdef inline ndarray oarray_p(object ob, PetscInt* size, void** data):
 *     cdef ndarray ary = oarray(ob, NPY_INTP)
 *     if size != NULL: size[0] = <PetscInt> PyArray_SIZE(ary)             # <<<<<<<<<<<<<<
 *     if data != NULL: data[0] = <void*>    PyArray_DATA(ary)
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_size != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_size[0]) = ((PetscInt)PyArray_SIZE(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":190
 *     cdef ndarray ary = oarray(ob, NPY_INTP)
 *     if size != NULL: size[0] = <PetscInt> PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <void*>    PyArray_DATA(ary)             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_data[0]) = ((void *)PyArray_DATA(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":191
 *     if size != NULL: size[0] = <PetscInt> PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <void*>    PyArray_DATA(ary)
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":187
 *     return ary
 * 
 * cdef inline ndarray oarray_p(object ob, PetscInt* size, void** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = oarray(ob, NPY_INTP)
 *     if size != NULL: size[0] = <PetscInt> PyArray_SIZE(ary)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.oarray_p", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":195
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray ocarray_s(object ob, PetscInt* size, PetscScalar** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, NPY_PETSC_SCALAR, NPY_ARRAY_CARRAY|NPY_ARRAY_NOTSWAPPED)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_ocarray_s(PyObject *__pyx_v_ob, PetscInt *__pyx_v_size, PetscScalar **__pyx_v_data) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ocarray_s", 0);

  /* "include/arraynpy.pxi":196
 * 
 * cdef inline ndarray ocarray_s(object ob, PetscInt* size, PetscScalar** data):
 *     cdef ndarray ary = PyArray_FROM_OTF(             # <<<<<<<<<<<<<<
 *         ob, NPY_PETSC_SCALAR, NPY_ARRAY_CARRAY|NPY_ARRAY_NOTSWAPPED)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 */
  __pyx_t_1 = ((PyObject *)PyArray_FROM_OTF(__pyx_v_ob, NPY_PETSC_SCALAR, (NPY_ARRAY_CARRAY | NPY_ARRAY_NOTSWAPPED))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":198
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, NPY_PETSC_SCALAR, NPY_ARRAY_CARRAY|NPY_ARRAY_NOTSWAPPED)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)             # <<<<<<<<<<<<<<
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_size != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_size[0]) = ((PetscInt)PyArray_SIZE(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":199
 *         ob, NPY_PETSC_SCALAR, NPY_ARRAY_CARRAY|NPY_ARRAY_NOTSWAPPED)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_data[0]) = ((PetscScalar *)PyArray_DATA(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":200
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * cdef inline ndarray ofarray_s(object ob, PetscInt* size, PetscScalar** data):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":195
 * # --------------------------------------------------------------------
 * 
 * cdef inline ndarray ocarray_s(object ob, PetscInt* size, PetscScalar** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, NPY_PETSC_SCALAR, NPY_ARRAY_CARRAY|NPY_ARRAY_NOTSWAPPED)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.ocarray_s", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "include/arraynpy.pxi":202
 *     return ary
 * 
 * cdef inline ndarray ofarray_s(object ob, PetscInt* size, PetscScalar** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, NPY_PETSC_SCALAR, NPY_ARRAY_FARRAY|NPY_ARRAY_NOTSWAPPED)
 */

static CYTHON_INLINE PyArrayObject *__pyx_f_11libpetsc4py_ofarray_s(PyObject *__pyx_v_ob, PetscInt *__pyx_v_size, PetscScalar **__pyx_v_data) {
  PyArrayObject *__pyx_v_ary = 0;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ofarray_s", 0);

  /* "include/arraynpy.pxi":203
 * 
 * cdef inline ndarray ofarray_s(object ob, PetscInt* size, PetscScalar** data):
 *     cdef ndarray ary = PyArray_FROM_OTF(             # <<<<<<<<<<<<<<
 *         ob, NPY_PETSC_SCALAR, NPY_ARRAY_FARRAY|NPY_ARRAY_NOTSWAPPED)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 */
  __pyx_t_1 = ((PyObject *)PyArray_FROM_OTF(__pyx_v_ob, NPY_PETSC_SCALAR, (NPY_ARRAY_FARRAY | NPY_ARRAY_NOTSWAPPED))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ary = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "include/arraynpy.pxi":205
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, NPY_PETSC_SCALAR, NPY_ARRAY_FARRAY|NPY_ARRAY_NOTSWAPPED)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)             # <<<<<<<<<<<<<<
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)
 *     return ary
 */
  __pyx_t_2 = ((__pyx_v_size != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_size[0]) = ((PetscInt)PyArray_SIZE(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":206
 *         ob, NPY_PETSC_SCALAR, NPY_ARRAY_FARRAY|NPY_ARRAY_NOTSWAPPED)
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)             # <<<<<<<<<<<<<<
 *     return ary
 * 
 */
  __pyx_t_2 = ((__pyx_v_data != NULL) != 0);
  if (__pyx_t_2) {
    (__pyx_v_data[0]) = ((PetscScalar *)PyArray_DATA(__pyx_v_ary));
  }

  /* "include/arraynpy.pxi":207
 *     if size != NULL: size[0] = <PetscInt>     PyArray_SIZE(ary)
 *     if data != NULL: data[0] = <PetscScalar*> PyArray_DATA(ary)
 *     return ary             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ary));
  __pyx_r = __pyx_v_ary;
  goto __pyx_L0;

  /* "include/arraynpy.pxi":202
 *     return ary
 * 
 * cdef inline ndarray ofarray_s(object ob, PetscInt* size, PetscScalar** data):             # <<<<<<<<<<<<<<
 *     cdef ndarray ary = PyArray_FROM_OTF(
 *         ob, NPY_PETSC_SCALAR, NPY_ARRAY_FARRAY|NPY_ARRAY_NOTSWAPPED)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.ofarray_s", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ary);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":118
 * cdef int   istack = 0
 * 
 * cdef inline void FunctionBegin(char name[]) nogil:             # <<<<<<<<<<<<<<
 *     global FUNCT
 *     FUNCT = name
 */

static CYTHON_INLINE void __pyx_f_11libpetsc4py_FunctionBegin(char *__pyx_v_name) {
  int __pyx_t_1;

  /* "libpetsc4py.pyx":120
 * cdef inline void FunctionBegin(char name[]) nogil:
 *     global FUNCT
 *     FUNCT = name             # <<<<<<<<<<<<<<
 *     global fstack, istack
 *     fstack[istack] = FUNCT
 */
  __pyx_v_11libpetsc4py_FUNCT = __pyx_v_name;

  /* "libpetsc4py.pyx":122
 *     FUNCT = name
 *     global fstack, istack
 *     fstack[istack] = FUNCT             # <<<<<<<<<<<<<<
 *     istack += 1
 *     if istack >= 1024:
 */
  (__pyx_v_11libpetsc4py_fstack[__pyx_v_11libpetsc4py_istack]) = __pyx_v_11libpetsc4py_FUNCT;

  /* "libpetsc4py.pyx":123
 *     global fstack, istack
 *     fstack[istack] = FUNCT
 *     istack += 1             # <<<<<<<<<<<<<<
 *     if istack >= 1024:
 *         istack = 0
 */
  __pyx_v_11libpetsc4py_istack = (__pyx_v_11libpetsc4py_istack + 1);

  /* "libpetsc4py.pyx":124
 *     fstack[istack] = FUNCT
 *     istack += 1
 *     if istack >= 1024:             # <<<<<<<<<<<<<<
 *         istack = 0
 *     return
 */
  __pyx_t_1 = ((__pyx_v_11libpetsc4py_istack >= 0x400) != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":125
 *     istack += 1
 *     if istack >= 1024:
 *         istack = 0             # <<<<<<<<<<<<<<
 *     return
 * 
 */
    __pyx_v_11libpetsc4py_istack = 0;

    /* "libpetsc4py.pyx":124
 *     fstack[istack] = FUNCT
 *     istack += 1
 *     if istack >= 1024:             # <<<<<<<<<<<<<<
 *         istack = 0
 *     return
 */
  }

  /* "libpetsc4py.pyx":126
 *     if istack >= 1024:
 *         istack = 0
 *     return             # <<<<<<<<<<<<<<
 * 
 * cdef inline PetscErrorCode FunctionEnd() nogil:
 */
  goto __pyx_L0;

  /* "libpetsc4py.pyx":118
 * cdef int   istack = 0
 * 
 * cdef inline void FunctionBegin(char name[]) nogil:             # <<<<<<<<<<<<<<
 *     global FUNCT
 *     FUNCT = name
 */

  /* function exit code */
  __pyx_L0:;
}

/* "libpetsc4py.pyx":128
 *     return
 * 
 * cdef inline PetscErrorCode FunctionEnd() nogil:             # <<<<<<<<<<<<<<
 *     global FUNCT
 *     FUNCT = NULL
 */

static CYTHON_INLINE PetscErrorCode __pyx_f_11libpetsc4py_FunctionEnd(void) {
  PetscErrorCode __pyx_r;
  int __pyx_t_1;

  /* "libpetsc4py.pyx":130
 * cdef inline PetscErrorCode FunctionEnd() nogil:
 *     global FUNCT
 *     FUNCT = NULL             # <<<<<<<<<<<<<<
 *     global fstack, istack
 *     istack -= 1
 */
  __pyx_v_11libpetsc4py_FUNCT = NULL;

  /* "libpetsc4py.pyx":132
 *     FUNCT = NULL
 *     global fstack, istack
 *     istack -= 1             # <<<<<<<<<<<<<<
 *     if istack < 0:
 *         istack = 1024
 */
  __pyx_v_11libpetsc4py_istack = (__pyx_v_11libpetsc4py_istack - 1);

  /* "libpetsc4py.pyx":133
 *     global fstack, istack
 *     istack -= 1
 *     if istack < 0:             # <<<<<<<<<<<<<<
 *         istack = 1024
 *     FUNCT = fstack[istack]
 */
  __pyx_t_1 = ((__pyx_v_11libpetsc4py_istack < 0) != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":134
 *     istack -= 1
 *     if istack < 0:
 *         istack = 1024             # <<<<<<<<<<<<<<
 *     FUNCT = fstack[istack]
 *     return 0
 */
    __pyx_v_11libpetsc4py_istack = 0x400;

    /* "libpetsc4py.pyx":133
 *     global fstack, istack
 *     istack -= 1
 *     if istack < 0:             # <<<<<<<<<<<<<<
 *         istack = 1024
 *     FUNCT = fstack[istack]
 */
  }

  /* "libpetsc4py.pyx":135
 *     if istack < 0:
 *         istack = 1024
 *     FUNCT = fstack[istack]             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  __pyx_v_11libpetsc4py_FUNCT = (__pyx_v_11libpetsc4py_fstack[__pyx_v_11libpetsc4py_istack]);

  /* "libpetsc4py.pyx":136
 *         istack = 1024
 *     FUNCT = fstack[istack]
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PetscSETERR(PetscErrorCode ierr,char msg[]) nogil:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":128
 *     return
 * 
 * cdef inline PetscErrorCode FunctionEnd() nogil:             # <<<<<<<<<<<<<<
 *     global FUNCT
 *     FUNCT = NULL
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "libpetsc4py.pyx":138
 *     return 0
 * 
 * cdef PetscErrorCode PetscSETERR(PetscErrorCode ierr,char msg[]) nogil:             # <<<<<<<<<<<<<<
 *     global fstack, istack
 *     istack = 0; fstack[istack] = NULL;
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PetscSETERR(PetscErrorCode __pyx_v_ierr, char *__pyx_v_msg) {
  PetscErrorCode __pyx_r;

  /* "libpetsc4py.pyx":140
 * cdef PetscErrorCode PetscSETERR(PetscErrorCode ierr,char msg[]) nogil:
 *     global fstack, istack
 *     istack = 0; fstack[istack] = NULL;             # <<<<<<<<<<<<<<
 *     global FUNCT
 *     return PetscERROR(PETSC_COMM_SELF,FUNCT,ierr,
 */
  __pyx_v_11libpetsc4py_istack = 0;
  (__pyx_v_11libpetsc4py_fstack[__pyx_v_11libpetsc4py_istack]) = NULL;

  /* "libpetsc4py.pyx":142
 *     istack = 0; fstack[istack] = NULL;
 *     global FUNCT
 *     return PetscERROR(PETSC_COMM_SELF,FUNCT,ierr,             # <<<<<<<<<<<<<<
 *                       PETSC_ERROR_INITIAL, msg, NULL)
 * 
 */
  __pyx_r = PetscERROR(PETSC_COMM_SELF, __pyx_v_11libpetsc4py_FUNCT, __pyx_v_ierr, PETSC_ERROR_INITIAL, __pyx_v_msg, NULL);
  goto __pyx_L0;

  /* "libpetsc4py.pyx":138
 *     return 0
 * 
 * cdef PetscErrorCode PetscSETERR(PetscErrorCode ierr,char msg[]) nogil:             # <<<<<<<<<<<<<<
 *     global fstack, istack
 *     istack = 0; fstack[istack] = NULL;
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "libpetsc4py.pyx":145
 *                       PETSC_ERROR_INITIAL, msg, NULL)
 * 
 * cdef PetscErrorCode PetscCHKERR(PetscErrorCode ierr) nogil:             # <<<<<<<<<<<<<<
 *     global fstack, istack
 *     istack = 0; fstack[istack] = NULL;
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PetscCHKERR(PetscErrorCode __pyx_v_ierr) {
  PetscErrorCode __pyx_r;

  /* "libpetsc4py.pyx":147
 * cdef PetscErrorCode PetscCHKERR(PetscErrorCode ierr) nogil:
 *     global fstack, istack
 *     istack = 0; fstack[istack] = NULL;             # <<<<<<<<<<<<<<
 *     global FUNCT
 *     return PetscERROR(PETSC_COMM_SELF,FUNCT,ierr,
 */
  __pyx_v_11libpetsc4py_istack = 0;
  (__pyx_v_11libpetsc4py_fstack[__pyx_v_11libpetsc4py_istack]) = NULL;

  /* "libpetsc4py.pyx":149
 *     istack = 0; fstack[istack] = NULL;
 *     global FUNCT
 *     return PetscERROR(PETSC_COMM_SELF,FUNCT,ierr,             # <<<<<<<<<<<<<<
 *                       PETSC_ERROR_REPEAT, b"", NULL)
 * 
 */
  __pyx_r = PetscERROR(PETSC_COMM_SELF, __pyx_v_11libpetsc4py_FUNCT, __pyx_v_ierr, PETSC_ERROR_REPEAT, ((char *)""), NULL);
  goto __pyx_L0;

  /* "libpetsc4py.pyx":145
 *                       PETSC_ERROR_INITIAL, msg, NULL)
 * 
 * cdef PetscErrorCode PetscCHKERR(PetscErrorCode ierr) nogil:             # <<<<<<<<<<<<<<
 *     global fstack, istack
 *     istack = 0; fstack[istack] = NULL;
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "libpetsc4py.pyx":160
 * from petsc4py.PETSc import Error as PetscError
 * 
 * cdef inline void PythonSETERR(PetscErrorCode ierr) with gil:             # <<<<<<<<<<<<<<
 *     if (<void*>PetscError) != NULL:
 *         PyErr_SetObject(PetscError, <long>ierr)
 */

static CYTHON_INLINE void __pyx_f_11libpetsc4py_PythonSETERR(PetscErrorCode __pyx_v_ierr) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PythonSETERR", 0);

  /* "libpetsc4py.pyx":161
 * 
 * cdef inline void PythonSETERR(PetscErrorCode ierr) with gil:
 *     if (<void*>PetscError) != NULL:             # <<<<<<<<<<<<<<
 *         PyErr_SetObject(PetscError, <long>ierr)
 *     else:
 */
  __pyx_t_1 = ((((void *)__pyx_v_11libpetsc4py_PetscError) != NULL) != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":162
 * cdef inline void PythonSETERR(PetscErrorCode ierr) with gil:
 *     if (<void*>PetscError) != NULL:
 *         PyErr_SetObject(PetscError, <long>ierr)             # <<<<<<<<<<<<<<
 *     else:
 *         PyErr_SetObject(<object>PyExc_RuntimeError, <long>ierr)
 */
    __pyx_t_2 = __pyx_v_11libpetsc4py_PetscError;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_From_long(((long)__pyx_v_ierr)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 162, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    PyErr_SetObject(__pyx_t_2, __pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libpetsc4py.pyx":161
 * 
 * cdef inline void PythonSETERR(PetscErrorCode ierr) with gil:
 *     if (<void*>PetscError) != NULL:             # <<<<<<<<<<<<<<
 *         PyErr_SetObject(PetscError, <long>ierr)
 *     else:
 */
    goto __pyx_L3;
  }

  /* "libpetsc4py.pyx":164
 *         PyErr_SetObject(PetscError, <long>ierr)
 *     else:
 *         PyErr_SetObject(<object>PyExc_RuntimeError, <long>ierr)             # <<<<<<<<<<<<<<
 * 
 * cdef inline int CHKERR(PetscErrorCode ierr) nogil except -1:
 */
  /*else*/ {
    __pyx_t_3 = ((PyObject *)PyExc_RuntimeError);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyInt_From_long(((long)__pyx_v_ierr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    PyErr_SetObject(__pyx_t_3, __pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "libpetsc4py.pyx":160
 * from petsc4py.PETSc import Error as PetscError
 * 
 * cdef inline void PythonSETERR(PetscErrorCode ierr) with gil:             # <<<<<<<<<<<<<<
 *     if (<void*>PetscError) != NULL:
 *         PyErr_SetObject(PetscError, <long>ierr)
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("libpetsc4py.PythonSETERR", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "libpetsc4py.pyx":166
 *         PyErr_SetObject(<object>PyExc_RuntimeError, <long>ierr)
 * 
 * cdef inline int CHKERR(PetscErrorCode ierr) nogil except -1:             # <<<<<<<<<<<<<<
 *     if ierr == 0:
 *         return 0
 */

static CYTHON_INLINE int __pyx_f_11libpetsc4py_CHKERR(PetscErrorCode __pyx_v_ierr) {
  int __pyx_r;
  int __pyx_t_1;

  /* "libpetsc4py.pyx":167
 * 
 * cdef inline int CHKERR(PetscErrorCode ierr) nogil except -1:
 *     if ierr == 0:             # <<<<<<<<<<<<<<
 *         return 0
 *     if ierr == PETSC_ERR_PYTHON:
 */
  __pyx_t_1 = ((__pyx_v_ierr == 0) != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":168
 * cdef inline int CHKERR(PetscErrorCode ierr) nogil except -1:
 *     if ierr == 0:
 *         return 0             # <<<<<<<<<<<<<<
 *     if ierr == PETSC_ERR_PYTHON:
 *         #PetscCHKERR(ierr)
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "libpetsc4py.pyx":167
 * 
 * cdef inline int CHKERR(PetscErrorCode ierr) nogil except -1:
 *     if ierr == 0:             # <<<<<<<<<<<<<<
 *         return 0
 *     if ierr == PETSC_ERR_PYTHON:
 */
  }

  /* "libpetsc4py.pyx":169
 *     if ierr == 0:
 *         return 0
 *     if ierr == PETSC_ERR_PYTHON:             # <<<<<<<<<<<<<<
 *         #PetscCHKERR(ierr)
 *         return -1
 */
  __pyx_t_1 = ((__pyx_v_ierr == PETSC_ERR_PYTHON) != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":171
 *     if ierr == PETSC_ERR_PYTHON:
 *         #PetscCHKERR(ierr)
 *         return -1             # <<<<<<<<<<<<<<
 *     if Py_IsInitialized():
 *         PythonSETERR(ierr)
 */
    __pyx_r = -1;
    goto __pyx_L0;

    /* "libpetsc4py.pyx":169
 *     if ierr == 0:
 *         return 0
 *     if ierr == PETSC_ERR_PYTHON:             # <<<<<<<<<<<<<<
 *         #PetscCHKERR(ierr)
 *         return -1
 */
  }

  /* "libpetsc4py.pyx":172
 *         #PetscCHKERR(ierr)
 *         return -1
 *     if Py_IsInitialized():             # <<<<<<<<<<<<<<
 *         PythonSETERR(ierr)
 *     PetscCHKERR(ierr)
 */
  __pyx_t_1 = (Py_IsInitialized() != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":173
 *         return -1
 *     if Py_IsInitialized():
 *         PythonSETERR(ierr)             # <<<<<<<<<<<<<<
 *     PetscCHKERR(ierr)
 *     return -1
 */
    __pyx_f_11libpetsc4py_PythonSETERR(__pyx_v_ierr);

    /* "libpetsc4py.pyx":172
 *         #PetscCHKERR(ierr)
 *         return -1
 *     if Py_IsInitialized():             # <<<<<<<<<<<<<<
 *         PythonSETERR(ierr)
 *     PetscCHKERR(ierr)
 */
  }

  /* "libpetsc4py.pyx":174
 *     if Py_IsInitialized():
 *         PythonSETERR(ierr)
 *     PetscCHKERR(ierr)             # <<<<<<<<<<<<<<
 *     return -1
 * 
 */
  (void)(__pyx_f_11libpetsc4py_PetscCHKERR(__pyx_v_ierr));

  /* "libpetsc4py.pyx":175
 *         PythonSETERR(ierr)
 *     PetscCHKERR(ierr)
 *     return -1             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode UNSUPPORTED(char msg[]) nogil:
 */
  __pyx_r = -1;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":166
 *         PyErr_SetObject(<object>PyExc_RuntimeError, <long>ierr)
 * 
 * cdef inline int CHKERR(PetscErrorCode ierr) nogil except -1:             # <<<<<<<<<<<<<<
 *     if ierr == 0:
 *         return 0
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "libpetsc4py.pyx":177
 *     return -1
 * 
 * cdef PetscErrorCode UNSUPPORTED(char msg[]) nogil:             # <<<<<<<<<<<<<<
 *     global FUNCT
 *     return PetscERROR(PETSC_COMM_SELF,FUNCT,PETSC_ERR_USER,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_UNSUPPORTED(char *__pyx_v_msg) {
  PetscErrorCode __pyx_r;

  /* "libpetsc4py.pyx":179
 * cdef PetscErrorCode UNSUPPORTED(char msg[]) nogil:
 *     global FUNCT
 *     return PetscERROR(PETSC_COMM_SELF,FUNCT,PETSC_ERR_USER,             # <<<<<<<<<<<<<<
 *                       PETSC_ERROR_INITIAL,b"method %s()",msg)
 * 
 */
  __pyx_r = PetscERROR(PETSC_COMM_SELF, __pyx_v_11libpetsc4py_FUNCT, PETSC_ERR_USER, PETSC_ERROR_INITIAL, ((char *)"method %s()"), __pyx_v_msg);
  goto __pyx_L0;

  /* "libpetsc4py.pyx":177
 *     return -1
 * 
 * cdef PetscErrorCode UNSUPPORTED(char msg[]) nogil:             # <<<<<<<<<<<<<<
 *     global FUNCT
 *     return PetscERROR(PETSC_COMM_SELF,FUNCT,PETSC_ERR_USER,
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "libpetsc4py.pyx":184
 * # --------------------------------------------------------------------
 * 
 * cdef inline PetscInt getRef(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return 0
 */

static CYTHON_INLINE PetscInt __pyx_f_11libpetsc4py_getRef(void *__pyx_v_pobj) {
  PetscObject __pyx_v_obj;
  PetscInt __pyx_r;
  int __pyx_t_1;

  /* "libpetsc4py.pyx":185
 * 
 * cdef inline PetscInt getRef(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj             # <<<<<<<<<<<<<<
 *     if obj == NULL: return 0
 *     else: return obj.refct
 */
  __pyx_v_obj = ((PetscObject)__pyx_v_pobj);

  /* "libpetsc4py.pyx":186
 * cdef inline PetscInt getRef(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return 0             # <<<<<<<<<<<<<<
 *     else: return obj.refct
 * 
 */
  __pyx_t_1 = ((__pyx_v_obj == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":187
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return 0
 *     else: return obj.refct             # <<<<<<<<<<<<<<
 * 
 * cdef inline void addRef(void *pobj) nogil:
 */
  /*else*/ {
    __pyx_r = __pyx_v_obj->refct;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":184
 * # --------------------------------------------------------------------
 * 
 * cdef inline PetscInt getRef(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return 0
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "libpetsc4py.pyx":189
 *     else: return obj.refct
 * 
 * cdef inline void addRef(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj != NULL: obj.refct += 1
 */

static CYTHON_INLINE void __pyx_f_11libpetsc4py_addRef(void *__pyx_v_pobj) {
  PetscObject __pyx_v_obj;
  int __pyx_t_1;

  /* "libpetsc4py.pyx":190
 * 
 * cdef inline void addRef(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj             # <<<<<<<<<<<<<<
 *     if obj != NULL: obj.refct += 1
 * 
 */
  __pyx_v_obj = ((PetscObject)__pyx_v_pobj);

  /* "libpetsc4py.pyx":191
 * cdef inline void addRef(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj != NULL: obj.refct += 1             # <<<<<<<<<<<<<<
 * 
 * cdef inline void delRef(void *pobj) nogil:
 */
  __pyx_t_1 = ((__pyx_v_obj != NULL) != 0);
  if (__pyx_t_1) {
    __pyx_v_obj->refct = (__pyx_v_obj->refct + 1);
  }

  /* "libpetsc4py.pyx":189
 *     else: return obj.refct
 * 
 * cdef inline void addRef(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj != NULL: obj.refct += 1
 */

  /* function exit code */
}

/* "libpetsc4py.pyx":193
 *     if obj != NULL: obj.refct += 1
 * 
 * cdef inline void delRef(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj != NULL: obj.refct -= 1
 */

static CYTHON_INLINE void __pyx_f_11libpetsc4py_delRef(void *__pyx_v_pobj) {
  PetscObject __pyx_v_obj;
  int __pyx_t_1;

  /* "libpetsc4py.pyx":194
 * 
 * cdef inline void delRef(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj             # <<<<<<<<<<<<<<
 *     if obj != NULL: obj.refct -= 1
 * 
 */
  __pyx_v_obj = ((PetscObject)__pyx_v_pobj);

  /* "libpetsc4py.pyx":195
 * cdef inline void delRef(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj != NULL: obj.refct -= 1             # <<<<<<<<<<<<<<
 * 
 * cdef inline PetscObject newRef(void *pobj) nogil:
 */
  __pyx_t_1 = ((__pyx_v_obj != NULL) != 0);
  if (__pyx_t_1) {
    __pyx_v_obj->refct = (__pyx_v_obj->refct - 1);
  }

  /* "libpetsc4py.pyx":193
 *     if obj != NULL: obj.refct += 1
 * 
 * cdef inline void delRef(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj != NULL: obj.refct -= 1
 */

  /* function exit code */
}

/* "libpetsc4py.pyx":197
 *     if obj != NULL: obj.refct -= 1
 * 
 * cdef inline PetscObject newRef(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     cdef int ierr = 0
 */

static CYTHON_INLINE PetscObject __pyx_f_11libpetsc4py_newRef(void *__pyx_v_pobj) {
  PetscObject __pyx_v_obj;
  int __pyx_v_ierr;
  PetscObject __pyx_r;
  int __pyx_t_1;

  /* "libpetsc4py.pyx":198
 * 
 * cdef inline PetscObject newRef(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj             # <<<<<<<<<<<<<<
 *     cdef int ierr = 0
 *     if obj != NULL:
 */
  __pyx_v_obj = ((PetscObject)__pyx_v_pobj);

  /* "libpetsc4py.pyx":199
 * cdef inline PetscObject newRef(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj
 *     cdef int ierr = 0             # <<<<<<<<<<<<<<
 *     if obj != NULL:
 *         ierr = PetscObjectReference(obj)
 */
  __pyx_v_ierr = 0;

  /* "libpetsc4py.pyx":200
 *     cdef PetscObject obj = <PetscObject>pobj
 *     cdef int ierr = 0
 *     if obj != NULL:             # <<<<<<<<<<<<<<
 *         ierr = PetscObjectReference(obj)
 *         if ierr: return NULL # XXX warning!
 */
  __pyx_t_1 = ((__pyx_v_obj != NULL) != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":201
 *     cdef int ierr = 0
 *     if obj != NULL:
 *         ierr = PetscObjectReference(obj)             # <<<<<<<<<<<<<<
 *         if ierr: return NULL # XXX warning!
 *     return obj
 */
    __pyx_v_ierr = PetscObjectReference(__pyx_v_obj);

    /* "libpetsc4py.pyx":202
 *     if obj != NULL:
 *         ierr = PetscObjectReference(obj)
 *         if ierr: return NULL # XXX warning!             # <<<<<<<<<<<<<<
 *     return obj
 * 
 */
    __pyx_t_1 = (__pyx_v_ierr != 0);
    if (__pyx_t_1) {
      __pyx_r = NULL;
      goto __pyx_L0;
    }

    /* "libpetsc4py.pyx":200
 *     cdef PetscObject obj = <PetscObject>pobj
 *     cdef int ierr = 0
 *     if obj != NULL:             # <<<<<<<<<<<<<<
 *         ierr = PetscObjectReference(obj)
 *         if ierr: return NULL # XXX warning!
 */
  }

  /* "libpetsc4py.pyx":203
 *         ierr = PetscObjectReference(obj)
 *         if ierr: return NULL # XXX warning!
 *     return obj             # <<<<<<<<<<<<<<
 * 
 * cdef inline char* getPrefix(void *pobj) nogil:
 */
  __pyx_r = __pyx_v_obj;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":197
 *     if obj != NULL: obj.refct -= 1
 * 
 * cdef inline PetscObject newRef(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     cdef int ierr = 0
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "libpetsc4py.pyx":205
 *     return obj
 * 
 * cdef inline char* getPrefix(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return NULL
 */

static CYTHON_INLINE char *__pyx_f_11libpetsc4py_getPrefix(void *__pyx_v_pobj) {
  PetscObject __pyx_v_obj;
  char *__pyx_r;
  int __pyx_t_1;

  /* "libpetsc4py.pyx":206
 * 
 * cdef inline char* getPrefix(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj             # <<<<<<<<<<<<<<
 *     if obj == NULL: return NULL
 *     return obj.prefix
 */
  __pyx_v_obj = ((PetscObject)__pyx_v_pobj);

  /* "libpetsc4py.pyx":207
 * cdef inline char* getPrefix(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return NULL             # <<<<<<<<<<<<<<
 *     return obj.prefix
 * 
 */
  __pyx_t_1 = ((__pyx_v_obj == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = NULL;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":208
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return NULL
 *     return obj.prefix             # <<<<<<<<<<<<<<
 * 
 * cdef inline int getCommSize(void *pobj) nogil:
 */
  __pyx_r = __pyx_v_obj->prefix;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":205
 *     return obj
 * 
 * cdef inline char* getPrefix(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return NULL
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "libpetsc4py.pyx":210
 *     return obj.prefix
 * 
 * cdef inline int getCommSize(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return 0
 */

static CYTHON_INLINE int __pyx_f_11libpetsc4py_getCommSize(void *__pyx_v_pobj) {
  PetscObject __pyx_v_obj;
  int __pyx_v_size;
  int __pyx_r;
  int __pyx_t_1;

  /* "libpetsc4py.pyx":211
 * 
 * cdef inline int getCommSize(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj             # <<<<<<<<<<<<<<
 *     if obj == NULL: return 0
 *     cdef int size = 0
 */
  __pyx_v_obj = ((PetscObject)__pyx_v_pobj);

  /* "libpetsc4py.pyx":212
 * cdef inline int getCommSize(void *pobj) nogil:
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return 0             # <<<<<<<<<<<<<<
 *     cdef int size = 0
 *     MPI_Comm_size(obj.comm,&size)
 */
  __pyx_t_1 = ((__pyx_v_obj == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":213
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return 0
 *     cdef int size = 0             # <<<<<<<<<<<<<<
 *     MPI_Comm_size(obj.comm,&size)
 *     return size
 */
  __pyx_v_size = 0;

  /* "libpetsc4py.pyx":214
 *     if obj == NULL: return 0
 *     cdef int size = 0
 *     MPI_Comm_size(obj.comm,&size)             # <<<<<<<<<<<<<<
 *     return size
 * 
 */
  (void)(MPI_Comm_size(__pyx_v_obj->comm, (&__pyx_v_size)));

  /* "libpetsc4py.pyx":215
 *     cdef int size = 0
 *     MPI_Comm_size(obj.comm,&size)
 *     return size             # <<<<<<<<<<<<<<
 * 
 * cdef inline Viewer Viewer_(PetscViewer p):
 */
  __pyx_r = __pyx_v_size;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":210
 *     return obj.prefix
 * 
 * cdef inline int getCommSize(void *pobj) nogil:             # <<<<<<<<<<<<<<
 *     cdef PetscObject obj = <PetscObject>pobj
 *     if obj == NULL: return 0
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "libpetsc4py.pyx":217
 *     return size
 * 
 * cdef inline Viewer Viewer_(PetscViewer p):             # <<<<<<<<<<<<<<
 *     cdef Viewer ob = Viewer.__new__(Viewer)
 *     ob.obj[0] = newRef(p)
 */

static CYTHON_INLINE struct PyPetscViewerObject *__pyx_f_11libpetsc4py_Viewer_(PetscViewer __pyx_v_p) {
  struct PyPetscViewerObject *__pyx_v_ob = 0;
  struct PyPetscViewerObject *__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("Viewer_", 0);

  /* "libpetsc4py.pyx":218
 * 
 * cdef inline Viewer Viewer_(PetscViewer p):
 *     cdef Viewer ob = Viewer.__new__(Viewer)             # <<<<<<<<<<<<<<
 *     ob.obj[0] = newRef(p)
 *     return ob
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_8petsc4py_5PETSc_Viewer), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8petsc4py_5PETSc_Viewer)))) __PYX_ERR(0, 218, __pyx_L1_error)
  __pyx_v_ob = ((struct PyPetscViewerObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":219
 * cdef inline Viewer Viewer_(PetscViewer p):
 *     cdef Viewer ob = Viewer.__new__(Viewer)
 *     ob.obj[0] = newRef(p)             # <<<<<<<<<<<<<<
 *     return ob
 * 
 */
  (__pyx_v_ob->__pyx_base.obj[0]) = __pyx_f_11libpetsc4py_newRef(__pyx_v_p);

  /* "libpetsc4py.pyx":220
 *     cdef Viewer ob = Viewer.__new__(Viewer)
 *     ob.obj[0] = newRef(p)
 *     return ob             # <<<<<<<<<<<<<<
 * 
 * cdef inline IS IS_(PetscIS p):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ob));
  __pyx_r = __pyx_v_ob;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":217
 *     return size
 * 
 * cdef inline Viewer Viewer_(PetscViewer p):             # <<<<<<<<<<<<<<
 *     cdef Viewer ob = Viewer.__new__(Viewer)
 *     ob.obj[0] = newRef(p)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.Viewer_", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ob);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":222
 *     return ob
 * 
 * cdef inline IS IS_(PetscIS p):             # <<<<<<<<<<<<<<
 *     cdef IS ob = IS.__new__(IS)
 *     ob.obj[0] = newRef(p)
 */

static CYTHON_INLINE struct PyPetscISObject *__pyx_f_11libpetsc4py_IS_(IS __pyx_v_p) {
  struct PyPetscISObject *__pyx_v_ob = 0;
  struct PyPetscISObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("IS_", 0);

  /* "libpetsc4py.pyx":223
 * 
 * cdef inline IS IS_(PetscIS p):
 *     cdef IS ob = IS.__new__(IS)             # <<<<<<<<<<<<<<
 *     ob.obj[0] = newRef(p)
 *     return ob
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_8petsc4py_5PETSc_IS), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8petsc4py_5PETSc_IS)))) __PYX_ERR(0, 223, __pyx_L1_error)
  __pyx_v_ob = ((struct PyPetscISObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":224
 * cdef inline IS IS_(PetscIS p):
 *     cdef IS ob = IS.__new__(IS)
 *     ob.obj[0] = newRef(p)             # <<<<<<<<<<<<<<
 *     return ob
 * 
 */
  (__pyx_v_ob->__pyx_base.obj[0]) = __pyx_f_11libpetsc4py_newRef(__pyx_v_p);

  /* "libpetsc4py.pyx":225
 *     cdef IS ob = IS.__new__(IS)
 *     ob.obj[0] = newRef(p)
 *     return ob             # <<<<<<<<<<<<<<
 * 
 * cdef inline Vec Vec_(PetscVec p):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ob));
  __pyx_r = __pyx_v_ob;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":222
 *     return ob
 * 
 * cdef inline IS IS_(PetscIS p):             # <<<<<<<<<<<<<<
 *     cdef IS ob = IS.__new__(IS)
 *     ob.obj[0] = newRef(p)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.IS_", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ob);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":227
 *     return ob
 * 
 * cdef inline Vec Vec_(PetscVec p):             # <<<<<<<<<<<<<<
 *     cdef Vec ob = Vec.__new__(Vec)
 *     ob.obj[0] = newRef(p)
 */

static CYTHON_INLINE struct PyPetscVecObject *__pyx_f_11libpetsc4py_Vec_(Vec __pyx_v_p) {
  struct PyPetscVecObject *__pyx_v_ob = 0;
  struct PyPetscVecObject *__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("Vec_", 0);

  /* "libpetsc4py.pyx":228
 * 
 * cdef inline Vec Vec_(PetscVec p):
 *     cdef Vec ob = Vec.__new__(Vec)             # <<<<<<<<<<<<<<
 *     ob.obj[0] = newRef(p)
 *     return ob
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_8petsc4py_5PETSc_Vec), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8petsc4py_5PETSc_Vec)))) __PYX_ERR(0, 228, __pyx_L1_error)
  __pyx_v_ob = ((struct PyPetscVecObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":229
 * cdef inline Vec Vec_(PetscVec p):
 *     cdef Vec ob = Vec.__new__(Vec)
 *     ob.obj[0] = newRef(p)             # <<<<<<<<<<<<<<
 *     return ob
 * 
 */
  (__pyx_v_ob->__pyx_base.obj[0]) = __pyx_f_11libpetsc4py_newRef(__pyx_v_p);

  /* "libpetsc4py.pyx":230
 *     cdef Vec ob = Vec.__new__(Vec)
 *     ob.obj[0] = newRef(p)
 *     return ob             # <<<<<<<<<<<<<<
 * 
 * cdef inline Mat Mat_(PetscMat p):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ob));
  __pyx_r = __pyx_v_ob;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":227
 *     return ob
 * 
 * cdef inline Vec Vec_(PetscVec p):             # <<<<<<<<<<<<<<
 *     cdef Vec ob = Vec.__new__(Vec)
 *     ob.obj[0] = newRef(p)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.Vec_", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ob);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":232
 *     return ob
 * 
 * cdef inline Mat Mat_(PetscMat p):             # <<<<<<<<<<<<<<
 *     cdef Mat ob = Mat.__new__(Mat)
 *     ob.obj[0] = newRef(p)
 */

static CYTHON_INLINE struct PyPetscMatObject *__pyx_f_11libpetsc4py_Mat_(Mat __pyx_v_p) {
  struct PyPetscMatObject *__pyx_v_ob = 0;
  struct PyPetscMatObject *__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("Mat_", 0);

  /* "libpetsc4py.pyx":233
 * 
 * cdef inline Mat Mat_(PetscMat p):
 *     cdef Mat ob = Mat.__new__(Mat)             # <<<<<<<<<<<<<<
 *     ob.obj[0] = newRef(p)
 *     return ob
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_8petsc4py_5PETSc_Mat), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8petsc4py_5PETSc_Mat)))) __PYX_ERR(0, 233, __pyx_L1_error)
  __pyx_v_ob = ((struct PyPetscMatObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":234
 * cdef inline Mat Mat_(PetscMat p):
 *     cdef Mat ob = Mat.__new__(Mat)
 *     ob.obj[0] = newRef(p)             # <<<<<<<<<<<<<<
 *     return ob
 * 
 */
  (__pyx_v_ob->__pyx_base.obj[0]) = __pyx_f_11libpetsc4py_newRef(__pyx_v_p);

  /* "libpetsc4py.pyx":235
 *     cdef Mat ob = Mat.__new__(Mat)
 *     ob.obj[0] = newRef(p)
 *     return ob             # <<<<<<<<<<<<<<
 * 
 * cdef inline PC PC_(PetscPC p):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ob));
  __pyx_r = __pyx_v_ob;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":232
 *     return ob
 * 
 * cdef inline Mat Mat_(PetscMat p):             # <<<<<<<<<<<<<<
 *     cdef Mat ob = Mat.__new__(Mat)
 *     ob.obj[0] = newRef(p)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.Mat_", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ob);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":237
 *     return ob
 * 
 * cdef inline PC PC_(PetscPC p):             # <<<<<<<<<<<<<<
 *     cdef PC ob = PC.__new__(PC)
 *     ob.obj[0] = newRef(p)
 */

static CYTHON_INLINE struct PyPetscPCObject *__pyx_f_11libpetsc4py_PC_(PC __pyx_v_p) {
  struct PyPetscPCObject *__pyx_v_ob = 0;
  struct PyPetscPCObject *__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("PC_", 0);

  /* "libpetsc4py.pyx":238
 * 
 * cdef inline PC PC_(PetscPC p):
 *     cdef PC ob = PC.__new__(PC)             # <<<<<<<<<<<<<<
 *     ob.obj[0] = newRef(p)
 *     return ob
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_8petsc4py_5PETSc_PC), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8petsc4py_5PETSc_PC)))) __PYX_ERR(0, 238, __pyx_L1_error)
  __pyx_v_ob = ((struct PyPetscPCObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":239
 * cdef inline PC PC_(PetscPC p):
 *     cdef PC ob = PC.__new__(PC)
 *     ob.obj[0] = newRef(p)             # <<<<<<<<<<<<<<
 *     return ob
 * 
 */
  (__pyx_v_ob->__pyx_base.obj[0]) = __pyx_f_11libpetsc4py_newRef(__pyx_v_p);

  /* "libpetsc4py.pyx":240
 *     cdef PC ob = PC.__new__(PC)
 *     ob.obj[0] = newRef(p)
 *     return ob             # <<<<<<<<<<<<<<
 * 
 * cdef inline KSP KSP_(PetscKSP p):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ob));
  __pyx_r = __pyx_v_ob;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":237
 *     return ob
 * 
 * cdef inline PC PC_(PetscPC p):             # <<<<<<<<<<<<<<
 *     cdef PC ob = PC.__new__(PC)
 *     ob.obj[0] = newRef(p)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.PC_", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ob);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":242
 *     return ob
 * 
 * cdef inline KSP KSP_(PetscKSP p):             # <<<<<<<<<<<<<<
 *     cdef KSP ob = KSP.__new__(KSP)
 *     ob.obj[0] = newRef(p)
 */

static CYTHON_INLINE struct PyPetscKSPObject *__pyx_f_11libpetsc4py_KSP_(KSP __pyx_v_p) {
  struct PyPetscKSPObject *__pyx_v_ob = 0;
  struct PyPetscKSPObject *__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("KSP_", 0);

  /* "libpetsc4py.pyx":243
 * 
 * cdef inline KSP KSP_(PetscKSP p):
 *     cdef KSP ob = KSP.__new__(KSP)             # <<<<<<<<<<<<<<
 *     ob.obj[0] = newRef(p)
 *     return ob
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_8petsc4py_5PETSc_KSP), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8petsc4py_5PETSc_KSP)))) __PYX_ERR(0, 243, __pyx_L1_error)
  __pyx_v_ob = ((struct PyPetscKSPObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":244
 * cdef inline KSP KSP_(PetscKSP p):
 *     cdef KSP ob = KSP.__new__(KSP)
 *     ob.obj[0] = newRef(p)             # <<<<<<<<<<<<<<
 *     return ob
 * 
 */
  (__pyx_v_ob->__pyx_base.obj[0]) = __pyx_f_11libpetsc4py_newRef(__pyx_v_p);

  /* "libpetsc4py.pyx":245
 *     cdef KSP ob = KSP.__new__(KSP)
 *     ob.obj[0] = newRef(p)
 *     return ob             # <<<<<<<<<<<<<<
 * 
 * cdef inline SNES SNES_(PetscSNES p):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ob));
  __pyx_r = __pyx_v_ob;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":242
 *     return ob
 * 
 * cdef inline KSP KSP_(PetscKSP p):             # <<<<<<<<<<<<<<
 *     cdef KSP ob = KSP.__new__(KSP)
 *     ob.obj[0] = newRef(p)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.KSP_", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ob);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":247
 *     return ob
 * 
 * cdef inline SNES SNES_(PetscSNES p):             # <<<<<<<<<<<<<<
 *     cdef SNES ob = SNES.__new__(SNES)
 *     ob.obj[0] = newRef(p)
 */

static CYTHON_INLINE struct PyPetscSNESObject *__pyx_f_11libpetsc4py_SNES_(SNES __pyx_v_p) {
  struct PyPetscSNESObject *__pyx_v_ob = 0;
  struct PyPetscSNESObject *__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("SNES_", 0);

  /* "libpetsc4py.pyx":248
 * 
 * cdef inline SNES SNES_(PetscSNES p):
 *     cdef SNES ob = SNES.__new__(SNES)             # <<<<<<<<<<<<<<
 *     ob.obj[0] = newRef(p)
 *     return ob
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_8petsc4py_5PETSc_SNES), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8petsc4py_5PETSc_SNES)))) __PYX_ERR(0, 248, __pyx_L1_error)
  __pyx_v_ob = ((struct PyPetscSNESObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":249
 * cdef inline SNES SNES_(PetscSNES p):
 *     cdef SNES ob = SNES.__new__(SNES)
 *     ob.obj[0] = newRef(p)             # <<<<<<<<<<<<<<
 *     return ob
 * 
 */
  (__pyx_v_ob->__pyx_base.obj[0]) = __pyx_f_11libpetsc4py_newRef(__pyx_v_p);

  /* "libpetsc4py.pyx":250
 *     cdef SNES ob = SNES.__new__(SNES)
 *     ob.obj[0] = newRef(p)
 *     return ob             # <<<<<<<<<<<<<<
 * 
 * cdef inline TS TS_(PetscTS p):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ob));
  __pyx_r = __pyx_v_ob;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":247
 *     return ob
 * 
 * cdef inline SNES SNES_(PetscSNES p):             # <<<<<<<<<<<<<<
 *     cdef SNES ob = SNES.__new__(SNES)
 *     ob.obj[0] = newRef(p)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.SNES_", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ob);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":252
 *     return ob
 * 
 * cdef inline TS TS_(PetscTS p):             # <<<<<<<<<<<<<<
 *     cdef TS ob = TS.__new__(TS)
 *     ob.obj[0] = newRef(p)
 */

static CYTHON_INLINE struct PyPetscTSObject *__pyx_f_11libpetsc4py_TS_(TS __pyx_v_p) {
  struct PyPetscTSObject *__pyx_v_ob = 0;
  struct PyPetscTSObject *__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("TS_", 0);

  /* "libpetsc4py.pyx":253
 * 
 * cdef inline TS TS_(PetscTS p):
 *     cdef TS ob = TS.__new__(TS)             # <<<<<<<<<<<<<<
 *     ob.obj[0] = newRef(p)
 *     return ob
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_8petsc4py_5PETSc_TS), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8petsc4py_5PETSc_TS)))) __PYX_ERR(0, 253, __pyx_L1_error)
  __pyx_v_ob = ((struct PyPetscTSObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":254
 * cdef inline TS TS_(PetscTS p):
 *     cdef TS ob = TS.__new__(TS)
 *     ob.obj[0] = newRef(p)             # <<<<<<<<<<<<<<
 *     return ob
 * 
 */
  (__pyx_v_ob->__pyx_base.obj[0]) = __pyx_f_11libpetsc4py_newRef(__pyx_v_p);

  /* "libpetsc4py.pyx":255
 *     cdef TS ob = TS.__new__(TS)
 *     ob.obj[0] = newRef(p)
 *     return ob             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ob));
  __pyx_r = __pyx_v_ob;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":252
 *     return ob
 * 
 * cdef inline TS TS_(PetscTS p):             # <<<<<<<<<<<<<<
 *     cdef TS ob = TS.__new__(TS)
 *     ob.obj[0] = newRef(p)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.TS_", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ob);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":259
 * # --------------------------------------------------------------------
 * 
 * cdef inline object bytes2str(const char p[]):             # <<<<<<<<<<<<<<
 *      if p == NULL:
 *          return None
 */

static CYTHON_INLINE PyObject *__pyx_f_11libpetsc4py_bytes2str(char const *__pyx_v_p) {
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("bytes2str", 0);

  /* "libpetsc4py.pyx":260
 * 
 * cdef inline object bytes2str(const char p[]):
 *      if p == NULL:             # <<<<<<<<<<<<<<
 *          return None
 *      cdef bytes s = <char*>p
 */
  __pyx_t_1 = ((__pyx_v_p == NULL) != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":261
 * cdef inline object bytes2str(const char p[]):
 *      if p == NULL:
 *          return None             # <<<<<<<<<<<<<<
 *      cdef bytes s = <char*>p
 *      if isinstance(s, str):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "libpetsc4py.pyx":260
 * 
 * cdef inline object bytes2str(const char p[]):
 *      if p == NULL:             # <<<<<<<<<<<<<<
 *          return None
 *      cdef bytes s = <char*>p
 */
  }

  /* "libpetsc4py.pyx":262
 *      if p == NULL:
 *          return None
 *      cdef bytes s = <char*>p             # <<<<<<<<<<<<<<
 *      if isinstance(s, str):
 *          return s
 */
  __pyx_t_2 = __Pyx_PyBytes_FromString(((char *)__pyx_v_p)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_s = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":263
 *          return None
 *      cdef bytes s = <char*>p
 *      if isinstance(s, str):             # <<<<<<<<<<<<<<
 *          return s
 *      else:
 */
  __pyx_t_1 = PyString_Check(__pyx_v_s); 
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":264
 *      cdef bytes s = <char*>p
 *      if isinstance(s, str):
 *          return s             # <<<<<<<<<<<<<<
 *      else:
 *          return s.decode()
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_s);
    __pyx_r = __pyx_v_s;
    goto __pyx_L0;

    /* "libpetsc4py.pyx":263
 *          return None
 *      cdef bytes s = <char*>p
 *      if isinstance(s, str):             # <<<<<<<<<<<<<<
 *          return s
 *      else:
 */
  }

  /* "libpetsc4py.pyx":266
 *          return s
 *      else:
 *          return s.decode()             # <<<<<<<<<<<<<<
 * 
 * cdef object parse_url(object url):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_decode_bytes(__pyx_v_s, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":259
 * # --------------------------------------------------------------------
 * 
 * cdef inline object bytes2str(const char p[]):             # <<<<<<<<<<<<<<
 *      if p == NULL:
 *          return None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.bytes2str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":268
 *          return s.decode()
 * 
 * cdef object parse_url(object url):             # <<<<<<<<<<<<<<
 *     path, name = url.rsplit(":", 1)
 *     return (path, name)
 */

static PyObject *__pyx_f_11libpetsc4py_parse_url(PyObject *__pyx_v_url) {
  PyObject *__pyx_v_path = NULL;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parse_url", 0);

  /* "libpetsc4py.pyx":269
 * 
 * cdef object parse_url(object url):
 *     path, name = url.rsplit(":", 1)             # <<<<<<<<<<<<<<
 *     return (path, name)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_url, __pyx_n_s_rsplit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 269, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 269, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 269, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_path = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_name = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":270
 * cdef object parse_url(object url):
 *     path, name = url.rsplit(":", 1)
 *     return (path, name)             # <<<<<<<<<<<<<<
 * 
 * cdef dict module_cache = {}
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_path);
  __Pyx_GIVEREF(__pyx_v_path);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_path);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_name);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":268
 *          return s.decode()
 * 
 * cdef object parse_url(object url):             # <<<<<<<<<<<<<<
 *     path, name = url.rsplit(":", 1)
 *     return (path, name)
 */

  /* 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("libpetsc4py.parse_url", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_path);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":274
 * cdef dict module_cache = {}
 * 
 * cdef object load_module(object path):             # <<<<<<<<<<<<<<
 *     if path in module_cache:
 *         return module_cache[path]
 */

static PyObject *__pyx_f_11libpetsc4py_load_module(PyObject *__pyx_v_path) {
  PyObject *__pyx_v_module = NULL;
  PyObject *__pyx_v_source = NULL;
  PyObject *__pyx_v_code = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  char const *__pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("load_module", 0);

  /* "libpetsc4py.pyx":275
 * 
 * cdef object load_module(object path):
 *     if path in module_cache:             # <<<<<<<<<<<<<<
 *         return module_cache[path]
 *     module = PyModule_New("__petsc__")
 */
  if (unlikely(__pyx_v_11libpetsc4py_module_cache == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 275, __pyx_L1_error)
  }
  __pyx_t_1 = (__Pyx_PyDict_ContainsTF(__pyx_v_path, __pyx_v_11libpetsc4py_module_cache, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 275, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":276
 * cdef object load_module(object path):
 *     if path in module_cache:
 *         return module_cache[path]             # <<<<<<<<<<<<<<
 *     module = PyModule_New("__petsc__")
 *     module.__file__ = path
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_11libpetsc4py_module_cache == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 276, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_11libpetsc4py_module_cache, __pyx_v_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "libpetsc4py.pyx":275
 * 
 * cdef object load_module(object path):
 *     if path in module_cache:             # <<<<<<<<<<<<<<
 *         return module_cache[path]
 *     module = PyModule_New("__petsc__")
 */
  }

  /* "libpetsc4py.pyx":277
 *     if path in module_cache:
 *         return module_cache[path]
 *     module = PyModule_New("__petsc__")             # <<<<<<<<<<<<<<
 *     module.__file__ = path
 *     module.__package__ = None
 */
  __pyx_t_3 = PyModule_New(((char *)"__petsc__")); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_module = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":278
 *         return module_cache[path]
 *     module = PyModule_New("__petsc__")
 *     module.__file__ = path             # <<<<<<<<<<<<<<
 *     module.__package__ = None
 *     module_cache[path] = module
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_module, __pyx_n_s_file, __pyx_v_path) < 0) __PYX_ERR(0, 278, __pyx_L1_error)

  /* "libpetsc4py.pyx":279
 *     module = PyModule_New("__petsc__")
 *     module.__file__ = path
 *     module.__package__ = None             # <<<<<<<<<<<<<<
 *     module_cache[path] = module
 *     try:
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_module, __pyx_n_s_package, Py_None) < 0) __PYX_ERR(0, 279, __pyx_L1_error)

  /* "libpetsc4py.pyx":280
 *     module.__file__ = path
 *     module.__package__ = None
 *     module_cache[path] = module             # <<<<<<<<<<<<<<
 *     try:
 *         source = open(path, 'rU')
 */
  if (unlikely(__pyx_v_11libpetsc4py_module_cache == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 280, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_11libpetsc4py_module_cache, __pyx_v_path, __pyx_v_module) < 0)) __PYX_ERR(0, 280, __pyx_L1_error)

  /* "libpetsc4py.pyx":281
 *     module.__package__ = None
 *     module_cache[path] = module
 *     try:             # <<<<<<<<<<<<<<
 *         source = open(path, 'rU')
 *         try:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "libpetsc4py.pyx":282
 *     module_cache[path] = module
 *     try:
 *         source = open(path, 'rU')             # <<<<<<<<<<<<<<
 *         try:
 *             code = compile(source.read(), path, 'exec')
 */
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 282, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_path);
      __Pyx_GIVEREF(__pyx_v_path);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_path);
      __Pyx_INCREF(__pyx_n_s_rU);
      __Pyx_GIVEREF(__pyx_n_s_rU);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_rU);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 282, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_source = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "libpetsc4py.pyx":283
 *     try:
 *         source = open(path, 'rU')
 *         try:             # <<<<<<<<<<<<<<
 *             code = compile(source.read(), path, 'exec')
 *         finally:
 */
      /*try:*/ {

        /* "libpetsc4py.pyx":284
 *         source = open(path, 'rU')
 *         try:
 *             code = compile(source.read(), path, 'exec')             # <<<<<<<<<<<<<<
 *         finally:
 *             source.close()
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_read); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_8 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_7 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 284, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7);
        __Pyx_INCREF(__pyx_v_path);
        __Pyx_GIVEREF(__pyx_v_path);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_path);
        __Pyx_INCREF(__pyx_n_s_exec);
        __Pyx_GIVEREF(__pyx_n_s_exec);
        PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_exec);
        __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_compile, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 284, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_v_code = __pyx_t_7;
        __pyx_t_7 = 0;
      }

      /* "libpetsc4py.pyx":286
 *             code = compile(source.read(), path, 'exec')
 *         finally:
 *             source.close()             # <<<<<<<<<<<<<<
 *         exec(code, module.__dict__)
 *     except:
 */
      /*finally:*/ {
        /*normal exit:*/{
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_close); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_8 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_8)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_8);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
            }
          }
          __pyx_t_7 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 286, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          goto __pyx_L12;
        }
        __pyx_L11_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_17);
          __pyx_t_9 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
          {
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s_close); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L14_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_8 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_8)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_8);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            __pyx_t_7 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 286, __pyx_L14_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          }
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
          }
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
          __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
          goto __pyx_L4_error;
          __pyx_L14_error:;
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
          }
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
          goto __pyx_L4_error;
        }
        __pyx_L12:;
      }

      /* "libpetsc4py.pyx":287
 *         finally:
 *             source.close()
 *         exec(code, module.__dict__)             # <<<<<<<<<<<<<<
 *     except:
 *         del module_cache[path]
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_module, __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 287, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = __Pyx_PyExec2(__pyx_v_code, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "libpetsc4py.pyx":281
 *     module.__package__ = None
 *     module_cache[path] = module
 *     try:             # <<<<<<<<<<<<<<
 *         source = open(path, 'rU')
 *         try:
 */
    }
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "libpetsc4py.pyx":288
 *             source.close()
 *         exec(code, module.__dict__)
 *     except:             # <<<<<<<<<<<<<<
 *         del module_cache[path]
 *         raise
 */
    /*except:*/ {
      __Pyx_AddTraceback("libpetsc4py.load_module", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(0, 288, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_8);

      /* "libpetsc4py.pyx":289
 *         exec(code, module.__dict__)
 *     except:
 *         del module_cache[path]             # <<<<<<<<<<<<<<
 *         raise
 *     return module
 */
      if (unlikely(__pyx_v_11libpetsc4py_module_cache == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 289, __pyx_L6_except_error)
      }
      if (unlikely(PyDict_DelItem(__pyx_v_11libpetsc4py_module_cache, __pyx_v_path) < 0)) __PYX_ERR(0, 289, __pyx_L6_except_error)

      /* "libpetsc4py.pyx":290
 *     except:
 *         del module_cache[path]
 *         raise             # <<<<<<<<<<<<<<
 *     return module
 * 
 */
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_7, __pyx_t_8);
      __pyx_t_3 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; 
      __PYX_ERR(0, 290, __pyx_L6_except_error)
    }
    __pyx_L6_except_error:;

    /* "libpetsc4py.pyx":281
 *     module.__package__ = None
 *     module_cache[path] = module
 *     try:             # <<<<<<<<<<<<<<
 *         source = open(path, 'rU')
 *         try:
 */
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L9_try_end:;
  }

  /* "libpetsc4py.pyx":291
 *         del module_cache[path]
 *         raise
 *     return module             # <<<<<<<<<<<<<<
 * 
 * # -----------------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_module);
  __pyx_r = __pyx_v_module;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":274
 * cdef dict module_cache = {}
 * 
 * cdef object load_module(object path):             # <<<<<<<<<<<<<<
 *     if path in module_cache:
 *         return module_cache[path]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("libpetsc4py.load_module", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF(__pyx_v_code);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":301
 *     cdef bytes  name
 * 
 *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
 *         return getattr(self.self, attr, None)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11libpetsc4py_6_PyObj_1__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/
static PyObject *__pyx_pw_11libpetsc4py_6_PyObj_1__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11libpetsc4py_6_PyObj___getattr__(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));

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

static PyObject *__pyx_pf_11libpetsc4py_6_PyObj___getattr__(struct __pyx_obj_11libpetsc4py__PyObj *__pyx_v_self, PyObject *__pyx_v_attr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getattr__", 0);

  /* "libpetsc4py.pyx":302
 * 
 *     def __getattr__(self, attr):
 *         return getattr(self.self, attr, None)             # <<<<<<<<<<<<<<
 * 
 *     cdef int setcontext(self, void *ctx, Object base) except -1:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_self->self;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetAttr3(__pyx_t_1, __pyx_v_attr, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":301
 *     cdef bytes  name
 * 
 *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
 *         return getattr(self.self, attr, None)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py._PyObj.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":304
 *         return getattr(self.self, attr, None)
 * 
 *     cdef int setcontext(self, void *ctx, Object base) except -1:             # <<<<<<<<<<<<<<
 *         #
 *         if ctx == <void*>self.self:
 */

static int __pyx_f_11libpetsc4py_6_PyObj_setcontext(struct __pyx_obj_11libpetsc4py__PyObj *__pyx_v_self, void *__pyx_v_ctx, struct PyPetscObjectObject *__pyx_v_base) {
  PyObject *__pyx_v_destroy = 0;
  PyObject *__pyx_v_create = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  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("setcontext", 0);

  /* "libpetsc4py.pyx":306
 *     cdef int setcontext(self, void *ctx, Object base) except -1:
 *         #
 *         if ctx == <void*>self.self:             # <<<<<<<<<<<<<<
 *             return 0
 *         #
 */
  __pyx_t_1 = ((__pyx_v_ctx == ((void *)__pyx_v_self->self)) != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":307
 *         #
 *         if ctx == <void*>self.self:
 *             return 0             # <<<<<<<<<<<<<<
 *         #
 *         cdef object destroy = self.destroy
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "libpetsc4py.pyx":306
 *     cdef int setcontext(self, void *ctx, Object base) except -1:
 *         #
 *         if ctx == <void*>self.self:             # <<<<<<<<<<<<<<
 *             return 0
 *         #
 */
  }

  /* "libpetsc4py.pyx":309
 *             return 0
 *         #
 *         cdef object destroy = self.destroy             # <<<<<<<<<<<<<<
 *         if destroy is not None:
 *             destroy(base)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_destroy = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":310
 *         #
 *         cdef object destroy = self.destroy
 *         if destroy is not None:             # <<<<<<<<<<<<<<
 *             destroy(base)
 *             destroy = None
 */
  __pyx_t_1 = (__pyx_v_destroy != Py_None);
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":311
 *         cdef object destroy = self.destroy
 *         if destroy is not None:
 *             destroy(base)             # <<<<<<<<<<<<<<
 *             destroy = None
 *         #
 */
    __Pyx_INCREF(__pyx_v_destroy);
    __pyx_t_4 = __pyx_v_destroy; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, ((PyObject *)__pyx_v_base)) : __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_base));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 311, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":312
 *         if destroy is not None:
 *             destroy(base)
 *             destroy = None             # <<<<<<<<<<<<<<
 *         #
 *         if ctx == NULL:
 */
    __Pyx_INCREF(Py_None);
    __Pyx_DECREF_SET(__pyx_v_destroy, Py_None);

    /* "libpetsc4py.pyx":310
 *         #
 *         cdef object destroy = self.destroy
 *         if destroy is not None:             # <<<<<<<<<<<<<<
 *             destroy(base)
 *             destroy = None
 */
  }

  /* "libpetsc4py.pyx":314
 *             destroy = None
 *         #
 *         if ctx == NULL:             # <<<<<<<<<<<<<<
 *             self.self = None
 *             self.name = None
 */
  __pyx_t_3 = ((__pyx_v_ctx == NULL) != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":315
 *         #
 *         if ctx == NULL:
 *             self.self = None             # <<<<<<<<<<<<<<
 *             self.name = None
 *             return 0
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->self);
    __Pyx_DECREF(__pyx_v_self->self);
    __pyx_v_self->self = Py_None;

    /* "libpetsc4py.pyx":316
 *         if ctx == NULL:
 *             self.self = None
 *             self.name = None             # <<<<<<<<<<<<<<
 *             return 0
 *         #
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->name);
    __Pyx_DECREF(__pyx_v_self->name);
    __pyx_v_self->name = ((PyObject*)Py_None);

    /* "libpetsc4py.pyx":317
 *             self.self = None
 *             self.name = None
 *             return 0             # <<<<<<<<<<<<<<
 *         #
 *         self.self = <object>ctx
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "libpetsc4py.pyx":314
 *             destroy = None
 *         #
 *         if ctx == NULL:             # <<<<<<<<<<<<<<
 *             self.self = None
 *             self.name = None
 */
  }

  /* "libpetsc4py.pyx":319
 *             return 0
 *         #
 *         self.self = <object>ctx             # <<<<<<<<<<<<<<
 *         self.name = None
 *         cdef object create = self.create
 */
  __pyx_t_2 = ((PyObject *)__pyx_v_ctx);
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->self);
  __Pyx_DECREF(__pyx_v_self->self);
  __pyx_v_self->self = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":320
 *         #
 *         self.self = <object>ctx
 *         self.name = None             # <<<<<<<<<<<<<<
 *         cdef object create = self.create
 *         if create is not None:
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = ((PyObject*)Py_None);

  /* "libpetsc4py.pyx":321
 *         self.self = <object>ctx
 *         self.name = None
 *         cdef object create = self.create             # <<<<<<<<<<<<<<
 *         if create is not None:
 *             create(base)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_create = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":322
 *         self.name = None
 *         cdef object create = self.create
 *         if create is not None:             # <<<<<<<<<<<<<<
 *             create(base)
 *             create = None
 */
  __pyx_t_3 = (__pyx_v_create != Py_None);
  __pyx_t_1 = (__pyx_t_3 != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":323
 *         cdef object create = self.create
 *         if create is not None:
 *             create(base)             # <<<<<<<<<<<<<<
 *             create = None
 *         return 0
 */
    __Pyx_INCREF(__pyx_v_create);
    __pyx_t_4 = __pyx_v_create; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, ((PyObject *)__pyx_v_base)) : __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_base));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":324
 *         if create is not None:
 *             create(base)
 *             create = None             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
    __Pyx_INCREF(Py_None);
    __Pyx_DECREF_SET(__pyx_v_create, Py_None);

    /* "libpetsc4py.pyx":322
 *         self.name = None
 *         cdef object create = self.create
 *         if create is not None:             # <<<<<<<<<<<<<<
 *             create(base)
 *             create = None
 */
  }

  /* "libpetsc4py.pyx":325
 *             create(base)
 *             create = None
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int getcontext(self, void **ctx) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":304
 *         return getattr(self.self, attr, None)
 * 
 *     cdef int setcontext(self, void *ctx, Object base) except -1:             # <<<<<<<<<<<<<<
 *         #
 *         if ctx == <void*>self.self:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("libpetsc4py._PyObj.setcontext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_destroy);
  __Pyx_XDECREF(__pyx_v_create);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":327
 *         return 0
 * 
 *     cdef int getcontext(self, void **ctx) except -1:             # <<<<<<<<<<<<<<
 *         if ctx == NULL: return 0
 *         if self.self is not None:
 */

static int __pyx_f_11libpetsc4py_6_PyObj_getcontext(struct __pyx_obj_11libpetsc4py__PyObj *__pyx_v_self, void **__pyx_v_ctx) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("getcontext", 0);

  /* "libpetsc4py.pyx":328
 * 
 *     cdef int getcontext(self, void **ctx) except -1:
 *         if ctx == NULL: return 0             # <<<<<<<<<<<<<<
 *         if self.self is not None:
 *             ctx[0] = <void*> self.self
 */
  __pyx_t_1 = ((__pyx_v_ctx == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":329
 *     cdef int getcontext(self, void **ctx) except -1:
 *         if ctx == NULL: return 0
 *         if self.self is not None:             # <<<<<<<<<<<<<<
 *             ctx[0] = <void*> self.self
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->self != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":330
 *         if ctx == NULL: return 0
 *         if self.self is not None:
 *             ctx[0] = <void*> self.self             # <<<<<<<<<<<<<<
 *         else:
 *             ctx[0] = NULL
 */
    (__pyx_v_ctx[0]) = ((void *)__pyx_v_self->self);

    /* "libpetsc4py.pyx":329
 *     cdef int getcontext(self, void **ctx) except -1:
 *         if ctx == NULL: return 0
 *         if self.self is not None:             # <<<<<<<<<<<<<<
 *             ctx[0] = <void*> self.self
 *         else:
 */
    goto __pyx_L4;
  }

  /* "libpetsc4py.pyx":332
 *             ctx[0] = <void*> self.self
 *         else:
 *             ctx[0] = NULL             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  /*else*/ {
    (__pyx_v_ctx[0]) = NULL;
  }
  __pyx_L4:;

  /* "libpetsc4py.pyx":333
 *         else:
 *             ctx[0] = NULL
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int setname(self, char name[]) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":327
 *         return 0
 * 
 *     cdef int getcontext(self, void **ctx) except -1:             # <<<<<<<<<<<<<<
 *         if ctx == NULL: return 0
 *         if self.self is not None:
 */

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

/* "libpetsc4py.pyx":335
 *         return 0
 * 
 *     cdef int setname(self, char name[]) except -1:             # <<<<<<<<<<<<<<
 *         if name != NULL and name[0] != 0:
 *             self.name = name
 */

static int __pyx_f_11libpetsc4py_6_PyObj_setname(struct __pyx_obj_11libpetsc4py__PyObj *__pyx_v_self, char *__pyx_v_name) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setname", 0);

  /* "libpetsc4py.pyx":336
 * 
 *     cdef int setname(self, char name[]) except -1:
 *         if name != NULL and name[0] != 0:             # <<<<<<<<<<<<<<
 *             self.name = name
 *         else:
 */
  __pyx_t_2 = ((__pyx_v_name != NULL) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_name[0]) != 0) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":337
 *     cdef int setname(self, char name[]) except -1:
 *         if name != NULL and name[0] != 0:
 *             self.name = name             # <<<<<<<<<<<<<<
 *         else:
 *             self.name = None
 */
    __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->name);
    __Pyx_DECREF(__pyx_v_self->name);
    __pyx_v_self->name = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "libpetsc4py.pyx":336
 * 
 *     cdef int setname(self, char name[]) except -1:
 *         if name != NULL and name[0] != 0:             # <<<<<<<<<<<<<<
 *             self.name = name
 *         else:
 */
    goto __pyx_L3;
  }

  /* "libpetsc4py.pyx":339
 *             self.name = name
 *         else:
 *             self.name = None             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->name);
    __Pyx_DECREF(__pyx_v_self->name);
    __pyx_v_self->name = ((PyObject*)Py_None);
  }
  __pyx_L3:;

  /* "libpetsc4py.pyx":340
 *         else:
 *             self.name = None
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef char* getname(self) except? NULL:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":335
 *         return 0
 * 
 *     cdef int setname(self, char name[]) except -1:             # <<<<<<<<<<<<<<
 *         if name != NULL and name[0] != 0:
 *             self.name = name
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libpetsc4py._PyObj.setname", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":342
 *         return 0
 * 
 *     cdef char* getname(self) except? NULL:             # <<<<<<<<<<<<<<
 *         if self.self is None:
 *             return NULL
 */

static char *__pyx_f_11libpetsc4py_6_PyObj_getname(struct __pyx_obj_11libpetsc4py__PyObj *__pyx_v_self) {
  PyObject *__pyx_v_ctx = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_modname = NULL;
  PyObject *__pyx_v_clsname = NULL;
  PyObject *__pyx_v_cls = NULL;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  char *__pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getname", 0);

  /* "libpetsc4py.pyx":343
 * 
 *     cdef char* getname(self) except? NULL:
 *         if self.self is None:             # <<<<<<<<<<<<<<
 *             return NULL
 *         if self.name is not None:
 */
  __pyx_t_1 = (__pyx_v_self->self == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":344
 *     cdef char* getname(self) except? NULL:
 *         if self.self is None:
 *             return NULL             # <<<<<<<<<<<<<<
 *         if self.name is not None:
 *             return self.name
 */
    __pyx_r = NULL;
    goto __pyx_L0;

    /* "libpetsc4py.pyx":343
 * 
 *     cdef char* getname(self) except? NULL:
 *         if self.self is None:             # <<<<<<<<<<<<<<
 *             return NULL
 *         if self.name is not None:
 */
  }

  /* "libpetsc4py.pyx":345
 *         if self.self is None:
 *             return NULL
 *         if self.name is not None:             # <<<<<<<<<<<<<<
 *             return self.name
 *         cdef ctx = self.self
 */
  __pyx_t_2 = (__pyx_v_self->name != ((PyObject*)Py_None));
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":346
 *             return NULL
 *         if self.name is not None:
 *             return self.name             # <<<<<<<<<<<<<<
 *         cdef ctx = self.self
 *         cdef name = None
 */
    if (unlikely(__pyx_v_self->name == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 346, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->name); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 346, __pyx_L1_error)
    __pyx_r = __pyx_t_3;
    goto __pyx_L0;

    /* "libpetsc4py.pyx":345
 *         if self.self is None:
 *             return NULL
 *         if self.name is not None:             # <<<<<<<<<<<<<<
 *             return self.name
 *         cdef ctx = self.self
 */
  }

  /* "libpetsc4py.pyx":347
 *         if self.name is not None:
 *             return self.name
 *         cdef ctx = self.self             # <<<<<<<<<<<<<<
 *         cdef name = None
 *         if PyModule_Check(ctx):
 */
  __pyx_t_4 = __pyx_v_self->self;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_ctx = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "libpetsc4py.pyx":348
 *             return self.name
 *         cdef ctx = self.self
 *         cdef name = None             # <<<<<<<<<<<<<<
 *         if PyModule_Check(ctx):
 *             name = getattr(ctx, '__name__', None)
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_name = Py_None;

  /* "libpetsc4py.pyx":349
 *         cdef ctx = self.self
 *         cdef name = None
 *         if PyModule_Check(ctx):             # <<<<<<<<<<<<<<
 *             name = getattr(ctx, '__name__', None)
 *         else:
 */
  __pyx_t_1 = (PyModule_Check(__pyx_v_ctx) != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":350
 *         cdef name = None
 *         if PyModule_Check(ctx):
 *             name = getattr(ctx, '__name__', None)             # <<<<<<<<<<<<<<
 *         else:
 *             modname = getattr(ctx, '__module__', None)
 */
    __pyx_t_4 = __Pyx_GetAttr3(__pyx_v_ctx, __pyx_n_s_name, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "libpetsc4py.pyx":349
 *         cdef ctx = self.self
 *         cdef name = None
 *         if PyModule_Check(ctx):             # <<<<<<<<<<<<<<
 *             name = getattr(ctx, '__name__', None)
 *         else:
 */
    goto __pyx_L5;
  }

  /* "libpetsc4py.pyx":352
 *             name = getattr(ctx, '__name__', None)
 *         else:
 *             modname = getattr(ctx, '__module__', None)             # <<<<<<<<<<<<<<
 *             clsname = None
 *             cls = getattr(ctx, '__class__', None)
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetAttr3(__pyx_v_ctx, __pyx_n_s_module, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_modname = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "libpetsc4py.pyx":353
 *         else:
 *             modname = getattr(ctx, '__module__', None)
 *             clsname = None             # <<<<<<<<<<<<<<
 *             cls = getattr(ctx, '__class__', None)
 *             if cls:
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_clsname = Py_None;

    /* "libpetsc4py.pyx":354
 *             modname = getattr(ctx, '__module__', None)
 *             clsname = None
 *             cls = getattr(ctx, '__class__', None)             # <<<<<<<<<<<<<<
 *             if cls:
 *                 clsname = getattr(cls, '__name__', None)
 */
    __pyx_t_4 = __Pyx_GetAttr3(__pyx_v_ctx, __pyx_n_s_class, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 354, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_cls = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "libpetsc4py.pyx":355
 *             clsname = None
 *             cls = getattr(ctx, '__class__', None)
 *             if cls:             # <<<<<<<<<<<<<<
 *                 clsname = getattr(cls, '__name__', None)
 *                 if not modname:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_cls); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 355, __pyx_L1_error)
    if (__pyx_t_1) {

      /* "libpetsc4py.pyx":356
 *             cls = getattr(ctx, '__class__', None)
 *             if cls:
 *                 clsname = getattr(cls, '__name__', None)             # <<<<<<<<<<<<<<
 *                 if not modname:
 *                     modname = getattr(cls, '__module__', None)
 */
      __pyx_t_4 = __Pyx_GetAttr3(__pyx_v_cls, __pyx_n_s_name, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 356, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_clsname, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "libpetsc4py.pyx":357
 *             if cls:
 *                 clsname = getattr(cls, '__name__', None)
 *                 if not modname:             # <<<<<<<<<<<<<<
 *                     modname = getattr(cls, '__module__', None)
 *             if modname and clsname:
 */
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_modname); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 357, __pyx_L1_error)
      __pyx_t_2 = ((!__pyx_t_1) != 0);
      if (__pyx_t_2) {

        /* "libpetsc4py.pyx":358
 *                 clsname = getattr(cls, '__name__', None)
 *                 if not modname:
 *                     modname = getattr(cls, '__module__', None)             # <<<<<<<<<<<<<<
 *             if modname and clsname:
 *                 name = modname + '.' + clsname
 */
        __pyx_t_4 = __Pyx_GetAttr3(__pyx_v_cls, __pyx_n_s_module, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 358, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF_SET(__pyx_v_modname, __pyx_t_4);
        __pyx_t_4 = 0;

        /* "libpetsc4py.pyx":357
 *             if cls:
 *                 clsname = getattr(cls, '__name__', None)
 *                 if not modname:             # <<<<<<<<<<<<<<
 *                     modname = getattr(cls, '__module__', None)
 *             if modname and clsname:
 */
      }

      /* "libpetsc4py.pyx":355
 *             clsname = None
 *             cls = getattr(ctx, '__class__', None)
 *             if cls:             # <<<<<<<<<<<<<<
 *                 clsname = getattr(cls, '__name__', None)
 *                 if not modname:
 */
    }

    /* "libpetsc4py.pyx":359
 *                 if not modname:
 *                     modname = getattr(cls, '__module__', None)
 *             if modname and clsname:             # <<<<<<<<<<<<<<
 *                 name = modname + '.' + clsname
 *             elif clsname:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_modname); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 359, __pyx_L1_error)
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_clsname); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 359, __pyx_L1_error)
    __pyx_t_2 = __pyx_t_1;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_2) {

      /* "libpetsc4py.pyx":360
 *                     modname = getattr(cls, '__module__', None)
 *             if modname and clsname:
 *                 name = modname + '.' + clsname             # <<<<<<<<<<<<<<
 *             elif clsname:
 *                 name = clsname
 */
      __pyx_t_4 = PyNumber_Add(__pyx_v_modname, __pyx_kp_s__3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 360, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_v_clsname); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 360, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "libpetsc4py.pyx":359
 *                 if not modname:
 *                     modname = getattr(cls, '__module__', None)
 *             if modname and clsname:             # <<<<<<<<<<<<<<
 *                 name = modname + '.' + clsname
 *             elif clsname:
 */
      goto __pyx_L8;
    }

    /* "libpetsc4py.pyx":361
 *             if modname and clsname:
 *                 name = modname + '.' + clsname
 *             elif clsname:             # <<<<<<<<<<<<<<
 *                 name = clsname
 *             elif modname:
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_clsname); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 361, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "libpetsc4py.pyx":362
 *                 name = modname + '.' + clsname
 *             elif clsname:
 *                 name = clsname             # <<<<<<<<<<<<<<
 *             elif modname:
 *                 name = modname
 */
      __Pyx_INCREF(__pyx_v_clsname);
      __Pyx_DECREF_SET(__pyx_v_name, __pyx_v_clsname);

      /* "libpetsc4py.pyx":361
 *             if modname and clsname:
 *                 name = modname + '.' + clsname
 *             elif clsname:             # <<<<<<<<<<<<<<
 *                 name = clsname
 *             elif modname:
 */
      goto __pyx_L8;
    }

    /* "libpetsc4py.pyx":363
 *             elif clsname:
 *                 name = clsname
 *             elif modname:             # <<<<<<<<<<<<<<
 *                 name = modname
 *         if name is not None:
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_modname); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 363, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "libpetsc4py.pyx":364
 *                 name = clsname
 *             elif modname:
 *                 name = modname             # <<<<<<<<<<<<<<
 *         if name is not None:
 *             self.name = name.encode()
 */
      __Pyx_INCREF(__pyx_v_modname);
      __Pyx_DECREF_SET(__pyx_v_name, __pyx_v_modname);

      /* "libpetsc4py.pyx":363
 *             elif clsname:
 *                 name = clsname
 *             elif modname:             # <<<<<<<<<<<<<<
 *                 name = modname
 *         if name is not None:
 */
    }
    __pyx_L8:;
  }
  __pyx_L5:;

  /* "libpetsc4py.pyx":365
 *             elif modname:
 *                 name = modname
 *         if name is not None:             # <<<<<<<<<<<<<<
 *             self.name = name.encode()
 *         if self.name is not None:
 */
  __pyx_t_2 = (__pyx_v_name != Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":366
 *                 name = modname
 *         if name is not None:
 *             self.name = name.encode()             # <<<<<<<<<<<<<<
 *         if self.name is not None:
 *             return self.name
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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_5 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(0, 366, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_self->name);
    __Pyx_DECREF(__pyx_v_self->name);
    __pyx_v_self->name = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "libpetsc4py.pyx":365
 *             elif modname:
 *                 name = modname
 *         if name is not None:             # <<<<<<<<<<<<<<
 *             self.name = name.encode()
 *         if self.name is not None:
 */
  }

  /* "libpetsc4py.pyx":367
 *         if name is not None:
 *             self.name = name.encode()
 *         if self.name is not None:             # <<<<<<<<<<<<<<
 *             return self.name
 *         return NULL
 */
  __pyx_t_1 = (__pyx_v_self->name != ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":368
 *             self.name = name.encode()
 *         if self.name is not None:
 *             return self.name             # <<<<<<<<<<<<<<
 *         return NULL
 * 
 */
    if (unlikely(__pyx_v_self->name == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 368, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->name); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 368, __pyx_L1_error)
    __pyx_r = __pyx_t_3;
    goto __pyx_L0;

    /* "libpetsc4py.pyx":367
 *         if name is not None:
 *             self.name = name.encode()
 *         if self.name is not None:             # <<<<<<<<<<<<<<
 *             return self.name
 *         return NULL
 */
  }

  /* "libpetsc4py.pyx":369
 *         if self.name is not None:
 *             return self.name
 *         return NULL             # <<<<<<<<<<<<<<
 * 
 * cdef createcontext(char name_p[]):
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":342
 *         return 0
 * 
 *     cdef char* getname(self) except? NULL:             # <<<<<<<<<<<<<<
 *         if self.self is None:
 *             return NULL
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py._PyObj.getname", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ctx);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_modname);
  __Pyx_XDECREF(__pyx_v_clsname);
  __Pyx_XDECREF(__pyx_v_cls);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":371
 *         return NULL
 * 
 * cdef createcontext(char name_p[]):             # <<<<<<<<<<<<<<
 *     if name_p == NULL: return None
 *     cdef name = bytes2str(name_p)
 */

static PyObject *__pyx_f_11libpetsc4py_createcontext(char *__pyx_v_name_p) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_mod = 0;
  PyObject *__pyx_v_path = 0;
  PyObject *__pyx_v_modname = 0;
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_attr = 0;
  PyObject *__pyx_v_clsname = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("createcontext", 0);

  /* "libpetsc4py.pyx":372
 * 
 * cdef createcontext(char name_p[]):
 *     if name_p == NULL: return None             # <<<<<<<<<<<<<<
 *     cdef name = bytes2str(name_p)
 *     cdef mod, path, modname=None
 */
  __pyx_t_1 = ((__pyx_v_name_p == NULL) != 0);
  if (__pyx_t_1) {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":373
 * cdef createcontext(char name_p[]):
 *     if name_p == NULL: return None
 *     cdef name = bytes2str(name_p)             # <<<<<<<<<<<<<<
 *     cdef mod, path, modname=None
 *     cdef cls, attr, clsname=None
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_bytes2str(__pyx_v_name_p); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_name = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":374
 *     if name_p == NULL: return None
 *     cdef name = bytes2str(name_p)
 *     cdef mod, path, modname=None             # <<<<<<<<<<<<<<
 *     cdef cls, attr, clsname=None
 *     # path/to/filename.py:{function|class}
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_modname = Py_None;

  /* "libpetsc4py.pyx":375
 *     cdef name = bytes2str(name_p)
 *     cdef mod, path, modname=None
 *     cdef cls, attr, clsname=None             # <<<<<<<<<<<<<<
 *     # path/to/filename.py:{function|class}
 *     if ':' in name:
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_clsname = Py_None;

  /* "libpetsc4py.pyx":377
 *     cdef cls, attr, clsname=None
 *     # path/to/filename.py:{function|class}
 *     if ':' in name:             # <<<<<<<<<<<<<<
 *         path, attr = parse_url(name)
 *         mod = load_module(path)
 */
  __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_kp_s_, __pyx_v_name, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 377, __pyx_L1_error)
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":378
 *     # path/to/filename.py:{function|class}
 *     if ':' in name:
 *         path, attr = parse_url(name)             # <<<<<<<<<<<<<<
 *         mod = load_module(path)
 *         if attr:
 */
    __pyx_t_2 = __pyx_f_11libpetsc4py_parse_url(__pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 378, __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_5 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
      index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) __PYX_ERR(0, 378, __pyx_L1_error)
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 378, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __pyx_v_path = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_v_attr = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "libpetsc4py.pyx":379
 *     if ':' in name:
 *         path, attr = parse_url(name)
 *         mod = load_module(path)             # <<<<<<<<<<<<<<
 *         if attr:
 *             cls = getattr(mod, attr)
 */
    __pyx_t_2 = __pyx_f_11libpetsc4py_load_module(__pyx_v_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_mod = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":380
 *         path, attr = parse_url(name)
 *         mod = load_module(path)
 *         if attr:             # <<<<<<<<<<<<<<
 *             cls = getattr(mod, attr)
 *             return cls()
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_attr); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 380, __pyx_L1_error)
    if (__pyx_t_3) {

      /* "libpetsc4py.pyx":381
 *         mod = load_module(path)
 *         if attr:
 *             cls = getattr(mod, attr)             # <<<<<<<<<<<<<<
 *             return cls()
 *         else:
 */
      __pyx_t_2 = __Pyx_GetAttr(__pyx_v_mod, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_cls = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "libpetsc4py.pyx":382
 *         if attr:
 *             cls = getattr(mod, attr)
 *             return cls()             # <<<<<<<<<<<<<<
 *         else:
 *             return mod
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_cls);
      __pyx_t_5 = __pyx_v_cls; __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_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 382, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

      /* "libpetsc4py.pyx":380
 *         path, attr = parse_url(name)
 *         mod = load_module(path)
 *         if attr:             # <<<<<<<<<<<<<<
 *             cls = getattr(mod, attr)
 *             return cls()
 */
    }

    /* "libpetsc4py.pyx":384
 *             return cls()
 *         else:
 *             return mod             # <<<<<<<<<<<<<<
 *     # package.module[.{function|class}]
 *     if '.' in name:
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_mod);
      __pyx_r = __pyx_v_mod;
      goto __pyx_L0;
    }

    /* "libpetsc4py.pyx":377
 *     cdef cls, attr, clsname=None
 *     # path/to/filename.py:{function|class}
 *     if ':' in name:             # <<<<<<<<<<<<<<
 *         path, attr = parse_url(name)
 *         mod = load_module(path)
 */
  }

  /* "libpetsc4py.pyx":386
 *             return mod
 *     # package.module[.{function|class}]
 *     if '.' in name:             # <<<<<<<<<<<<<<
 *         modname, clsname = name.rsplit('.', 1)
 *         mod = PyImport_Import(modname)
 */
  __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_kp_s__3, __pyx_v_name, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 386, __pyx_L1_error)
  __pyx_t_1 = (__pyx_t_3 != 0);
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":387
 *     # package.module[.{function|class}]
 *     if '.' in name:
 *         modname, clsname = name.rsplit('.', 1)             # <<<<<<<<<<<<<<
 *         mod = PyImport_Import(modname)
 *         if hasattr(mod, clsname):
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_rsplit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
      PyObject* sequence = __pyx_t_5;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 387, __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); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 387, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 387, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 387, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) __PYX_ERR(0, 387, __pyx_L1_error)
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L10_unpacking_done;
      __pyx_L9_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 387, __pyx_L1_error)
      __pyx_L10_unpacking_done:;
    }
    __Pyx_DECREF_SET(__pyx_v_modname, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_clsname, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "libpetsc4py.pyx":388
 *     if '.' in name:
 *         modname, clsname = name.rsplit('.', 1)
 *         mod = PyImport_Import(modname)             # <<<<<<<<<<<<<<
 *         if hasattr(mod, clsname):
 *             cls = getattr(mod, clsname)
 */
    __pyx_t_5 = PyImport_Import(__pyx_v_modname); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_v_mod = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "libpetsc4py.pyx":389
 *         modname, clsname = name.rsplit('.', 1)
 *         mod = PyImport_Import(modname)
 *         if hasattr(mod, clsname):             # <<<<<<<<<<<<<<
 *             cls = getattr(mod, clsname)
 *             if not PyModule_Check(cls):
 */
    __pyx_t_1 = __Pyx_HasAttr(__pyx_v_mod, __pyx_v_clsname); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 389, __pyx_L1_error)
    __pyx_t_3 = (__pyx_t_1 != 0);
    if (__pyx_t_3) {

      /* "libpetsc4py.pyx":390
 *         mod = PyImport_Import(modname)
 *         if hasattr(mod, clsname):
 *             cls = getattr(mod, clsname)             # <<<<<<<<<<<<<<
 *             if not PyModule_Check(cls):
 *                 return cls()
 */
      __pyx_t_5 = __Pyx_GetAttr(__pyx_v_mod, __pyx_v_clsname); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 390, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_v_cls = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "libpetsc4py.pyx":391
 *         if hasattr(mod, clsname):
 *             cls = getattr(mod, clsname)
 *             if not PyModule_Check(cls):             # <<<<<<<<<<<<<<
 *                 return cls()
 *     # package[.module]
 */
      __pyx_t_3 = ((!(PyModule_Check(__pyx_v_cls) != 0)) != 0);
      if (__pyx_t_3) {

        /* "libpetsc4py.pyx":392
 *             cls = getattr(mod, clsname)
 *             if not PyModule_Check(cls):
 *                 return cls()             # <<<<<<<<<<<<<<
 *     # package[.module]
 *     mod = PyImport_Import(name)
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_v_cls);
        __pyx_t_4 = __pyx_v_cls; __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_5 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 392, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_r = __pyx_t_5;
        __pyx_t_5 = 0;
        goto __pyx_L0;

        /* "libpetsc4py.pyx":391
 *         if hasattr(mod, clsname):
 *             cls = getattr(mod, clsname)
 *             if not PyModule_Check(cls):             # <<<<<<<<<<<<<<
 *                 return cls()
 *     # package[.module]
 */
      }

      /* "libpetsc4py.pyx":389
 *         modname, clsname = name.rsplit('.', 1)
 *         mod = PyImport_Import(modname)
 *         if hasattr(mod, clsname):             # <<<<<<<<<<<<<<
 *             cls = getattr(mod, clsname)
 *             if not PyModule_Check(cls):
 */
    }

    /* "libpetsc4py.pyx":386
 *             return mod
 *     # package.module[.{function|class}]
 *     if '.' in name:             # <<<<<<<<<<<<<<
 *         modname, clsname = name.rsplit('.', 1)
 *         mod = PyImport_Import(modname)
 */
  }

  /* "libpetsc4py.pyx":394
 *                 return cls()
 *     # package[.module]
 *     mod = PyImport_Import(name)             # <<<<<<<<<<<<<<
 *     return mod
 * 
 */
  __pyx_t_5 = PyImport_Import(__pyx_v_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF_SET(__pyx_v_mod, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "libpetsc4py.pyx":395
 *     # package[.module]
 *     mod = PyImport_Import(name)
 *     return mod             # <<<<<<<<<<<<<<
 * 
 * cdef int viewcontext(_PyObj ctx, PetscViewer viewer) except -1:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_mod);
  __pyx_r = __pyx_v_mod;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":371
 *         return NULL
 * 
 * cdef createcontext(char name_p[]):             # <<<<<<<<<<<<<<
 *     if name_p == NULL: return None
 *     cdef name = bytes2str(name_p)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.createcontext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_mod);
  __Pyx_XDECREF(__pyx_v_path);
  __Pyx_XDECREF(__pyx_v_modname);
  __Pyx_XDECREF(__pyx_v_cls);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF(__pyx_v_clsname);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":397
 *     return mod
 * 
 * cdef int viewcontext(_PyObj ctx, PetscViewer viewer) except -1:             # <<<<<<<<<<<<<<
 *     cdef PetscBool isascii = PETSC_FALSE, isstring = PETSC_FALSE
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERASCII,  &isascii)  )
 */

static int __pyx_f_11libpetsc4py_viewcontext(struct __pyx_obj_11libpetsc4py__PyObj *__pyx_v_ctx, PetscViewer __pyx_v_viewer) {
  PetscBool __pyx_v_isascii;
  PetscBool __pyx_v_isstring;
  char *__pyx_v_name;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  char *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("viewcontext", 0);

  /* "libpetsc4py.pyx":398
 * 
 * cdef int viewcontext(_PyObj ctx, PetscViewer viewer) except -1:
 *     cdef PetscBool isascii = PETSC_FALSE, isstring = PETSC_FALSE             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERASCII,  &isascii)  )
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERSTRING, &isstring) )
 */
  __pyx_v_isascii = PETSC_FALSE;
  __pyx_v_isstring = PETSC_FALSE;

  /* "libpetsc4py.pyx":399
 * cdef int viewcontext(_PyObj ctx, PetscViewer viewer) except -1:
 *     cdef PetscBool isascii = PETSC_FALSE, isstring = PETSC_FALSE
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERASCII,  &isascii)  )             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERSTRING, &isstring) )
 *     cdef char *name = ctx.getname()
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectTypeCompare(((PetscObject)__pyx_v_viewer), PETSCVIEWERASCII, (&__pyx_v_isascii))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 399, __pyx_L1_error)

  /* "libpetsc4py.pyx":400
 *     cdef PetscBool isascii = PETSC_FALSE, isstring = PETSC_FALSE
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERASCII,  &isascii)  )
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERSTRING, &isstring) )             # <<<<<<<<<<<<<<
 *     cdef char *name = ctx.getname()
 *     if isascii:
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectTypeCompare(((PetscObject)__pyx_v_viewer), PETSCVIEWERSTRING, (&__pyx_v_isstring))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 400, __pyx_L1_error)

  /* "libpetsc4py.pyx":401
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERASCII,  &isascii)  )
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERSTRING, &isstring) )
 *     cdef char *name = ctx.getname()             # <<<<<<<<<<<<<<
 *     if isascii:
 *         if name == NULL: name = b"unknown/no yet set"
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_11libpetsc4py__PyObj *)__pyx_v_ctx->__pyx_vtab)->getname(__pyx_v_ctx); if (unlikely(__pyx_t_2 == ((char *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L1_error)
  __pyx_v_name = __pyx_t_2;

  /* "libpetsc4py.pyx":402
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERSTRING, &isstring) )
 *     cdef char *name = ctx.getname()
 *     if isascii:             # <<<<<<<<<<<<<<
 *         if name == NULL: name = b"unknown/no yet set"
 *         CHKERR( PetscViewerASCIIPrintf(viewer, b"  Python: %s\n", name) )
 */
  if (__pyx_v_isascii) {

    /* "libpetsc4py.pyx":403
 *     cdef char *name = ctx.getname()
 *     if isascii:
 *         if name == NULL: name = b"unknown/no yet set"             # <<<<<<<<<<<<<<
 *         CHKERR( PetscViewerASCIIPrintf(viewer, b"  Python: %s\n", name) )
 *     if isstring:
 */
    __pyx_t_3 = ((__pyx_v_name == NULL) != 0);
    if (__pyx_t_3) {
      __pyx_v_name = ((char *)"unknown/no yet set");
    }

    /* "libpetsc4py.pyx":404
 *     if isascii:
 *         if name == NULL: name = b"unknown/no yet set"
 *         CHKERR( PetscViewerASCIIPrintf(viewer, b"  Python: %s\n", name) )             # <<<<<<<<<<<<<<
 *     if isstring:
 *         if name == NULL: name = b"<unknown>"
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscViewerASCIIPrintf(__pyx_v_viewer, ((char *)"  Python: %s\n"), __pyx_v_name)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 404, __pyx_L1_error)

    /* "libpetsc4py.pyx":402
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERSTRING, &isstring) )
 *     cdef char *name = ctx.getname()
 *     if isascii:             # <<<<<<<<<<<<<<
 *         if name == NULL: name = b"unknown/no yet set"
 *         CHKERR( PetscViewerASCIIPrintf(viewer, b"  Python: %s\n", name) )
 */
  }

  /* "libpetsc4py.pyx":405
 *         if name == NULL: name = b"unknown/no yet set"
 *         CHKERR( PetscViewerASCIIPrintf(viewer, b"  Python: %s\n", name) )
 *     if isstring:             # <<<<<<<<<<<<<<
 *         if name == NULL: name = b"<unknown>"
 *         CHKERR( PetscViewerStringSPrintf(viewer,"%s", name) )
 */
  if (__pyx_v_isstring) {

    /* "libpetsc4py.pyx":406
 *         CHKERR( PetscViewerASCIIPrintf(viewer, b"  Python: %s\n", name) )
 *     if isstring:
 *         if name == NULL: name = b"<unknown>"             # <<<<<<<<<<<<<<
 *         CHKERR( PetscViewerStringSPrintf(viewer,"%s", name) )
 *     return 0
 */
    __pyx_t_3 = ((__pyx_v_name == NULL) != 0);
    if (__pyx_t_3) {
      __pyx_v_name = ((char *)"<unknown>");
    }

    /* "libpetsc4py.pyx":407
 *     if isstring:
 *         if name == NULL: name = b"<unknown>"
 *         CHKERR( PetscViewerStringSPrintf(viewer,"%s", name) )             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscViewerStringSPrintf(__pyx_v_viewer, ((char *)"%s"), __pyx_v_name)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 407, __pyx_L1_error)

    /* "libpetsc4py.pyx":405
 *         if name == NULL: name = b"unknown/no yet set"
 *         CHKERR( PetscViewerASCIIPrintf(viewer, b"  Python: %s\n", name) )
 *     if isstring:             # <<<<<<<<<<<<<<
 *         if name == NULL: name = b"<unknown>"
 *         CHKERR( PetscViewerStringSPrintf(viewer,"%s", name) )
 */
  }

  /* "libpetsc4py.pyx":408
 *         if name == NULL: name = b"<unknown>"
 *         CHKERR( PetscViewerStringSPrintf(viewer,"%s", name) )
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":397
 *     return mod
 * 
 * cdef int viewcontext(_PyObj ctx, PetscViewer viewer) except -1:             # <<<<<<<<<<<<<<
 *     cdef PetscBool isascii = PETSC_FALSE, isstring = PETSC_FALSE
 *     CHKERR( PetscObjectTypeCompare(<PetscObject>viewer, PETSCVIEWERASCII,  &isascii)  )
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.viewcontext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":528
 * @cython.internal
 * cdef class _PyMat(_PyObj): pass
 * cdef inline _PyMat PyMat(PetscMat mat):             # <<<<<<<<<<<<<<
 *     if mat != NULL and mat.data != NULL:
 *         return <_PyMat>mat.data
 */

static CYTHON_INLINE struct __pyx_obj_11libpetsc4py__PyMat *__pyx_f_11libpetsc4py_PyMat(Mat __pyx_v_mat) {
  struct __pyx_obj_11libpetsc4py__PyMat *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyMat", 0);

  /* "libpetsc4py.pyx":529
 * cdef class _PyMat(_PyObj): pass
 * cdef inline _PyMat PyMat(PetscMat mat):
 *     if mat != NULL and mat.data != NULL:             # <<<<<<<<<<<<<<
 *         return <_PyMat>mat.data
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_mat != NULL) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_mat->data != NULL) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":530
 * cdef inline _PyMat PyMat(PetscMat mat):
 *     if mat != NULL and mat.data != NULL:
 *         return <_PyMat>mat.data             # <<<<<<<<<<<<<<
 *     else:
 *         return _PyMat.__new__(_PyMat)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_11libpetsc4py__PyMat *)__pyx_v_mat->data)));
    __pyx_r = ((struct __pyx_obj_11libpetsc4py__PyMat *)__pyx_v_mat->data);
    goto __pyx_L0;

    /* "libpetsc4py.pyx":529
 * cdef class _PyMat(_PyObj): pass
 * cdef inline _PyMat PyMat(PetscMat mat):
 *     if mat != NULL and mat.data != NULL:             # <<<<<<<<<<<<<<
 *         return <_PyMat>mat.data
 *     else:
 */
  }

  /* "libpetsc4py.pyx":532
 *         return <_PyMat>mat.data
 *     else:
 *         return _PyMat.__new__(_PyMat)             # <<<<<<<<<<<<<<
 * 
 * cdef public PetscErrorCode MatPythonGetContext(PetscMat mat, void **ctx) \
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_3 = ((PyObject *)__pyx_tp_new_11libpetsc4py__PyMat(((PyTypeObject *)__pyx_ptype_11libpetsc4py__PyMat), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error)
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_r = ((struct __pyx_obj_11libpetsc4py__PyMat *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":528
 * @cython.internal
 * cdef class _PyMat(_PyObj): pass
 * cdef inline _PyMat PyMat(PetscMat mat):             # <<<<<<<<<<<<<<
 *     if mat != NULL and mat.data != NULL:
 *         return <_PyMat>mat.data
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libpetsc4py.PyMat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":534
 *         return _PyMat.__new__(_PyMat)
 * 
 * cdef public PetscErrorCode MatPythonGetContext(PetscMat mat, void **ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"MatPythonGetContext")
 */

PetscErrorCode MatPythonGetContext(Mat __pyx_v_mat, void **__pyx_v_ctx) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("MatPythonGetContext", 0);

  /* "libpetsc4py.pyx":536
 * cdef public PetscErrorCode MatPythonGetContext(PetscMat mat, void **ctx) \
 *     except IERR:
 *     FunctionBegin(b"MatPythonGetContext")             # <<<<<<<<<<<<<<
 *     PyMat(mat).getcontext(ctx)
 *     return FunctionEnd()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatPythonGetContext"));

  /* "libpetsc4py.pyx":537
 *     except IERR:
 *     FunctionBegin(b"MatPythonGetContext")
 *     PyMat(mat).getcontext(ctx)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 537, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_11libpetsc4py__PyMat *)((struct __pyx_obj_11libpetsc4py__PyMat *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.getcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_ctx); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 537, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":538
 *     FunctionBegin(b"MatPythonGetContext")
 *     PyMat(mat).getcontext(ctx)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef public PetscErrorCode MatPythonSetContext(PetscMat mat, void *ctx) \
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":534
 *         return _PyMat.__new__(_PyMat)
 * 
 * cdef public PetscErrorCode MatPythonGetContext(PetscMat mat, void **ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"MatPythonGetContext")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.MatPythonGetContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":540
 *     return FunctionEnd()
 * 
 * cdef public PetscErrorCode MatPythonSetContext(PetscMat mat, void *ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"MatPythonSetContext")
 */

PetscErrorCode MatPythonSetContext(Mat __pyx_v_mat, void *__pyx_v_ctx) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("MatPythonSetContext", 0);

  /* "libpetsc4py.pyx":542
 * cdef public PetscErrorCode MatPythonSetContext(PetscMat mat, void *ctx) \
 *     except IERR:
 *     FunctionBegin(b"MatPythonSetContext")             # <<<<<<<<<<<<<<
 *     PyMat(mat).setcontext(ctx, Mat_(mat))
 *     return FunctionEnd()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatPythonSetContext"));

  /* "libpetsc4py.pyx":543
 *     except IERR:
 *     FunctionBegin(b"MatPythonSetContext")
 *     PyMat(mat).setcontext(ctx, Mat_(mat))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((struct __pyx_vtabstruct_11libpetsc4py__PyMat *)((struct __pyx_obj_11libpetsc4py__PyMat *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.setcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_ctx, ((struct PyPetscObjectObject *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":544
 *     FunctionBegin(b"MatPythonSetContext")
 *     PyMat(mat).setcontext(ctx, Mat_(mat))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatPythonSetType_PYTHON(PetscMat mat, char name[]) \
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":540
 *     return FunctionEnd()
 * 
 * cdef public PetscErrorCode MatPythonSetContext(PetscMat mat, void *ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"MatPythonSetContext")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.MatPythonSetContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":546
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatPythonSetType_PYTHON(PetscMat mat, char name[]) \             # <<<<<<<<<<<<<<
 *     except IERR with gil:
 *     FunctionBegin(b"MatPythonSetType_PYTHON")
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatPythonSetType_PYTHON(Mat __pyx_v_mat, char *__pyx_v_name) {
  PyObject *__pyx_v_ctx = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PetscErrorCode __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatPythonSetType_PYTHON", 0);

  /* "libpetsc4py.pyx":548
 * cdef PetscErrorCode MatPythonSetType_PYTHON(PetscMat mat, char name[]) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatPythonSetType_PYTHON")             # <<<<<<<<<<<<<<
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatPythonSetType_PYTHON"));

  /* "libpetsc4py.pyx":549
 *     except IERR with gil:
 *     FunctionBegin(b"MatPythonSetType_PYTHON")
 *     if name == NULL: return FunctionEnd() # XXX             # <<<<<<<<<<<<<<
 *     cdef object ctx = createcontext(name)
 *     MatPythonSetContext(mat, <void*>ctx)
 */
  __pyx_t_1 = ((__pyx_v_name == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":550
 *     FunctionBegin(b"MatPythonSetType_PYTHON")
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)             # <<<<<<<<<<<<<<
 *     MatPythonSetContext(mat, <void*>ctx)
 *     PyMat(mat).setname(name)
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_createcontext(__pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_ctx = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":551
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)
 *     MatPythonSetContext(mat, <void*>ctx)             # <<<<<<<<<<<<<<
 *     PyMat(mat).setname(name)
 *     return FunctionEnd()
 */
  __pyx_t_3 = MatPythonSetContext(__pyx_v_mat, ((void *)__pyx_v_ctx)); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 551, __pyx_L1_error)

  /* "libpetsc4py.pyx":552
 *     cdef object ctx = createcontext(name)
 *     MatPythonSetContext(mat, <void*>ctx)
 *     PyMat(mat).setname(name)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = ((struct __pyx_vtabstruct_11libpetsc4py__PyMat *)((struct __pyx_obj_11libpetsc4py__PyMat *)__pyx_t_2)->__pyx_base.__pyx_vtab)->__pyx_base.setname(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_2), __pyx_v_name); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":553
 *     MatPythonSetContext(mat, <void*>ctx)
 *     PyMat(mat).setname(name)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatCreate_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":546
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatPythonSetType_PYTHON(PetscMat mat, char name[]) \             # <<<<<<<<<<<<<<
 *     except IERR with gil:
 *     FunctionBegin(b"MatPythonSetType_PYTHON")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.MatPythonSetType_PYTHON", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ctx);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":555
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatCreate_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatCreate_Python(Mat __pyx_v_mat) {
  MatOps __pyx_v_ops;
  PyObject *__pyx_v_ctx = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  MatOps __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatCreate_Python", 0);

  /* "libpetsc4py.pyx":559
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatCreate_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef MatOps ops       = mat.ops
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatCreate_Python"));

  /* "libpetsc4py.pyx":561
 *     FunctionBegin(b"MatCreate_Python")
 *     #
 *     cdef MatOps ops       = mat.ops             # <<<<<<<<<<<<<<
 *     ops.destroy           = MatDestroy_Python
 *     ops.setfromoptions    = MatSetFromOptions_Python
 */
  __pyx_t_1 = __pyx_v_mat->ops;
  __pyx_v_ops = __pyx_t_1;

  /* "libpetsc4py.pyx":562
 *     #
 *     cdef MatOps ops       = mat.ops
 *     ops.destroy           = MatDestroy_Python             # <<<<<<<<<<<<<<
 *     ops.setfromoptions    = MatSetFromOptions_Python
 *     ops.view              = MatView_Python
 */
  __pyx_v_ops->destroy = __pyx_f_11libpetsc4py_MatDestroy_Python;

  /* "libpetsc4py.pyx":563
 *     cdef MatOps ops       = mat.ops
 *     ops.destroy           = MatDestroy_Python
 *     ops.setfromoptions    = MatSetFromOptions_Python             # <<<<<<<<<<<<<<
 *     ops.view              = MatView_Python
 *     ops.duplicate         = MatDuplicate_Python
 */
  __pyx_v_ops->setfromoptions = __pyx_f_11libpetsc4py_MatSetFromOptions_Python;

  /* "libpetsc4py.pyx":564
 *     ops.destroy           = MatDestroy_Python
 *     ops.setfromoptions    = MatSetFromOptions_Python
 *     ops.view              = MatView_Python             # <<<<<<<<<<<<<<
 *     ops.duplicate         = MatDuplicate_Python
 *     ops.copy              = MatCopy_Python
 */
  __pyx_v_ops->view = __pyx_f_11libpetsc4py_MatView_Python;

  /* "libpetsc4py.pyx":565
 *     ops.setfromoptions    = MatSetFromOptions_Python
 *     ops.view              = MatView_Python
 *     ops.duplicate         = MatDuplicate_Python             # <<<<<<<<<<<<<<
 *     ops.copy              = MatCopy_Python
 *     ops.createsubmatrix   = MatCreateSubMatrix_Python
 */
  __pyx_v_ops->duplicate = __pyx_f_11libpetsc4py_MatDuplicate_Python;

  /* "libpetsc4py.pyx":566
 *     ops.view              = MatView_Python
 *     ops.duplicate         = MatDuplicate_Python
 *     ops.copy              = MatCopy_Python             # <<<<<<<<<<<<<<
 *     ops.createsubmatrix   = MatCreateSubMatrix_Python
 *     ops.setoption         = MatSetOption_Python
 */
  __pyx_v_ops->copy = __pyx_f_11libpetsc4py_MatCopy_Python;

  /* "libpetsc4py.pyx":567
 *     ops.duplicate         = MatDuplicate_Python
 *     ops.copy              = MatCopy_Python
 *     ops.createsubmatrix   = MatCreateSubMatrix_Python             # <<<<<<<<<<<<<<
 *     ops.setoption         = MatSetOption_Python
 *     ops.setup             = MatSetUp_Python
 */
  __pyx_v_ops->createsubmatrix = __pyx_f_11libpetsc4py_MatCreateSubMatrix_Python;

  /* "libpetsc4py.pyx":568
 *     ops.copy              = MatCopy_Python
 *     ops.createsubmatrix   = MatCreateSubMatrix_Python
 *     ops.setoption         = MatSetOption_Python             # <<<<<<<<<<<<<<
 *     ops.setup             = MatSetUp_Python
 *     ops.assemblybegin     = MatAssemblyBegin_Python
 */
  __pyx_v_ops->setoption = __pyx_f_11libpetsc4py_MatSetOption_Python;

  /* "libpetsc4py.pyx":569
 *     ops.createsubmatrix   = MatCreateSubMatrix_Python
 *     ops.setoption         = MatSetOption_Python
 *     ops.setup             = MatSetUp_Python             # <<<<<<<<<<<<<<
 *     ops.assemblybegin     = MatAssemblyBegin_Python
 *     ops.assemblyend       = MatAssemblyEnd_Python
 */
  __pyx_v_ops->setup = __pyx_f_11libpetsc4py_MatSetUp_Python;

  /* "libpetsc4py.pyx":570
 *     ops.setoption         = MatSetOption_Python
 *     ops.setup             = MatSetUp_Python
 *     ops.assemblybegin     = MatAssemblyBegin_Python             # <<<<<<<<<<<<<<
 *     ops.assemblyend       = MatAssemblyEnd_Python
 *     ops.zeroentries       = MatZeroEntries_Python
 */
  __pyx_v_ops->assemblybegin = __pyx_f_11libpetsc4py_MatAssemblyBegin_Python;

  /* "libpetsc4py.pyx":571
 *     ops.setup             = MatSetUp_Python
 *     ops.assemblybegin     = MatAssemblyBegin_Python
 *     ops.assemblyend       = MatAssemblyEnd_Python             # <<<<<<<<<<<<<<
 *     ops.zeroentries       = MatZeroEntries_Python
 *     ops.zerorowscolumns   = MatZeroRowsColumns_Python
 */
  __pyx_v_ops->assemblyend = __pyx_f_11libpetsc4py_MatAssemblyEnd_Python;

  /* "libpetsc4py.pyx":572
 *     ops.assemblybegin     = MatAssemblyBegin_Python
 *     ops.assemblyend       = MatAssemblyEnd_Python
 *     ops.zeroentries       = MatZeroEntries_Python             # <<<<<<<<<<<<<<
 *     ops.zerorowscolumns   = MatZeroRowsColumns_Python
 *     ops.scale             = MatScale_Python
 */
  __pyx_v_ops->zeroentries = __pyx_f_11libpetsc4py_MatZeroEntries_Python;

  /* "libpetsc4py.pyx":573
 *     ops.assemblyend       = MatAssemblyEnd_Python
 *     ops.zeroentries       = MatZeroEntries_Python
 *     ops.zerorowscolumns   = MatZeroRowsColumns_Python             # <<<<<<<<<<<<<<
 *     ops.scale             = MatScale_Python
 *     ops.shift             = MatShift_Python
 */
  __pyx_v_ops->zerorowscolumns = __pyx_f_11libpetsc4py_MatZeroRowsColumns_Python;

  /* "libpetsc4py.pyx":574
 *     ops.zeroentries       = MatZeroEntries_Python
 *     ops.zerorowscolumns   = MatZeroRowsColumns_Python
 *     ops.scale             = MatScale_Python             # <<<<<<<<<<<<<<
 *     ops.shift             = MatShift_Python
 *     ops.getvecs           = MatCreateVecs_Python
 */
  __pyx_v_ops->scale = __pyx_f_11libpetsc4py_MatScale_Python;

  /* "libpetsc4py.pyx":575
 *     ops.zerorowscolumns   = MatZeroRowsColumns_Python
 *     ops.scale             = MatScale_Python
 *     ops.shift             = MatShift_Python             # <<<<<<<<<<<<<<
 *     ops.getvecs           = MatCreateVecs_Python
 *     ops.mult              = MatMult_Python
 */
  __pyx_v_ops->shift = __pyx_f_11libpetsc4py_MatShift_Python;

  /* "libpetsc4py.pyx":576
 *     ops.scale             = MatScale_Python
 *     ops.shift             = MatShift_Python
 *     ops.getvecs           = MatCreateVecs_Python             # <<<<<<<<<<<<<<
 *     ops.mult              = MatMult_Python
 *     ops.sor               = MatSOR_Python
 */
  __pyx_v_ops->getvecs = __pyx_f_11libpetsc4py_MatCreateVecs_Python;

  /* "libpetsc4py.pyx":577
 *     ops.shift             = MatShift_Python
 *     ops.getvecs           = MatCreateVecs_Python
 *     ops.mult              = MatMult_Python             # <<<<<<<<<<<<<<
 *     ops.sor               = MatSOR_Python
 *     ops.multtranspose     = MatMultTranspose_Python
 */
  __pyx_v_ops->mult = __pyx_f_11libpetsc4py_MatMult_Python;

  /* "libpetsc4py.pyx":578
 *     ops.getvecs           = MatCreateVecs_Python
 *     ops.mult              = MatMult_Python
 *     ops.sor               = MatSOR_Python             # <<<<<<<<<<<<<<
 *     ops.multtranspose     = MatMultTranspose_Python
 *     ops.multhermitian     = MatMultHermitian_Python
 */
  __pyx_v_ops->sor = __pyx_f_11libpetsc4py_MatSOR_Python;

  /* "libpetsc4py.pyx":579
 *     ops.mult              = MatMult_Python
 *     ops.sor               = MatSOR_Python
 *     ops.multtranspose     = MatMultTranspose_Python             # <<<<<<<<<<<<<<
 *     ops.multhermitian     = MatMultHermitian_Python
 *     ops.multadd           = MatMultAdd_Python
 */
  __pyx_v_ops->multtranspose = __pyx_f_11libpetsc4py_MatMultTranspose_Python;

  /* "libpetsc4py.pyx":580
 *     ops.sor               = MatSOR_Python
 *     ops.multtranspose     = MatMultTranspose_Python
 *     ops.multhermitian     = MatMultHermitian_Python             # <<<<<<<<<<<<<<
 *     ops.multadd           = MatMultAdd_Python
 *     ops.multtransposeadd  = MatMultTransposeAdd_Python
 */
  __pyx_v_ops->multhermitiantranspose = __pyx_f_11libpetsc4py_MatMultHermitian_Python;

  /* "libpetsc4py.pyx":581
 *     ops.multtranspose     = MatMultTranspose_Python
 *     ops.multhermitian     = MatMultHermitian_Python
 *     ops.multadd           = MatMultAdd_Python             # <<<<<<<<<<<<<<
 *     ops.multtransposeadd  = MatMultTransposeAdd_Python
 *     ops.multhermitianadd  = MatMultHermitianAdd_Python
 */
  __pyx_v_ops->multadd = __pyx_f_11libpetsc4py_MatMultAdd_Python;

  /* "libpetsc4py.pyx":582
 *     ops.multhermitian     = MatMultHermitian_Python
 *     ops.multadd           = MatMultAdd_Python
 *     ops.multtransposeadd  = MatMultTransposeAdd_Python             # <<<<<<<<<<<<<<
 *     ops.multhermitianadd  = MatMultHermitianAdd_Python
 *     ops.multdiagonalblock = MatMultDiagonalBlock_Python
 */
  __pyx_v_ops->multtransposeadd = __pyx_f_11libpetsc4py_MatMultTransposeAdd_Python;

  /* "libpetsc4py.pyx":583
 *     ops.multadd           = MatMultAdd_Python
 *     ops.multtransposeadd  = MatMultTransposeAdd_Python
 *     ops.multhermitianadd  = MatMultHermitianAdd_Python             # <<<<<<<<<<<<<<
 *     ops.multdiagonalblock = MatMultDiagonalBlock_Python
 *     ops.solve             = MatSolve_Python
 */
  __pyx_v_ops->multhermitiantransposeadd = __pyx_f_11libpetsc4py_MatMultHermitianAdd_Python;

  /* "libpetsc4py.pyx":584
 *     ops.multtransposeadd  = MatMultTransposeAdd_Python
 *     ops.multhermitianadd  = MatMultHermitianAdd_Python
 *     ops.multdiagonalblock = MatMultDiagonalBlock_Python             # <<<<<<<<<<<<<<
 *     ops.solve             = MatSolve_Python
 *     ops.solvetranspose    = MatSolveTranspose_Python
 */
  __pyx_v_ops->multdiagonalblock = __pyx_f_11libpetsc4py_MatMultDiagonalBlock_Python;

  /* "libpetsc4py.pyx":585
 *     ops.multhermitianadd  = MatMultHermitianAdd_Python
 *     ops.multdiagonalblock = MatMultDiagonalBlock_Python
 *     ops.solve             = MatSolve_Python             # <<<<<<<<<<<<<<
 *     ops.solvetranspose    = MatSolveTranspose_Python
 *     ops.solveadd          = MatSolveAdd_Python
 */
  __pyx_v_ops->solve = __pyx_f_11libpetsc4py_MatSolve_Python;

  /* "libpetsc4py.pyx":586
 *     ops.multdiagonalblock = MatMultDiagonalBlock_Python
 *     ops.solve             = MatSolve_Python
 *     ops.solvetranspose    = MatSolveTranspose_Python             # <<<<<<<<<<<<<<
 *     ops.solveadd          = MatSolveAdd_Python
 *     ops.solvetransposeadd = MatSolveTransposeAdd_Python
 */
  __pyx_v_ops->solvetranspose = __pyx_f_11libpetsc4py_MatSolveTranspose_Python;

  /* "libpetsc4py.pyx":587
 *     ops.solve             = MatSolve_Python
 *     ops.solvetranspose    = MatSolveTranspose_Python
 *     ops.solveadd          = MatSolveAdd_Python             # <<<<<<<<<<<<<<
 *     ops.solvetransposeadd = MatSolveTransposeAdd_Python
 *     ops.getdiagonal       = MatGetDiagonal_Python
 */
  __pyx_v_ops->solveadd = __pyx_f_11libpetsc4py_MatSolveAdd_Python;

  /* "libpetsc4py.pyx":588
 *     ops.solvetranspose    = MatSolveTranspose_Python
 *     ops.solveadd          = MatSolveAdd_Python
 *     ops.solvetransposeadd = MatSolveTransposeAdd_Python             # <<<<<<<<<<<<<<
 *     ops.getdiagonal       = MatGetDiagonal_Python
 *     ops.setdiagonal       = MatSetDiagonal_Python
 */
  __pyx_v_ops->solvetransposeadd = __pyx_f_11libpetsc4py_MatSolveTransposeAdd_Python;

  /* "libpetsc4py.pyx":589
 *     ops.solveadd          = MatSolveAdd_Python
 *     ops.solvetransposeadd = MatSolveTransposeAdd_Python
 *     ops.getdiagonal       = MatGetDiagonal_Python             # <<<<<<<<<<<<<<
 *     ops.setdiagonal       = MatSetDiagonal_Python
 *     ops.diagonalscale     = MatDiagonalScale_Python
 */
  __pyx_v_ops->getdiagonal = __pyx_f_11libpetsc4py_MatGetDiagonal_Python;

  /* "libpetsc4py.pyx":590
 *     ops.solvetransposeadd = MatSolveTransposeAdd_Python
 *     ops.getdiagonal       = MatGetDiagonal_Python
 *     ops.setdiagonal       = MatSetDiagonal_Python             # <<<<<<<<<<<<<<
 *     ops.diagonalscale     = MatDiagonalScale_Python
 *     ops.missingdiagonal   = MatMissingDiagonal_Python
 */
  __pyx_v_ops->diagonalset = __pyx_f_11libpetsc4py_MatSetDiagonal_Python;

  /* "libpetsc4py.pyx":591
 *     ops.getdiagonal       = MatGetDiagonal_Python
 *     ops.setdiagonal       = MatSetDiagonal_Python
 *     ops.diagonalscale     = MatDiagonalScale_Python             # <<<<<<<<<<<<<<
 *     ops.missingdiagonal   = MatMissingDiagonal_Python
 *     ops.norm              = MatNorm_Python
 */
  __pyx_v_ops->diagonalscale = __pyx_f_11libpetsc4py_MatDiagonalScale_Python;

  /* "libpetsc4py.pyx":592
 *     ops.setdiagonal       = MatSetDiagonal_Python
 *     ops.diagonalscale     = MatDiagonalScale_Python
 *     ops.missingdiagonal   = MatMissingDiagonal_Python             # <<<<<<<<<<<<<<
 *     ops.norm              = MatNorm_Python
 *     ops.realpart          = MatRealPart_Python
 */
  __pyx_v_ops->missingdiagonal = __pyx_f_11libpetsc4py_MatMissingDiagonal_Python;

  /* "libpetsc4py.pyx":593
 *     ops.diagonalscale     = MatDiagonalScale_Python
 *     ops.missingdiagonal   = MatMissingDiagonal_Python
 *     ops.norm              = MatNorm_Python             # <<<<<<<<<<<<<<
 *     ops.realpart          = MatRealPart_Python
 *     ops.imagpart          = MatImagPart_Python
 */
  __pyx_v_ops->norm = __pyx_f_11libpetsc4py_MatNorm_Python;

  /* "libpetsc4py.pyx":594
 *     ops.missingdiagonal   = MatMissingDiagonal_Python
 *     ops.norm              = MatNorm_Python
 *     ops.realpart          = MatRealPart_Python             # <<<<<<<<<<<<<<
 *     ops.imagpart          = MatImagPart_Python
 *     ops.conjugate         = MatConjugate_Python
 */
  __pyx_v_ops->realpart = __pyx_f_11libpetsc4py_MatRealPart_Python;

  /* "libpetsc4py.pyx":595
 *     ops.norm              = MatNorm_Python
 *     ops.realpart          = MatRealPart_Python
 *     ops.imagpart          = MatImagPart_Python             # <<<<<<<<<<<<<<
 *     ops.conjugate         = MatConjugate_Python
 *     #
 */
  __pyx_v_ops->imaginarypart = __pyx_f_11libpetsc4py_MatImagPart_Python;

  /* "libpetsc4py.pyx":596
 *     ops.realpart          = MatRealPart_Python
 *     ops.imagpart          = MatImagPart_Python
 *     ops.conjugate         = MatConjugate_Python             # <<<<<<<<<<<<<<
 *     #
 *     mat.assembled    = PETSC_TRUE  # XXX
 */
  __pyx_v_ops->conjugate = __pyx_f_11libpetsc4py_MatConjugate_Python;

  /* "libpetsc4py.pyx":598
 *     ops.conjugate         = MatConjugate_Python
 *     #
 *     mat.assembled    = PETSC_TRUE  # XXX             # <<<<<<<<<<<<<<
 *     mat.preallocated = PETSC_FALSE # XXX
 *     #
 */
  __pyx_v_mat->assembled = PETSC_TRUE;

  /* "libpetsc4py.pyx":599
 *     #
 *     mat.assembled    = PETSC_TRUE  # XXX
 *     mat.preallocated = PETSC_FALSE # XXX             # <<<<<<<<<<<<<<
 *     #
 *     CHKERR( PetscObjectComposeFunction(
 */
  __pyx_v_mat->preallocated = PETSC_FALSE;

  /* "libpetsc4py.pyx":601
 *     mat.preallocated = PETSC_FALSE # XXX
 *     #
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>mat,b"MatGetDiagonalBlock_C",
 *             <PetscVoidFunction>MatGetDiagonalBlock_Python) )
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_mat), ((char *)"MatGetDiagonalBlock_C"), ((PetscVoidFunction)__pyx_f_11libpetsc4py_MatGetDiagonalBlock_Python))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 601, __pyx_L1_error)

  /* "libpetsc4py.pyx":604
 *             <PetscObject>mat,b"MatGetDiagonalBlock_C",
 *             <PetscVoidFunction>MatGetDiagonalBlock_Python) )
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>mat,b"MatPythonSetType_C",
 *             <PetscVoidFunction>MatPythonSetType_PYTHON) )
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_mat), ((char *)"MatPythonSetType_C"), ((PetscVoidFunction)__pyx_f_11libpetsc4py_MatPythonSetType_PYTHON))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 604, __pyx_L1_error)

  /* "libpetsc4py.pyx":607
 *             <PetscObject>mat,b"MatPythonSetType_C",
 *             <PetscVoidFunction>MatPythonSetType_PYTHON) )
 *     CHKERR( PetscObjectChangeTypeName(             # <<<<<<<<<<<<<<
 *             <PetscObject>mat,MATPYTHON) )
 *     #
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectChangeTypeName(((PetscObject)__pyx_v_mat), "python")); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 607, __pyx_L1_error)

  /* "libpetsc4py.pyx":610
 *             <PetscObject>mat,MATPYTHON) )
 *     #
 *     cdef ctx = PyMat(NULL)             # <<<<<<<<<<<<<<
 *     mat.data = <void*> ctx
 *     Py_INCREF(<PyObject*>mat.data)
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ctx = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":611
 *     #
 *     cdef ctx = PyMat(NULL)
 *     mat.data = <void*> ctx             # <<<<<<<<<<<<<<
 *     Py_INCREF(<PyObject*>mat.data)
 *     return FunctionEnd()
 */
  __pyx_v_mat->data = ((void *)__pyx_v_ctx);

  /* "libpetsc4py.pyx":612
 *     cdef ctx = PyMat(NULL)
 *     mat.data = <void*> ctx
 *     Py_INCREF(<PyObject*>mat.data)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_mat->data));

  /* "libpetsc4py.pyx":613
 *     mat.data = <void*> ctx
 *     Py_INCREF(<PyObject*>mat.data)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatDestroy_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":555
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatCreate_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libpetsc4py.MatCreate_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ctx);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":615
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatDestroy_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatDestroy_Python(Mat __pyx_v_mat) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PetscErrorCode __pyx_t_3;
  int __pyx_t_4;
  char const *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatDestroy_Python", 0);

  /* "libpetsc4py.pyx":619
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatDestroy_Python")             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectComposeFunction(
 *             <PetscObject>mat,b"MatGetDiagonalBlock_C",
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatDestroy_Python"));

  /* "libpetsc4py.pyx":620
 *     except IERR with gil:
 *     FunctionBegin(b"MatDestroy_Python")
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>mat,b"MatGetDiagonalBlock_C",
 *             <PetscVoidFunction>NULL) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_mat), ((char *)"MatGetDiagonalBlock_C"), ((PetscVoidFunction)NULL))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 620, __pyx_L1_error)

  /* "libpetsc4py.pyx":623
 *             <PetscObject>mat,b"MatGetDiagonalBlock_C",
 *             <PetscVoidFunction>NULL) )
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>mat,b"MatPythonSetType_C",
 *             <PetscVoidFunction>NULL) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_mat), ((char *)"MatPythonSetType_C"), ((PetscVoidFunction)NULL))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 623, __pyx_L1_error)

  /* "libpetsc4py.pyx":626
 *             <PetscObject>mat,b"MatPythonSetType_C",
 *             <PetscVoidFunction>NULL) )
 *     CHKERR( PetscObjectChangeTypeName(             # <<<<<<<<<<<<<<
 *             <PetscObject>mat,NULL) )
 *     #
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectChangeTypeName(((PetscObject)__pyx_v_mat), NULL)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 626, __pyx_L1_error)

  /* "libpetsc4py.pyx":629
 *             <PetscObject>mat,NULL) )
 *     #
 *     if not Py_IsInitialized(): return FunctionEnd()             # <<<<<<<<<<<<<<
 *     try:
 *         addRef(mat)
 */
  __pyx_t_2 = ((!(Py_IsInitialized() != 0)) != 0);
  if (__pyx_t_2) {
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":630
 *     #
 *     if not Py_IsInitialized(): return FunctionEnd()
 *     try:             # <<<<<<<<<<<<<<
 *         addRef(mat)
 *         MatPythonSetContext(mat, NULL)
 */
  /*try:*/ {

    /* "libpetsc4py.pyx":631
 *     if not Py_IsInitialized(): return FunctionEnd()
 *     try:
 *         addRef(mat)             # <<<<<<<<<<<<<<
 *         MatPythonSetContext(mat, NULL)
 *     finally:
 */
    __pyx_f_11libpetsc4py_addRef(__pyx_v_mat);

    /* "libpetsc4py.pyx":632
 *     try:
 *         addRef(mat)
 *         MatPythonSetContext(mat, NULL)             # <<<<<<<<<<<<<<
 *     finally:
 *         delRef(mat)
 */
    __pyx_t_3 = MatPythonSetContext(__pyx_v_mat, NULL); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 632, __pyx_L5_error)
  }

  /* "libpetsc4py.pyx":634
 *         MatPythonSetContext(mat, NULL)
 *     finally:
 *         delRef(mat)             # <<<<<<<<<<<<<<
 *         Py_DECREF(<PyObject*>mat.data)
 *         mat.data = NULL
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_f_11libpetsc4py_delRef(__pyx_v_mat);

      /* "libpetsc4py.pyx":635
 *     finally:
 *         delRef(mat)
 *         Py_DECREF(<PyObject*>mat.data)             # <<<<<<<<<<<<<<
 *         mat.data = NULL
 *     return FunctionEnd()
 */
      Py_DECREF(((PyObject *)__pyx_v_mat->data));

      /* "libpetsc4py.pyx":636
 *         delRef(mat)
 *         Py_DECREF(<PyObject*>mat.data)
 *         mat.data = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
      __pyx_v_mat->data = NULL;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __pyx_t_1 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename;
      {

        /* "libpetsc4py.pyx":634
 *         MatPythonSetContext(mat, NULL)
 *     finally:
 *         delRef(mat)             # <<<<<<<<<<<<<<
 *         Py_DECREF(<PyObject*>mat.data)
 *         mat.data = NULL
 */
        __pyx_f_11libpetsc4py_delRef(__pyx_v_mat);

        /* "libpetsc4py.pyx":635
 *     finally:
 *         delRef(mat)
 *         Py_DECREF(<PyObject*>mat.data)             # <<<<<<<<<<<<<<
 *         mat.data = NULL
 *     return FunctionEnd()
 */
        Py_DECREF(((PyObject *)__pyx_v_mat->data));

        /* "libpetsc4py.pyx":636
 *         delRef(mat)
 *         Py_DECREF(<PyObject*>mat.data)
 *         mat.data = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
        __pyx_v_mat->data = NULL;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      __pyx_lineno = __pyx_t_1; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "libpetsc4py.pyx":637
 *         Py_DECREF(<PyObject*>mat.data)
 *         mat.data = NULL
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatSetFromOptions_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":615
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatDestroy_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.MatDestroy_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":639
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSetFromOptions_Python(             # <<<<<<<<<<<<<<
 *     PetscOptionItems *PetscOptionsObject,
 *     PetscMat mat,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatSetFromOptions_Python(PetscOptionItems *__pyx_v_PetscOptionsObject, Mat __pyx_v_mat) {
  char __pyx_v_name[0x800];
  char *__pyx_v_defval;
  PetscBool __pyx_v_found;
  PetscOptionItems *PetscOptionsObject;
  PyObject *__pyx_v_setFromOptions = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PetscErrorCode __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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatSetFromOptions_Python", 0);

  /* "libpetsc4py.pyx":644
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatSetFromOptions_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef char name[2048], *defval = PyMat(mat).getname()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatSetFromOptions_Python"));

  /* "libpetsc4py.pyx":646
 *     FunctionBegin(b"MatSetFromOptions_Python")
 *     #
 *     cdef char name[2048], *defval = PyMat(mat).getname()             # <<<<<<<<<<<<<<
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_11libpetsc4py__PyMat *)((struct __pyx_obj_11libpetsc4py__PyMat *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.getname(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1)); if (unlikely(__pyx_t_2 == ((char *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 646, __pyx_L1_error)
  __pyx_v_defval = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":647
 *     #
 *     cdef char name[2048], *defval = PyMat(mat).getname()
 *     cdef PetscBool found = PETSC_FALSE             # <<<<<<<<<<<<<<
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 *     CHKERR( PetscOptionsString(
 */
  __pyx_v_found = PETSC_FALSE;

  /* "libpetsc4py.pyx":648
 *     cdef char name[2048], *defval = PyMat(mat).getname()
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject             # <<<<<<<<<<<<<<
 *     CHKERR( PetscOptionsString(
 *             b"-mat_python_type",b"Python [package.]module[.{class|function}]",
 */
  PetscOptionsObject = __pyx_v_PetscOptionsObject;

  /* "libpetsc4py.pyx":649
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 *     CHKERR( PetscOptionsString(             # <<<<<<<<<<<<<<
 *             b"-mat_python_type",b"Python [package.]module[.{class|function}]",
 *             b"MatPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 */
  __pyx_t_3 = __pyx_f_11libpetsc4py_CHKERR(PetscOptionsString(((char *)"-mat_python_type"), ((char *)"Python [package.]module[.{class|function}]"), ((char *)"MatPythonSetType"), __pyx_v_defval, __pyx_v_name, (sizeof(__pyx_v_name)), (&__pyx_v_found))); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 649, __pyx_L1_error)

  /* "libpetsc4py.pyx":651
 *     CHKERR( PetscOptionsString(
 *             b"-mat_python_type",b"Python [package.]module[.{class|function}]",
 *             b"MatPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;             # <<<<<<<<<<<<<<
 *     if found and name[0]:
 *         CHKERR( MatPythonSetType_PYTHON(mat,name) )
 */
  ((void)PetscOptionsObject);

  /* "libpetsc4py.pyx":652
 *             b"-mat_python_type",b"Python [package.]module[.{class|function}]",
 *             b"MatPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:             # <<<<<<<<<<<<<<
 *         CHKERR( MatPythonSetType_PYTHON(mat,name) )
 *     #
 */
  if (__pyx_v_found) {
  } else {
    __pyx_t_4 = __pyx_v_found;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_name[0]) != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":653
 *             b"MatPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:
 *         CHKERR( MatPythonSetType_PYTHON(mat,name) )             # <<<<<<<<<<<<<<
 *     #
 *     cdef setFromOptions = PyMat(mat).setFromOptions
 */
    __pyx_t_6 = __pyx_f_11libpetsc4py_MatPythonSetType_PYTHON(__pyx_v_mat, __pyx_v_name); if (unlikely(__pyx_t_6 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 653, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_11libpetsc4py_CHKERR(__pyx_t_6); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 653, __pyx_L1_error)

    /* "libpetsc4py.pyx":652
 *             b"-mat_python_type",b"Python [package.]module[.{class|function}]",
 *             b"MatPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:             # <<<<<<<<<<<<<<
 *         CHKERR( MatPythonSetType_PYTHON(mat,name) )
 *     #
 */
  }

  /* "libpetsc4py.pyx":655
 *         CHKERR( MatPythonSetType_PYTHON(mat,name) )
 *     #
 *     cdef setFromOptions = PyMat(mat).setFromOptions             # <<<<<<<<<<<<<<
 *     if setFromOptions is not None:
 *         setFromOptions(Mat_(mat))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 655, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_setFromOptions); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 655, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_setFromOptions = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "libpetsc4py.pyx":656
 *     #
 *     cdef setFromOptions = PyMat(mat).setFromOptions
 *     if setFromOptions is not None:             # <<<<<<<<<<<<<<
 *         setFromOptions(Mat_(mat))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_setFromOptions != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":657
 *     cdef setFromOptions = PyMat(mat).setFromOptions
 *     if setFromOptions is not None:
 *         setFromOptions(Mat_(mat))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 657, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_setFromOptions);
    __pyx_t_8 = __pyx_v_setFromOptions; __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_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __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, 657, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "libpetsc4py.pyx":656
 *     #
 *     cdef setFromOptions = PyMat(mat).setFromOptions
 *     if setFromOptions is not None:             # <<<<<<<<<<<<<<
 *         setFromOptions(Mat_(mat))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":658
 *     if setFromOptions is not None:
 *         setFromOptions(Mat_(mat))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatView_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":639
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSetFromOptions_Python(             # <<<<<<<<<<<<<<
 *     PetscOptionItems *PetscOptionsObject,
 *     PetscMat mat,
 */

  /* function exit code */
  __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("libpetsc4py.MatSetFromOptions_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setFromOptions);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":660
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatView_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscViewer vwr,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatView_Python(Mat __pyx_v_mat, PetscViewer __pyx_v_vwr) {
  PyObject *__pyx_v_view = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatView_Python", 0);

  /* "libpetsc4py.pyx":665
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatView_Python")             # <<<<<<<<<<<<<<
 *     viewcontext(PyMat(mat), vwr)
 *     cdef view = PyMat(mat).view
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatView_Python"));

  /* "libpetsc4py.pyx":666
 *     except IERR with gil:
 *     FunctionBegin(b"MatView_Python")
 *     viewcontext(PyMat(mat), vwr)             # <<<<<<<<<<<<<<
 *     cdef view = PyMat(mat).view
 *     if view is not None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_11libpetsc4py_viewcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_vwr); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 666, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":667
 *     FunctionBegin(b"MatView_Python")
 *     viewcontext(PyMat(mat), vwr)
 *     cdef view = PyMat(mat).view             # <<<<<<<<<<<<<<
 *     if view is not None:
 *         view(Mat_(mat), Viewer_(vwr))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 667, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_view); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_view = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":668
 *     viewcontext(PyMat(mat), vwr)
 *     cdef view = PyMat(mat).view
 *     if view is not None:             # <<<<<<<<<<<<<<
 *         view(Mat_(mat), Viewer_(vwr))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_view != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":669
 *     cdef view = PyMat(mat).view
 *     if view is not None:
 *         view(Mat_(mat), Viewer_(vwr))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Viewer_(__pyx_v_vwr)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_view);
    __pyx_t_7 = __pyx_v_view; __pyx_t_8 = NULL;
    __pyx_t_2 = 0;
    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_2 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 669, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 669, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 669, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_2, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_2, __pyx_t_6);
      __pyx_t_1 = 0;
      __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 669, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libpetsc4py.pyx":668
 *     viewcontext(PyMat(mat), vwr)
 *     cdef view = PyMat(mat).view
 *     if view is not None:             # <<<<<<<<<<<<<<
 *         view(Mat_(mat), Viewer_(vwr))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":670
 *     if view is not None:
 *         view(Mat_(mat), Viewer_(vwr))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatDuplicate_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":660
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatView_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscViewer vwr,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.MatView_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_view);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":672
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatDuplicate_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     MatDuplicateOption op,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatDuplicate_Python(Mat __pyx_v_mat, MatDuplicateOption __pyx_v_op, Mat *__pyx_v_out) {
  PyObject *__pyx_v_duplicate = 0;
  struct PyPetscMatObject *__pyx_v_m = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  Mat __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatDuplicate_Python", 0);

  /* "libpetsc4py.pyx":678
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatDuplicate_Python")             # <<<<<<<<<<<<<<
 *     cdef duplicate = PyMat(mat).duplicate
 *     if duplicate is None: return UNSUPPORTED(b"duplicate")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatDuplicate_Python"));

  /* "libpetsc4py.pyx":679
 *     except IERR with gil:
 *     FunctionBegin(b"MatDuplicate_Python")
 *     cdef duplicate = PyMat(mat).duplicate             # <<<<<<<<<<<<<<
 *     if duplicate is None: return UNSUPPORTED(b"duplicate")
 *     cdef Mat m = duplicate(Mat_(mat), <long>op)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 679, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_duplicate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 679, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_duplicate = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":680
 *     FunctionBegin(b"MatDuplicate_Python")
 *     cdef duplicate = PyMat(mat).duplicate
 *     if duplicate is None: return UNSUPPORTED(b"duplicate")             # <<<<<<<<<<<<<<
 *     cdef Mat m = duplicate(Mat_(mat), <long>op)
 *     out[0] = m.mat; m.mat = NULL
 */
  __pyx_t_3 = (__pyx_v_duplicate == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"duplicate"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":681
 *     cdef duplicate = PyMat(mat).duplicate
 *     if duplicate is None: return UNSUPPORTED(b"duplicate")
 *     cdef Mat m = duplicate(Mat_(mat), <long>op)             # <<<<<<<<<<<<<<
 *     out[0] = m.mat; m.mat = NULL
 *     return FunctionEnd()
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyInt_From_long(((long)__pyx_v_op)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_duplicate);
  __pyx_t_6 = __pyx_v_duplicate; __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 681, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __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_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 681, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_8petsc4py_5PETSc_Mat))))) __PYX_ERR(0, 681, __pyx_L1_error)
  __pyx_v_m = ((struct PyPetscMatObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":682
 *     if duplicate is None: return UNSUPPORTED(b"duplicate")
 *     cdef Mat m = duplicate(Mat_(mat), <long>op)
 *     out[0] = m.mat; m.mat = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_10 = __pyx_v_m->mat;
  (__pyx_v_out[0]) = __pyx_t_10;
  __pyx_v_m->mat = NULL;

  /* "libpetsc4py.pyx":683
 *     cdef Mat m = duplicate(Mat_(mat), <long>op)
 *     out[0] = m.mat; m.mat = NULL
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatCopy_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":672
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatDuplicate_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     MatDuplicateOption op,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.MatDuplicate_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_duplicate);
  __Pyx_XDECREF((PyObject *)__pyx_v_m);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":685
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatCopy_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscMat out,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatCopy_Python(Mat __pyx_v_mat, Mat __pyx_v_out, MatStructure __pyx_v_op) {
  PyObject *__pyx_v_copy = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatCopy_Python", 0);

  /* "libpetsc4py.pyx":691
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatCopy_Python")             # <<<<<<<<<<<<<<
 *     cdef copy = PyMat(mat).copy
 *     if copy is None: return UNSUPPORTED(b"copy")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatCopy_Python"));

  /* "libpetsc4py.pyx":692
 *     except IERR with gil:
 *     FunctionBegin(b"MatCopy_Python")
 *     cdef copy = PyMat(mat).copy             # <<<<<<<<<<<<<<
 *     if copy is None: return UNSUPPORTED(b"copy")
 *     copy(Mat_(mat), Mat_(out), <long>op)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 692, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 692, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_copy = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":693
 *     FunctionBegin(b"MatCopy_Python")
 *     cdef copy = PyMat(mat).copy
 *     if copy is None: return UNSUPPORTED(b"copy")             # <<<<<<<<<<<<<<
 *     copy(Mat_(mat), Mat_(out), <long>op)
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_copy == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"copy"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":694
 *     cdef copy = PyMat(mat).copy
 *     if copy is None: return UNSUPPORTED(b"copy")
 *     copy(Mat_(mat), Mat_(out), <long>op)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 694, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_out)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 694, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_From_long(((long)__pyx_v_op)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 694, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_copy);
  __pyx_t_7 = __pyx_v_copy; __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  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_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 694, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":695
 *     if copy is None: return UNSUPPORTED(b"copy")
 *     copy(Mat_(mat), Mat_(out), <long>op)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatGetDiagonalBlock_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":685
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatCopy_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscMat out,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.MatCopy_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_copy);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":697
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatGetDiagonalBlock_Python(             # <<<<<<<<<<<<<<
 *     PetscMat  mat,
 *     PetscMat  *out
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatGetDiagonalBlock_Python(Mat __pyx_v_mat, Mat *__pyx_v_out) {
  PyObject *__pyx_v_getDiagonalBlock = 0;
  struct PyPetscMatObject *__pyx_v_sub = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Mat __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatGetDiagonalBlock_Python", 0);

  /* "libpetsc4py.pyx":702
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatGetDiagonalBlock_Python")             # <<<<<<<<<<<<<<
 *     cdef getDiagonalBlock = PyMat(mat).getDiagonalBlock
 *     if getDiagonalBlock is None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatGetDiagonalBlock_Python"));

  /* "libpetsc4py.pyx":703
 *     except IERR with gil:
 *     FunctionBegin(b"MatGetDiagonalBlock_Python")
 *     cdef getDiagonalBlock = PyMat(mat).getDiagonalBlock             # <<<<<<<<<<<<<<
 *     if getDiagonalBlock is None:
 *         if getCommSize(mat) == 1:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 703, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_getDiagonalBlock); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 703, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_getDiagonalBlock = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":704
 *     FunctionBegin(b"MatGetDiagonalBlock_Python")
 *     cdef getDiagonalBlock = PyMat(mat).getDiagonalBlock
 *     if getDiagonalBlock is None:             # <<<<<<<<<<<<<<
 *         if getCommSize(mat) == 1:
 *             out[0] = mat
 */
  __pyx_t_3 = (__pyx_v_getDiagonalBlock == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":705
 *     cdef getDiagonalBlock = PyMat(mat).getDiagonalBlock
 *     if getDiagonalBlock is None:
 *         if getCommSize(mat) == 1:             # <<<<<<<<<<<<<<
 *             out[0] = mat
 *             return FunctionEnd()
 */
    __pyx_t_4 = ((__pyx_f_11libpetsc4py_getCommSize(__pyx_v_mat) == 1) != 0);
    if (__pyx_t_4) {

      /* "libpetsc4py.pyx":706
 *     if getDiagonalBlock is None:
 *         if getCommSize(mat) == 1:
 *             out[0] = mat             # <<<<<<<<<<<<<<
 *             return FunctionEnd()
 *     if getDiagonalBlock is None: return UNSUPPORTED(b"getDiagonalBlock")
 */
      (__pyx_v_out[0]) = __pyx_v_mat;

      /* "libpetsc4py.pyx":707
 *         if getCommSize(mat) == 1:
 *             out[0] = mat
 *             return FunctionEnd()             # <<<<<<<<<<<<<<
 *     if getDiagonalBlock is None: return UNSUPPORTED(b"getDiagonalBlock")
 *     cdef Mat sub = getDiagonalBlock(Mat_(mat))
 */
      __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
      goto __pyx_L0;

      /* "libpetsc4py.pyx":705
 *     cdef getDiagonalBlock = PyMat(mat).getDiagonalBlock
 *     if getDiagonalBlock is None:
 *         if getCommSize(mat) == 1:             # <<<<<<<<<<<<<<
 *             out[0] = mat
 *             return FunctionEnd()
 */
    }

    /* "libpetsc4py.pyx":704
 *     FunctionBegin(b"MatGetDiagonalBlock_Python")
 *     cdef getDiagonalBlock = PyMat(mat).getDiagonalBlock
 *     if getDiagonalBlock is None:             # <<<<<<<<<<<<<<
 *         if getCommSize(mat) == 1:
 *             out[0] = mat
 */
  }

  /* "libpetsc4py.pyx":708
 *             out[0] = mat
 *             return FunctionEnd()
 *     if getDiagonalBlock is None: return UNSUPPORTED(b"getDiagonalBlock")             # <<<<<<<<<<<<<<
 *     cdef Mat sub = getDiagonalBlock(Mat_(mat))
 *     if sub is not None: out[0] = sub.mat
 */
  __pyx_t_4 = (__pyx_v_getDiagonalBlock == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"getDiagonalBlock"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":709
 *             return FunctionEnd()
 *     if getDiagonalBlock is None: return UNSUPPORTED(b"getDiagonalBlock")
 *     cdef Mat sub = getDiagonalBlock(Mat_(mat))             # <<<<<<<<<<<<<<
 *     if sub is not None: out[0] = sub.mat
 *     return FunctionEnd()
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_getDiagonalBlock);
  __pyx_t_5 = __pyx_v_getDiagonalBlock; __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_8petsc4py_5PETSc_Mat))))) __PYX_ERR(0, 709, __pyx_L1_error)
  __pyx_v_sub = ((struct PyPetscMatObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":710
 *     if getDiagonalBlock is None: return UNSUPPORTED(b"getDiagonalBlock")
 *     cdef Mat sub = getDiagonalBlock(Mat_(mat))
 *     if sub is not None: out[0] = sub.mat             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_sub) != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_t_7 = __pyx_v_sub->mat;
    (__pyx_v_out[0]) = __pyx_t_7;
  }

  /* "libpetsc4py.pyx":711
 *     cdef Mat sub = getDiagonalBlock(Mat_(mat))
 *     if sub is not None: out[0] = sub.mat
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatCreateSubMatrix_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":697
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatGetDiagonalBlock_Python(             # <<<<<<<<<<<<<<
 *     PetscMat  mat,
 *     PetscMat  *out
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.MatGetDiagonalBlock_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_getDiagonalBlock);
  __Pyx_XDECREF((PyObject *)__pyx_v_sub);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":713
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatCreateSubMatrix_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscIS  row,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatCreateSubMatrix_Python(Mat __pyx_v_mat, IS __pyx_v_row, IS __pyx_v_col, MatReuse __pyx_v_op, Mat *__pyx_v_out) {
  PyObject *__pyx_v_createSubMatrix = 0;
  struct PyPetscMatObject *__pyx_v_sub = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  Mat __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatCreateSubMatrix_Python", 0);

  /* "libpetsc4py.pyx":721
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatCreateSubMatrix_Python")             # <<<<<<<<<<<<<<
 *     cdef createSubMatrix = PyMat(mat).createSubMatrix
 *     if createSubMatrix is None: return UNSUPPORTED(b"createSubMatrix")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatCreateSubMatrix_Python"));

  /* "libpetsc4py.pyx":722
 *     except IERR with gil:
 *     FunctionBegin(b"MatCreateSubMatrix_Python")
 *     cdef createSubMatrix = PyMat(mat).createSubMatrix             # <<<<<<<<<<<<<<
 *     if createSubMatrix is None: return UNSUPPORTED(b"createSubMatrix")
 *     cdef Mat sub = None
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_createSubMatrix); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_createSubMatrix = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":723
 *     FunctionBegin(b"MatCreateSubMatrix_Python")
 *     cdef createSubMatrix = PyMat(mat).createSubMatrix
 *     if createSubMatrix is None: return UNSUPPORTED(b"createSubMatrix")             # <<<<<<<<<<<<<<
 *     cdef Mat sub = None
 *     if op == MAT_IGNORE_MATRIX:
 */
  __pyx_t_3 = (__pyx_v_createSubMatrix == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"createSubMatrix"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":724
 *     cdef createSubMatrix = PyMat(mat).createSubMatrix
 *     if createSubMatrix is None: return UNSUPPORTED(b"createSubMatrix")
 *     cdef Mat sub = None             # <<<<<<<<<<<<<<
 *     if op == MAT_IGNORE_MATRIX:
 *         sub = None
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_sub = ((struct PyPetscMatObject *)Py_None);

  /* "libpetsc4py.pyx":725
 *     if createSubMatrix is None: return UNSUPPORTED(b"createSubMatrix")
 *     cdef Mat sub = None
 *     if op == MAT_IGNORE_MATRIX:             # <<<<<<<<<<<<<<
 *         sub = None
 *     elif op == MAT_INITIAL_MATRIX:
 */
  switch (__pyx_v_op) {
    case MAT_IGNORE_MATRIX:

    /* "libpetsc4py.pyx":726
 *     cdef Mat sub = None
 *     if op == MAT_IGNORE_MATRIX:
 *         sub = None             # <<<<<<<<<<<<<<
 *     elif op == MAT_INITIAL_MATRIX:
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), None)
 */
    __Pyx_INCREF(Py_None);
    __Pyx_DECREF_SET(__pyx_v_sub, ((struct PyPetscMatObject *)Py_None));

    /* "libpetsc4py.pyx":725
 *     if createSubMatrix is None: return UNSUPPORTED(b"createSubMatrix")
 *     cdef Mat sub = None
 *     if op == MAT_IGNORE_MATRIX:             # <<<<<<<<<<<<<<
 *         sub = None
 *     elif op == MAT_INITIAL_MATRIX:
 */
    break;
    case MAT_INITIAL_MATRIX:

    /* "libpetsc4py.pyx":728
 *         sub = None
 *     elif op == MAT_INITIAL_MATRIX:
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), None)             # <<<<<<<<<<<<<<
 *         if sub is not None:
 *             addRef(sub.mat)
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_IS_(__pyx_v_row)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_IS_(__pyx_v_col)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_createSubMatrix);
    __pyx_t_7 = __pyx_v_createSubMatrix; __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    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_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6, Py_None};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 728, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6, Py_None};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 728, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 728, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, Py_None);
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 728, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_8petsc4py_5PETSc_Mat))))) __PYX_ERR(0, 728, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_sub, ((struct PyPetscMatObject *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":729
 *     elif op == MAT_INITIAL_MATRIX:
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), None)
 *         if sub is not None:             # <<<<<<<<<<<<<<
 *             addRef(sub.mat)
 *     elif op == MAT_REUSE_MATRIX:
 */
    __pyx_t_4 = (((PyObject *)__pyx_v_sub) != Py_None);
    __pyx_t_3 = (__pyx_t_4 != 0);
    if (__pyx_t_3) {

      /* "libpetsc4py.pyx":730
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), None)
 *         if sub is not None:
 *             addRef(sub.mat)             # <<<<<<<<<<<<<<
 *     elif op == MAT_REUSE_MATRIX:
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), Mat_(out[0]))
 */
      __pyx_f_11libpetsc4py_addRef(__pyx_v_sub->mat);

      /* "libpetsc4py.pyx":729
 *     elif op == MAT_INITIAL_MATRIX:
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), None)
 *         if sub is not None:             # <<<<<<<<<<<<<<
 *             addRef(sub.mat)
 *     elif op == MAT_REUSE_MATRIX:
 */
    }

    /* "libpetsc4py.pyx":727
 *     if op == MAT_IGNORE_MATRIX:
 *         sub = None
 *     elif op == MAT_INITIAL_MATRIX:             # <<<<<<<<<<<<<<
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), None)
 *         if sub is not None:
 */
    break;
    case MAT_REUSE_MATRIX:

    /* "libpetsc4py.pyx":732
 *             addRef(sub.mat)
 *     elif op == MAT_REUSE_MATRIX:
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), Mat_(out[0]))             # <<<<<<<<<<<<<<
 *     if sub is not None:
 *         out[0] = sub.mat
 */
    __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = ((PyObject *)__pyx_f_11libpetsc4py_IS_(__pyx_v_row)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_IS_(__pyx_v_col)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_((__pyx_v_out[0]))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_createSubMatrix);
    __pyx_t_1 = __pyx_v_createSubMatrix; __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_7, __pyx_t_10, __pyx_t_6, __pyx_t_5};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_7, __pyx_t_10, __pyx_t_6, __pyx_t_5};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 732, __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_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_t_5);
      __pyx_t_7 = 0;
      __pyx_t_10 = 0;
      __pyx_t_6 = 0;
      __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_8petsc4py_5PETSc_Mat))))) __PYX_ERR(0, 732, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_sub, ((struct PyPetscMatObject *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":731
 *         if sub is not None:
 *             addRef(sub.mat)
 *     elif op == MAT_REUSE_MATRIX:             # <<<<<<<<<<<<<<
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), Mat_(out[0]))
 *     if sub is not None:
 */
    break;
    default: break;
  }

  /* "libpetsc4py.pyx":733
 *     elif op == MAT_REUSE_MATRIX:
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), Mat_(out[0]))
 *     if sub is not None:             # <<<<<<<<<<<<<<
 *         out[0] = sub.mat
 *     return FunctionEnd()
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_sub) != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":734
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), Mat_(out[0]))
 *     if sub is not None:
 *         out[0] = sub.mat             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_12 = __pyx_v_sub->mat;
    (__pyx_v_out[0]) = __pyx_t_12;

    /* "libpetsc4py.pyx":733
 *     elif op == MAT_REUSE_MATRIX:
 *         sub = createSubMatrix(Mat_(mat), IS_(row), IS_(col), Mat_(out[0]))
 *     if sub is not None:             # <<<<<<<<<<<<<<
 *         out[0] = sub.mat
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":735
 *     if sub is not None:
 *         out[0] = sub.mat
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatSetOption_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":713
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatCreateSubMatrix_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscIS  row,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("libpetsc4py.MatCreateSubMatrix_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_createSubMatrix);
  __Pyx_XDECREF((PyObject *)__pyx_v_sub);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":737
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSetOption_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     MatOption op,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatSetOption_Python(Mat __pyx_v_mat, MatOption __pyx_v_op, PetscBool __pyx_v_flag) {
  PyObject *__pyx_v_setOption = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatSetOption_Python", 0);

  /* "libpetsc4py.pyx":743
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatSetOption_Python")             # <<<<<<<<<<<<<<
 *     cdef setOption = PyMat(mat).setOption
 *     if setOption is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatSetOption_Python"));

  /* "libpetsc4py.pyx":744
 *     except IERR with gil:
 *     FunctionBegin(b"MatSetOption_Python")
 *     cdef setOption = PyMat(mat).setOption             # <<<<<<<<<<<<<<
 *     if setOption is not None:
 *         setOption(Mat_(mat), <long>op, <bint>(<int>flag))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_setOption); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_setOption = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":745
 *     FunctionBegin(b"MatSetOption_Python")
 *     cdef setOption = PyMat(mat).setOption
 *     if setOption is not None:             # <<<<<<<<<<<<<<
 *         setOption(Mat_(mat), <long>op, <bint>(<int>flag))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_setOption != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":746
 *     cdef setOption = PyMat(mat).setOption
 *     if setOption is not None:
 *         setOption(Mat_(mat), <long>op, <bint>(<int>flag))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(((long)__pyx_v_op)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyBool_FromLong((((int)__pyx_v_flag) != 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_setOption);
    __pyx_t_7 = __pyx_v_setOption; __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    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_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":745
 *     FunctionBegin(b"MatSetOption_Python")
 *     cdef setOption = PyMat(mat).setOption
 *     if setOption is not None:             # <<<<<<<<<<<<<<
 *         setOption(Mat_(mat), <long>op, <bint>(<int>flag))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":747
 *     if setOption is not None:
 *         setOption(Mat_(mat), <long>op, <bint>(<int>flag))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatSetUp_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":737
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSetOption_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     MatOption op,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.MatSetOption_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setOption);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":749
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSetUp_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatSetUp_Python(Mat __pyx_v_mat) {
  PetscInt __pyx_v_rbs;
  PetscInt __pyx_v_cbs;
  char __pyx_v_name[0x800];
  PetscBool __pyx_v_found;
  PyObject *__pyx_v_setUp = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PetscErrorCode __pyx_t_5;
  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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatSetUp_Python", 0);

  /* "libpetsc4py.pyx":753
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatSetUp_Python")             # <<<<<<<<<<<<<<
 *     cdef PetscInt rbs = -1, cbs = -1
 *     CHKERR( PetscLayoutGetBlockSize(mat.rmap,&rbs) )
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatSetUp_Python"));

  /* "libpetsc4py.pyx":754
 *     except IERR with gil:
 *     FunctionBegin(b"MatSetUp_Python")
 *     cdef PetscInt rbs = -1, cbs = -1             # <<<<<<<<<<<<<<
 *     CHKERR( PetscLayoutGetBlockSize(mat.rmap,&rbs) )
 *     CHKERR( PetscLayoutGetBlockSize(mat.cmap,&cbs) )
 */
  __pyx_v_rbs = -1L;
  __pyx_v_cbs = -1L;

  /* "libpetsc4py.pyx":755
 *     FunctionBegin(b"MatSetUp_Python")
 *     cdef PetscInt rbs = -1, cbs = -1
 *     CHKERR( PetscLayoutGetBlockSize(mat.rmap,&rbs) )             # <<<<<<<<<<<<<<
 *     CHKERR( PetscLayoutGetBlockSize(mat.cmap,&cbs) )
 *     if rbs == -1: rbs = 1
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscLayoutGetBlockSize(__pyx_v_mat->rmap, (&__pyx_v_rbs))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 755, __pyx_L1_error)

  /* "libpetsc4py.pyx":756
 *     cdef PetscInt rbs = -1, cbs = -1
 *     CHKERR( PetscLayoutGetBlockSize(mat.rmap,&rbs) )
 *     CHKERR( PetscLayoutGetBlockSize(mat.cmap,&cbs) )             # <<<<<<<<<<<<<<
 *     if rbs == -1: rbs = 1
 *     if cbs == -1: cbs = rbs
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscLayoutGetBlockSize(__pyx_v_mat->cmap, (&__pyx_v_cbs))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 756, __pyx_L1_error)

  /* "libpetsc4py.pyx":757
 *     CHKERR( PetscLayoutGetBlockSize(mat.rmap,&rbs) )
 *     CHKERR( PetscLayoutGetBlockSize(mat.cmap,&cbs) )
 *     if rbs == -1: rbs = 1             # <<<<<<<<<<<<<<
 *     if cbs == -1: cbs = rbs
 *     CHKERR( PetscLayoutSetBlockSize(mat.rmap,rbs)  )
 */
  __pyx_t_2 = ((__pyx_v_rbs == -1L) != 0);
  if (__pyx_t_2) {
    __pyx_v_rbs = 1;
  }

  /* "libpetsc4py.pyx":758
 *     CHKERR( PetscLayoutGetBlockSize(mat.cmap,&cbs) )
 *     if rbs == -1: rbs = 1
 *     if cbs == -1: cbs = rbs             # <<<<<<<<<<<<<<
 *     CHKERR( PetscLayoutSetBlockSize(mat.rmap,rbs)  )
 *     CHKERR( PetscLayoutSetBlockSize(mat.cmap,cbs)  )
 */
  __pyx_t_2 = ((__pyx_v_cbs == -1L) != 0);
  if (__pyx_t_2) {
    __pyx_v_cbs = __pyx_v_rbs;
  }

  /* "libpetsc4py.pyx":759
 *     if rbs == -1: rbs = 1
 *     if cbs == -1: cbs = rbs
 *     CHKERR( PetscLayoutSetBlockSize(mat.rmap,rbs)  )             # <<<<<<<<<<<<<<
 *     CHKERR( PetscLayoutSetBlockSize(mat.cmap,cbs)  )
 *     CHKERR( PetscLayoutSetUp(mat.rmap)             )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscLayoutSetBlockSize(__pyx_v_mat->rmap, __pyx_v_rbs)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 759, __pyx_L1_error)

  /* "libpetsc4py.pyx":760
 *     if cbs == -1: cbs = rbs
 *     CHKERR( PetscLayoutSetBlockSize(mat.rmap,rbs)  )
 *     CHKERR( PetscLayoutSetBlockSize(mat.cmap,cbs)  )             # <<<<<<<<<<<<<<
 *     CHKERR( PetscLayoutSetUp(mat.rmap)             )
 *     CHKERR( PetscLayoutSetUp(mat.cmap)             )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscLayoutSetBlockSize(__pyx_v_mat->cmap, __pyx_v_cbs)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 760, __pyx_L1_error)

  /* "libpetsc4py.pyx":761
 *     CHKERR( PetscLayoutSetBlockSize(mat.rmap,rbs)  )
 *     CHKERR( PetscLayoutSetBlockSize(mat.cmap,cbs)  )
 *     CHKERR( PetscLayoutSetUp(mat.rmap)             )             # <<<<<<<<<<<<<<
 *     CHKERR( PetscLayoutSetUp(mat.cmap)             )
 *     mat.preallocated = PETSC_TRUE
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscLayoutSetUp(__pyx_v_mat->rmap)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 761, __pyx_L1_error)

  /* "libpetsc4py.pyx":762
 *     CHKERR( PetscLayoutSetBlockSize(mat.cmap,cbs)  )
 *     CHKERR( PetscLayoutSetUp(mat.rmap)             )
 *     CHKERR( PetscLayoutSetUp(mat.cmap)             )             # <<<<<<<<<<<<<<
 *     mat.preallocated = PETSC_TRUE
 *     #
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscLayoutSetUp(__pyx_v_mat->cmap)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 762, __pyx_L1_error)

  /* "libpetsc4py.pyx":763
 *     CHKERR( PetscLayoutSetUp(mat.rmap)             )
 *     CHKERR( PetscLayoutSetUp(mat.cmap)             )
 *     mat.preallocated = PETSC_TRUE             # <<<<<<<<<<<<<<
 *     #
 *     cdef char name[2048]
 */
  __pyx_v_mat->preallocated = PETSC_TRUE;

  /* "libpetsc4py.pyx":766
 *     #
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE             # <<<<<<<<<<<<<<
 *     if PyMat(mat).self is None:
 *         CHKERR( PetscOptionsGetString(NULL,
 */
  __pyx_v_found = PETSC_FALSE;

  /* "libpetsc4py.pyx":767
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyMat(mat).self is None:             # <<<<<<<<<<<<<<
 *         CHKERR( PetscOptionsGetString(NULL,
 *                 getPrefix(mat), b"-mat_python_type",
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = (((struct __pyx_obj_11libpetsc4py__PyMat *)__pyx_t_3)->__pyx_base.self == Py_None);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = (__pyx_t_2 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":768
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyMat(mat).self is None:
 *         CHKERR( PetscOptionsGetString(NULL,             # <<<<<<<<<<<<<<
 *                 getPrefix(mat), b"-mat_python_type",
 *                 name,sizeof(name),&found) )
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscOptionsGetString(NULL, __pyx_f_11libpetsc4py_getPrefix(__pyx_v_mat), ((char *)"-mat_python_type"), __pyx_v_name, (sizeof(__pyx_v_name)), (&__pyx_v_found))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 768, __pyx_L1_error)

    /* "libpetsc4py.pyx":771
 *                 getPrefix(mat), b"-mat_python_type",
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:             # <<<<<<<<<<<<<<
 *             CHKERR( MatPythonSetType_PYTHON(mat,name) )
 *     if PyMat(mat).self is None:
 */
    if (__pyx_v_found) {
    } else {
      __pyx_t_4 = __pyx_v_found;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_name[0]) != 0);
    __pyx_t_4 = __pyx_t_2;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_4) {

      /* "libpetsc4py.pyx":772
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:
 *             CHKERR( MatPythonSetType_PYTHON(mat,name) )             # <<<<<<<<<<<<<<
 *     if PyMat(mat).self is None:
 *         return PetscSETERR(PETSC_ERR_USER,
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_MatPythonSetType_PYTHON(__pyx_v_mat, __pyx_v_name); if (unlikely(__pyx_t_5 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 772, __pyx_L1_error)
      __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(__pyx_t_5); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 772, __pyx_L1_error)

      /* "libpetsc4py.pyx":771
 *                 getPrefix(mat), b"-mat_python_type",
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:             # <<<<<<<<<<<<<<
 *             CHKERR( MatPythonSetType_PYTHON(mat,name) )
 *     if PyMat(mat).self is None:
 */
    }

    /* "libpetsc4py.pyx":767
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyMat(mat).self is None:             # <<<<<<<<<<<<<<
 *         CHKERR( PetscOptionsGetString(NULL,
 *                 getPrefix(mat), b"-mat_python_type",
 */
  }

  /* "libpetsc4py.pyx":773
 *         if found and name[0]:
 *             CHKERR( MatPythonSetType_PYTHON(mat,name) )
 *     if PyMat(mat).self is None:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER,
 *             "Python context not set, call one of \n"
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = (((struct __pyx_obj_11libpetsc4py__PyMat *)__pyx_t_3)->__pyx_base.self == Py_None);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = (__pyx_t_4 != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":774
 *             CHKERR( MatPythonSetType_PYTHON(mat,name) )
 *     if PyMat(mat).self is None:
 *         return PetscSETERR(PETSC_ERR_USER,             # <<<<<<<<<<<<<<
 *             "Python context not set, call one of \n"
 *             " * MatPythonSetType(mat,\"[package.]module.class\")\n"
 */
    __pyx_r = __pyx_f_11libpetsc4py_PetscSETERR(PETSC_ERR_USER, ((char *)"Python context not set, call one of \n * MatPythonSetType(mat,\"[package.]module.class\")\n * MatSetFromOptions(mat) and pass option -mat_python_type [package.]module.class"));
    goto __pyx_L0;

    /* "libpetsc4py.pyx":773
 *         if found and name[0]:
 *             CHKERR( MatPythonSetType_PYTHON(mat,name) )
 *     if PyMat(mat).self is None:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER,
 *             "Python context not set, call one of \n"
 */
  }

  /* "libpetsc4py.pyx":780
 *             "-mat_python_type [package.]module.class")
 *     #
 *     cdef setUp = PyMat(mat).setUp             # <<<<<<<<<<<<<<
 *     if setUp is not None:
 *         setUp(Mat_(mat))
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_setUp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_setUp = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "libpetsc4py.pyx":781
 *     #
 *     cdef setUp = PyMat(mat).setUp
 *     if setUp is not None:             # <<<<<<<<<<<<<<
 *         setUp(Mat_(mat))
 *     return FunctionEnd()
 */
  __pyx_t_2 = (__pyx_v_setUp != Py_None);
  __pyx_t_4 = (__pyx_t_2 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":782
 *     cdef setUp = PyMat(mat).setUp
 *     if setUp is not None:
 *         setUp(Mat_(mat))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_setUp);
    __pyx_t_7 = __pyx_v_setUp; __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_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "libpetsc4py.pyx":781
 *     #
 *     cdef setUp = PyMat(mat).setUp
 *     if setUp is not None:             # <<<<<<<<<<<<<<
 *         setUp(Mat_(mat))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":783
 *     if setUp is not None:
 *         setUp(Mat_(mat))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatAssemblyBegin_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":749
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSetUp_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("libpetsc4py.MatSetUp_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setUp);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":785
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatAssemblyBegin_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     MatAssemblyType at,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatAssemblyBegin_Python(Mat __pyx_v_mat, MatAssemblyType __pyx_v_at) {
  PyObject *__pyx_v_assembly = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatAssemblyBegin_Python", 0);

  /* "libpetsc4py.pyx":790
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatAssemblyBegin_Python")             # <<<<<<<<<<<<<<
 *     cdef assembly = PyMat(mat).assemblyBegin
 *     if assembly is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatAssemblyBegin_Python"));

  /* "libpetsc4py.pyx":791
 *     except IERR with gil:
 *     FunctionBegin(b"MatAssemblyBegin_Python")
 *     cdef assembly = PyMat(mat).assemblyBegin             # <<<<<<<<<<<<<<
 *     if assembly is not None:
 *         assembly(Mat_(mat), <long>at)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_assemblyBegin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_assembly = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":792
 *     FunctionBegin(b"MatAssemblyBegin_Python")
 *     cdef assembly = PyMat(mat).assemblyBegin
 *     if assembly is not None:             # <<<<<<<<<<<<<<
 *         assembly(Mat_(mat), <long>at)
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_assembly != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":793
 *     cdef assembly = PyMat(mat).assemblyBegin
 *     if assembly is not None:
 *         assembly(Mat_(mat), <long>at)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 793, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_From_long(((long)__pyx_v_at)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 793, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_assembly);
    __pyx_t_6 = __pyx_v_assembly; __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __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_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5);
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":792
 *     FunctionBegin(b"MatAssemblyBegin_Python")
 *     cdef assembly = PyMat(mat).assemblyBegin
 *     if assembly is not None:             # <<<<<<<<<<<<<<
 *         assembly(Mat_(mat), <long>at)
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":794
 *     if assembly is not None:
 *         assembly(Mat_(mat), <long>at)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatAssemblyEnd_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":785
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatAssemblyBegin_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     MatAssemblyType at,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.MatAssemblyBegin_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_assembly);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":796
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatAssemblyEnd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     MatAssemblyType at,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatAssemblyEnd_Python(Mat __pyx_v_mat, MatAssemblyType __pyx_v_at) {
  PyObject *__pyx_v_assembly = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatAssemblyEnd_Python", 0);

  /* "libpetsc4py.pyx":801
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatAssemblyEnd_Python")             # <<<<<<<<<<<<<<
 *     cdef assembly = PyMat(mat).assemblyEnd
 *     if assembly is None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatAssemblyEnd_Python"));

  /* "libpetsc4py.pyx":802
 *     except IERR with gil:
 *     FunctionBegin(b"MatAssemblyEnd_Python")
 *     cdef assembly = PyMat(mat).assemblyEnd             # <<<<<<<<<<<<<<
 *     if assembly is None:
 *         assembly = PyMat(mat).assembly
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_assemblyEnd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_assembly = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":803
 *     FunctionBegin(b"MatAssemblyEnd_Python")
 *     cdef assembly = PyMat(mat).assemblyEnd
 *     if assembly is None:             # <<<<<<<<<<<<<<
 *         assembly = PyMat(mat).assembly
 *     if assembly is not None:
 */
  __pyx_t_3 = (__pyx_v_assembly == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":804
 *     cdef assembly = PyMat(mat).assemblyEnd
 *     if assembly is None:
 *         assembly = PyMat(mat).assembly             # <<<<<<<<<<<<<<
 *     if assembly is not None:
 *         assembly(Mat_(mat), <int>at)
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 804, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_assembly); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 804, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_assembly, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "libpetsc4py.pyx":803
 *     FunctionBegin(b"MatAssemblyEnd_Python")
 *     cdef assembly = PyMat(mat).assemblyEnd
 *     if assembly is None:             # <<<<<<<<<<<<<<
 *         assembly = PyMat(mat).assembly
 *     if assembly is not None:
 */
  }

  /* "libpetsc4py.pyx":805
 *     if assembly is None:
 *         assembly = PyMat(mat).assembly
 *     if assembly is not None:             # <<<<<<<<<<<<<<
 *         assembly(Mat_(mat), <int>at)
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_assembly != Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":806
 *         assembly = PyMat(mat).assembly
 *     if assembly is not None:
 *         assembly(Mat_(mat), <int>at)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 806, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyInt_From_int(((int)__pyx_v_at)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 806, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_assembly);
    __pyx_t_6 = __pyx_v_assembly; __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_2, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 806, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_2, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 806, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 806, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5);
      __pyx_t_2 = 0;
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 806, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "libpetsc4py.pyx":805
 *     if assembly is None:
 *         assembly = PyMat(mat).assembly
 *     if assembly is not None:             # <<<<<<<<<<<<<<
 *         assembly(Mat_(mat), <int>at)
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":807
 *     if assembly is not None:
 *         assembly(Mat_(mat), <int>at)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatZeroEntries_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":796
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatAssemblyEnd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     MatAssemblyType at,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.MatAssemblyEnd_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_assembly);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":809
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatZeroEntries_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatZeroEntries_Python(Mat __pyx_v_mat) {
  PyObject *__pyx_v_zeroEntries = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatZeroEntries_Python", 0);

  /* "libpetsc4py.pyx":813
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatZeroEntries_Python")             # <<<<<<<<<<<<<<
 *     cdef zeroEntries = PyMat(mat).zeroEntries
 *     if zeroEntries is None: return UNSUPPORTED(b"zeroEntries")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatZeroEntries_Python"));

  /* "libpetsc4py.pyx":814
 *     except IERR with gil:
 *     FunctionBegin(b"MatZeroEntries_Python")
 *     cdef zeroEntries = PyMat(mat).zeroEntries             # <<<<<<<<<<<<<<
 *     if zeroEntries is None: return UNSUPPORTED(b"zeroEntries")
 *     zeroEntries(Mat_(mat))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 814, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeroEntries); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 814, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_zeroEntries = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":815
 *     FunctionBegin(b"MatZeroEntries_Python")
 *     cdef zeroEntries = PyMat(mat).zeroEntries
 *     if zeroEntries is None: return UNSUPPORTED(b"zeroEntries")             # <<<<<<<<<<<<<<
 *     zeroEntries(Mat_(mat))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_zeroEntries == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"zeroEntries"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":816
 *     cdef zeroEntries = PyMat(mat).zeroEntries
 *     if zeroEntries is None: return UNSUPPORTED(b"zeroEntries")
 *     zeroEntries(Mat_(mat))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 816, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_zeroEntries);
  __pyx_t_5 = __pyx_v_zeroEntries; __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 816, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":817
 *     if zeroEntries is None: return UNSUPPORTED(b"zeroEntries")
 *     zeroEntries(Mat_(mat))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatZeroRowsColumns_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":809
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatZeroEntries_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.MatZeroEntries_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_zeroEntries);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":819
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatZeroRowsColumns_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscInt numRows,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatZeroRowsColumns_Python(Mat __pyx_v_mat, PetscInt __pyx_v_numRows, PetscInt const *__pyx_v_rows, PetscScalar __pyx_v_diag, Vec __pyx_v_x, Vec __pyx_v_b) {
  PyObject *__pyx_v_zeroRowsColumns = 0;
  PyArrayObject *__pyx_v_pyrows = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatZeroRowsColumns_Python", 0);

  /* "libpetsc4py.pyx":828
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatZeroRowsColumns_Python")             # <<<<<<<<<<<<<<
 *     cdef zeroRowsColumns = PyMat(mat).zeroRowsColumns
 *     if zeroRowsColumns is None: return UNSUPPORTED(b"zeroRowsColumns")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatZeroRowsColumns_Python"));

  /* "libpetsc4py.pyx":829
 *     except IERR with gil:
 *     FunctionBegin(b"MatZeroRowsColumns_Python")
 *     cdef zeroRowsColumns = PyMat(mat).zeroRowsColumns             # <<<<<<<<<<<<<<
 *     if zeroRowsColumns is None: return UNSUPPORTED(b"zeroRowsColumns")
 *     cdef ndarray pyrows = array_i(numRows, rows)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 829, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeroRowsColumns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 829, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_zeroRowsColumns = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":830
 *     FunctionBegin(b"MatZeroRowsColumns_Python")
 *     cdef zeroRowsColumns = PyMat(mat).zeroRowsColumns
 *     if zeroRowsColumns is None: return UNSUPPORTED(b"zeroRowsColumns")             # <<<<<<<<<<<<<<
 *     cdef ndarray pyrows = array_i(numRows, rows)
 *     zeroRowsColumns(Mat_(mat), pyrows, toScalar(diag), Vec_(x), Vec_(b))
 */
  __pyx_t_3 = (__pyx_v_zeroRowsColumns == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"zeroRowsColumns"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":831
 *     cdef zeroRowsColumns = PyMat(mat).zeroRowsColumns
 *     if zeroRowsColumns is None: return UNSUPPORTED(b"zeroRowsColumns")
 *     cdef ndarray pyrows = array_i(numRows, rows)             # <<<<<<<<<<<<<<
 *     zeroRowsColumns(Mat_(mat), pyrows, toScalar(diag), Vec_(x), Vec_(b))
 *     return FunctionEnd()
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_array_i(__pyx_v_numRows, __pyx_v_rows)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_pyrows = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":832
 *     if zeroRowsColumns is None: return UNSUPPORTED(b"zeroRowsColumns")
 *     cdef ndarray pyrows = array_i(numRows, rows)
 *     zeroRowsColumns(Mat_(mat), pyrows, toScalar(diag), Vec_(x), Vec_(b))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 832, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyPetscScalar_FromPetscScalar(__pyx_v_diag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 832, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 832, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_b)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 832, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_zeroRowsColumns);
  __pyx_t_8 = __pyx_v_zeroRowsColumns; __pyx_t_9 = NULL;
  __pyx_t_10 = 0;
  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_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[6] = {__pyx_t_9, __pyx_t_1, ((PyObject *)__pyx_v_pyrows), __pyx_t_5, __pyx_t_6, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 5+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[6] = {__pyx_t_9, __pyx_t_1, ((PyObject *)__pyx_v_pyrows), __pyx_t_5, __pyx_t_6, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 5+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(5+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 832, __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_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_pyrows));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_pyrows));
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, ((PyObject *)__pyx_v_pyrows));
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_10, __pyx_t_7);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":833
 *     cdef ndarray pyrows = array_i(numRows, rows)
 *     zeroRowsColumns(Mat_(mat), pyrows, toScalar(diag), Vec_(x), Vec_(b))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatScale_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":819
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatZeroRowsColumns_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscInt numRows,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("libpetsc4py.MatZeroRowsColumns_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_zeroRowsColumns);
  __Pyx_XDECREF((PyObject *)__pyx_v_pyrows);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":835
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatScale_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscScalar s,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatScale_Python(Mat __pyx_v_mat, PetscScalar __pyx_v_s) {
  PyObject *__pyx_v_scale = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatScale_Python", 0);

  /* "libpetsc4py.pyx":840
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatScale_Python")             # <<<<<<<<<<<<<<
 *     cdef scale = PyMat(mat).scale
 *     if scale is None: return UNSUPPORTED(b"scale")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatScale_Python"));

  /* "libpetsc4py.pyx":841
 *     except IERR with gil:
 *     FunctionBegin(b"MatScale_Python")
 *     cdef scale = PyMat(mat).scale             # <<<<<<<<<<<<<<
 *     if scale is None: return UNSUPPORTED(b"scale")
 *     scale(Mat_(mat), toScalar(s))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_scale); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_scale = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":842
 *     FunctionBegin(b"MatScale_Python")
 *     cdef scale = PyMat(mat).scale
 *     if scale is None: return UNSUPPORTED(b"scale")             # <<<<<<<<<<<<<<
 *     scale(Mat_(mat), toScalar(s))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_scale == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"scale"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":843
 *     cdef scale = PyMat(mat).scale
 *     if scale is None: return UNSUPPORTED(b"scale")
 *     scale(Mat_(mat), toScalar(s))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 843, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyPetscScalar_FromPetscScalar(__pyx_v_s); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 843, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_scale);
  __pyx_t_6 = __pyx_v_scale; __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 843, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __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_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 843, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":844
 *     if scale is None: return UNSUPPORTED(b"scale")
 *     scale(Mat_(mat), toScalar(s))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatShift_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":835
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatScale_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscScalar s,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.MatScale_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_scale);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":846
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatShift_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscScalar s,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatShift_Python(Mat __pyx_v_mat, PetscScalar __pyx_v_s) {
  PyObject *__pyx_v_shift = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatShift_Python", 0);

  /* "libpetsc4py.pyx":851
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatShift_Python")             # <<<<<<<<<<<<<<
 *     cdef shift = PyMat(mat).shift
 *     if shift is None: return UNSUPPORTED(b"shift")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatShift_Python"));

  /* "libpetsc4py.pyx":852
 *     except IERR with gil:
 *     FunctionBegin(b"MatShift_Python")
 *     cdef shift = PyMat(mat).shift             # <<<<<<<<<<<<<<
 *     if shift is None: return UNSUPPORTED(b"shift")
 *     shift(Mat_(mat), toScalar(s))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_shift); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_shift = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":853
 *     FunctionBegin(b"MatShift_Python")
 *     cdef shift = PyMat(mat).shift
 *     if shift is None: return UNSUPPORTED(b"shift")             # <<<<<<<<<<<<<<
 *     shift(Mat_(mat), toScalar(s))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_shift == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"shift"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":854
 *     cdef shift = PyMat(mat).shift
 *     if shift is None: return UNSUPPORTED(b"shift")
 *     shift(Mat_(mat), toScalar(s))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyPetscScalar_FromPetscScalar(__pyx_v_s); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_shift);
  __pyx_t_6 = __pyx_v_shift; __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 854, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __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_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 854, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 854, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 854, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":855
 *     if shift is None: return UNSUPPORTED(b"shift")
 *     shift(Mat_(mat), toScalar(s))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatCreateVecs_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":846
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatShift_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscScalar s,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.MatShift_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_shift);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":857
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatCreateVecs_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec *x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatCreateVecs_Python(Mat __pyx_v_mat, Vec *__pyx_v_x, Vec *__pyx_v_y) {
  PyObject *__pyx_v_createVecs = 0;
  struct PyPetscVecObject *__pyx_v_u = 0;
  struct PyPetscVecObject *__pyx_v_v = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  char const *__pyx_t_7;
  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;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *(*__pyx_t_16)(PyObject *);
  Vec __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatCreateVecs_Python", 0);

  /* "libpetsc4py.pyx":863
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatCreateVecs_Python")             # <<<<<<<<<<<<<<
 *     cdef createVecs = PyMat(mat).createVecs
 *     if createVecs is None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatCreateVecs_Python"));

  /* "libpetsc4py.pyx":864
 *     except IERR with gil:
 *     FunctionBegin(b"MatCreateVecs_Python")
 *     cdef createVecs = PyMat(mat).createVecs             # <<<<<<<<<<<<<<
 *     if createVecs is None:
 *         try:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_createVecs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_createVecs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":865
 *     FunctionBegin(b"MatCreateVecs_Python")
 *     cdef createVecs = PyMat(mat).createVecs
 *     if createVecs is None:             # <<<<<<<<<<<<<<
 *         try:
 *             mat.ops.getvecs = NULL
 */
  __pyx_t_3 = (__pyx_v_createVecs == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":866
 *     cdef createVecs = PyMat(mat).createVecs
 *     if createVecs is None:
 *         try:             # <<<<<<<<<<<<<<
 *             mat.ops.getvecs = NULL
 *             CHKERR( MatCreateVecs(mat,x,y) )
 */
    /*try:*/ {

      /* "libpetsc4py.pyx":867
 *     if createVecs is None:
 *         try:
 *             mat.ops.getvecs = NULL             # <<<<<<<<<<<<<<
 *             CHKERR( MatCreateVecs(mat,x,y) )
 *         finally:
 */
      __pyx_v_mat->ops->getvecs = NULL;

      /* "libpetsc4py.pyx":868
 *         try:
 *             mat.ops.getvecs = NULL
 *             CHKERR( MatCreateVecs(mat,x,y) )             # <<<<<<<<<<<<<<
 *         finally:
 *             mat.ops.getvecs = MatCreateVecs_Python
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatCreateVecs(__pyx_v_mat, __pyx_v_x, __pyx_v_y)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 868, __pyx_L5_error)
    }

    /* "libpetsc4py.pyx":870
 *             CHKERR( MatCreateVecs(mat,x,y) )
 *         finally:
 *             mat.ops.getvecs = MatCreateVecs_Python             # <<<<<<<<<<<<<<
 *         return FunctionEnd()
 *     if createVecs is None: return UNSUPPORTED(b"createVecs")
 */
    /*finally:*/ {
      /*normal exit:*/{
        __pyx_v_mat->ops->getvecs = __pyx_f_11libpetsc4py_MatCreateVecs_Python;
        goto __pyx_L6;
      }
      __pyx_L5_error:;
      /*exception exit:*/{
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_13);
        __pyx_t_5 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
        {
          __pyx_v_mat->ops->getvecs = __pyx_f_11libpetsc4py_MatCreateVecs_Python;
        }
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        }
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
        __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7;
        goto __pyx_L1_error;
      }
      __pyx_L6:;
    }

    /* "libpetsc4py.pyx":871
 *         finally:
 *             mat.ops.getvecs = MatCreateVecs_Python
 *         return FunctionEnd()             # <<<<<<<<<<<<<<
 *     if createVecs is None: return UNSUPPORTED(b"createVecs")
 *     cdef Vec u, v
 */
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;

    /* "libpetsc4py.pyx":865
 *     FunctionBegin(b"MatCreateVecs_Python")
 *     cdef createVecs = PyMat(mat).createVecs
 *     if createVecs is None:             # <<<<<<<<<<<<<<
 *         try:
 *             mat.ops.getvecs = NULL
 */
  }

  /* "libpetsc4py.pyx":872
 *             mat.ops.getvecs = MatCreateVecs_Python
 *         return FunctionEnd()
 *     if createVecs is None: return UNSUPPORTED(b"createVecs")             # <<<<<<<<<<<<<<
 *     cdef Vec u, v
 *     u, v = createVecs(Mat_(mat))
 */
  __pyx_t_4 = (__pyx_v_createVecs == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"createVecs"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":874
 *     if createVecs is None: return UNSUPPORTED(b"createVecs")
 *     cdef Vec u, v
 *     u, v = createVecs(Mat_(mat))             # <<<<<<<<<<<<<<
 *     if x != NULL:
 *         x[0] = u.vec
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 874, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_createVecs);
  __pyx_t_14 = __pyx_v_createVecs; __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
    }
  }
  __pyx_t_2 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_15, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 874, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 874, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_14 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_14 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_14);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_14 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 874, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 874, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_15 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 874, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_16 = Py_TYPE(__pyx_t_15)->tp_iternext;
    index = 0; __pyx_t_14 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_14)) goto __pyx_L10_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_14);
    index = 1; __pyx_t_1 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_1)) goto __pyx_L10_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_15), 2) < 0) __PYX_ERR(0, 874, __pyx_L1_error)
    __pyx_t_16 = NULL;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    goto __pyx_L11_unpacking_done;
    __pyx_L10_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_16 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 874, __pyx_L1_error)
    __pyx_L11_unpacking_done:;
  }
  if (!(likely(((__pyx_t_14) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_14, __pyx_ptype_8petsc4py_5PETSc_Vec))))) __PYX_ERR(0, 874, __pyx_L1_error)
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8petsc4py_5PETSc_Vec))))) __PYX_ERR(0, 874, __pyx_L1_error)
  __pyx_v_u = ((struct PyPetscVecObject *)__pyx_t_14);
  __pyx_t_14 = 0;
  __pyx_v_v = ((struct PyPetscVecObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":875
 *     cdef Vec u, v
 *     u, v = createVecs(Mat_(mat))
 *     if x != NULL:             # <<<<<<<<<<<<<<
 *         x[0] = u.vec
 *         u.vec = NULL
 */
  __pyx_t_3 = ((__pyx_v_x != NULL) != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":876
 *     u, v = createVecs(Mat_(mat))
 *     if x != NULL:
 *         x[0] = u.vec             # <<<<<<<<<<<<<<
 *         u.vec = NULL
 *     if y != NULL:
 */
    __pyx_t_17 = __pyx_v_u->vec;
    (__pyx_v_x[0]) = __pyx_t_17;

    /* "libpetsc4py.pyx":877
 *     if x != NULL:
 *         x[0] = u.vec
 *         u.vec = NULL             # <<<<<<<<<<<<<<
 *     if y != NULL:
 *         y[0] = v.vec
 */
    __pyx_v_u->vec = NULL;

    /* "libpetsc4py.pyx":875
 *     cdef Vec u, v
 *     u, v = createVecs(Mat_(mat))
 *     if x != NULL:             # <<<<<<<<<<<<<<
 *         x[0] = u.vec
 *         u.vec = NULL
 */
  }

  /* "libpetsc4py.pyx":878
 *         x[0] = u.vec
 *         u.vec = NULL
 *     if y != NULL:             # <<<<<<<<<<<<<<
 *         y[0] = v.vec
 *         v.vec = NULL
 */
  __pyx_t_3 = ((__pyx_v_y != NULL) != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":879
 *         u.vec = NULL
 *     if y != NULL:
 *         y[0] = v.vec             # <<<<<<<<<<<<<<
 *         v.vec = NULL
 *     return FunctionEnd()
 */
    __pyx_t_17 = __pyx_v_v->vec;
    (__pyx_v_y[0]) = __pyx_t_17;

    /* "libpetsc4py.pyx":880
 *     if y != NULL:
 *         y[0] = v.vec
 *         v.vec = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_v_v->vec = NULL;

    /* "libpetsc4py.pyx":878
 *         x[0] = u.vec
 *         u.vec = NULL
 *     if y != NULL:             # <<<<<<<<<<<<<<
 *         y[0] = v.vec
 *         v.vec = NULL
 */
  }

  /* "libpetsc4py.pyx":881
 *         y[0] = v.vec
 *         v.vec = NULL
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatMult_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":857
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatCreateVecs_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec *x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("libpetsc4py.MatCreateVecs_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_createVecs);
  __Pyx_XDECREF((PyObject *)__pyx_v_u);
  __Pyx_XDECREF((PyObject *)__pyx_v_v);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":883
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMult_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatMult_Python(Mat __pyx_v_mat, Vec __pyx_v_x, Vec __pyx_v_y) {
  PyObject *__pyx_v_mult = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatMult_Python", 0);

  /* "libpetsc4py.pyx":889
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatMult_Python")             # <<<<<<<<<<<<<<
 *     cdef mult = PyMat(mat).mult
 *     if mult is None: return UNSUPPORTED(b"mult")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatMult_Python"));

  /* "libpetsc4py.pyx":890
 *     except IERR with gil:
 *     FunctionBegin(b"MatMult_Python")
 *     cdef mult = PyMat(mat).mult             # <<<<<<<<<<<<<<
 *     if mult is None: return UNSUPPORTED(b"mult")
 *     mult(Mat_(mat), Vec_(x), Vec_(y))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_mult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_mult = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":891
 *     FunctionBegin(b"MatMult_Python")
 *     cdef mult = PyMat(mat).mult
 *     if mult is None: return UNSUPPORTED(b"mult")             # <<<<<<<<<<<<<<
 *     mult(Mat_(mat), Vec_(x), Vec_(y))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_mult == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"mult"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":892
 *     cdef mult = PyMat(mat).mult
 *     if mult is None: return UNSUPPORTED(b"mult")
 *     mult(Mat_(mat), Vec_(x), Vec_(y))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_mult);
  __pyx_t_7 = __pyx_v_mult; __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  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_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 892, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 892, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 892, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 892, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":893
 *     if mult is None: return UNSUPPORTED(b"mult")
 *     mult(Mat_(mat), Vec_(x), Vec_(y))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatMultTranspose_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":883
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMult_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.MatMult_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_mult);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":895
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultTranspose_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatMultTranspose_Python(Mat __pyx_v_mat, Vec __pyx_v_x, Vec __pyx_v_y) {
  PyObject *__pyx_v_multTranspose = 0;
  PetscBool __pyx_v_symmset;
  PetscBool __pyx_v_symmknown;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatMultTranspose_Python", 0);

  /* "libpetsc4py.pyx":901
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultTranspose_Python")             # <<<<<<<<<<<<<<
 *     cdef multTranspose = PyMat(mat).multTranspose
 *     cdef PetscBool symmset, symmknown
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatMultTranspose_Python"));

  /* "libpetsc4py.pyx":902
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultTranspose_Python")
 *     cdef multTranspose = PyMat(mat).multTranspose             # <<<<<<<<<<<<<<
 *     cdef PetscBool symmset, symmknown
 *     if multTranspose is None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 902, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_multTranspose); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 902, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_multTranspose = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":904
 *     cdef multTranspose = PyMat(mat).multTranspose
 *     cdef PetscBool symmset, symmknown
 *     if multTranspose is None:             # <<<<<<<<<<<<<<
 *         symmset = symmknown = PETSC_FALSE
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 */
  __pyx_t_3 = (__pyx_v_multTranspose == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":905
 *     cdef PetscBool symmset, symmknown
 *     if multTranspose is None:
 *         symmset = symmknown = PETSC_FALSE             # <<<<<<<<<<<<<<
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 *         if symmset and symmknown:
 */
    __pyx_v_symmset = PETSC_FALSE;
    __pyx_v_symmknown = PETSC_FALSE;

    /* "libpetsc4py.pyx":906
 *     if multTranspose is None:
 *         symmset = symmknown = PETSC_FALSE
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )             # <<<<<<<<<<<<<<
 *         if symmset and symmknown:
 *             CHKERR( MatMult(mat,x,y) )
 */
    __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatIsSymmetricKnown(__pyx_v_mat, (&__pyx_v_symmset), (&__pyx_v_symmknown))); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 906, __pyx_L1_error)

    /* "libpetsc4py.pyx":907
 *         symmset = symmknown = PETSC_FALSE
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 *         if symmset and symmknown:             # <<<<<<<<<<<<<<
 *             CHKERR( MatMult(mat,x,y) )
 *             return FunctionEnd()
 */
    if (__pyx_v_symmset) {
    } else {
      __pyx_t_4 = __pyx_v_symmset;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_4 = __pyx_v_symmknown;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_4) {

      /* "libpetsc4py.pyx":908
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 *         if symmset and symmknown:
 *             CHKERR( MatMult(mat,x,y) )             # <<<<<<<<<<<<<<
 *             return FunctionEnd()
 *     if multTranspose is None: return UNSUPPORTED(b"multTranspose")
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatMult(__pyx_v_mat, __pyx_v_x, __pyx_v_y)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 908, __pyx_L1_error)

      /* "libpetsc4py.pyx":909
 *         if symmset and symmknown:
 *             CHKERR( MatMult(mat,x,y) )
 *             return FunctionEnd()             # <<<<<<<<<<<<<<
 *     if multTranspose is None: return UNSUPPORTED(b"multTranspose")
 *     multTranspose(Mat_(mat), Vec_(x), Vec_(y))
 */
      __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
      goto __pyx_L0;

      /* "libpetsc4py.pyx":907
 *         symmset = symmknown = PETSC_FALSE
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 *         if symmset and symmknown:             # <<<<<<<<<<<<<<
 *             CHKERR( MatMult(mat,x,y) )
 *             return FunctionEnd()
 */
    }

    /* "libpetsc4py.pyx":904
 *     cdef multTranspose = PyMat(mat).multTranspose
 *     cdef PetscBool symmset, symmknown
 *     if multTranspose is None:             # <<<<<<<<<<<<<<
 *         symmset = symmknown = PETSC_FALSE
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 */
  }

  /* "libpetsc4py.pyx":910
 *             CHKERR( MatMult(mat,x,y) )
 *             return FunctionEnd()
 *     if multTranspose is None: return UNSUPPORTED(b"multTranspose")             # <<<<<<<<<<<<<<
 *     multTranspose(Mat_(mat), Vec_(x), Vec_(y))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_multTranspose == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"multTranspose"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":911
 *             return FunctionEnd()
 *     if multTranspose is None: return UNSUPPORTED(b"multTranspose")
 *     multTranspose(Mat_(mat), Vec_(x), Vec_(y))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 911, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 911, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 911, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_multTranspose);
  __pyx_t_8 = __pyx_v_multTranspose; __pyx_t_9 = NULL;
  __pyx_t_5 = 0;
  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_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_1, __pyx_t_6, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 911, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_1, __pyx_t_6, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 911, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 911, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_5, __pyx_t_7);
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 911, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":912
 *     if multTranspose is None: return UNSUPPORTED(b"multTranspose")
 *     multTranspose(Mat_(mat), Vec_(x), Vec_(y))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatMultHermitian_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":895
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultTranspose_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __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_AddTraceback("libpetsc4py.MatMultTranspose_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_multTranspose);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":914
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultHermitian_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatMultHermitian_Python(Mat __pyx_v_mat, Vec __pyx_v_x, Vec __pyx_v_y) {
  PyObject *__pyx_v_multHermitian = 0;
  PetscBool __pyx_v_hermset;
  PetscBool __pyx_v_hermknown;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatMultHermitian_Python", 0);

  /* "libpetsc4py.pyx":920
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultHermitian_Python")             # <<<<<<<<<<<<<<
 *     cdef multHermitian = PyMat(mat).multHermitian
 *     cdef PetscBool hermset, hermknown
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatMultHermitian_Python"));

  /* "libpetsc4py.pyx":921
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultHermitian_Python")
 *     cdef multHermitian = PyMat(mat).multHermitian             # <<<<<<<<<<<<<<
 *     cdef PetscBool hermset, hermknown
 *     if multHermitian is None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 921, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_multHermitian); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 921, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_multHermitian = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":923
 *     cdef multHermitian = PyMat(mat).multHermitian
 *     cdef PetscBool hermset, hermknown
 *     if multHermitian is None:             # <<<<<<<<<<<<<<
 *         hermset = hermknown = PETSC_FALSE
 *         CHKERR( MatIsHermitianKnown(mat,&hermset,&hermknown) )
 */
  __pyx_t_3 = (__pyx_v_multHermitian == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":924
 *     cdef PetscBool hermset, hermknown
 *     if multHermitian is None:
 *         hermset = hermknown = PETSC_FALSE             # <<<<<<<<<<<<<<
 *         CHKERR( MatIsHermitianKnown(mat,&hermset,&hermknown) )
 *         if hermset and hermknown:
 */
    __pyx_v_hermset = PETSC_FALSE;
    __pyx_v_hermknown = PETSC_FALSE;

    /* "libpetsc4py.pyx":925
 *     if multHermitian is None:
 *         hermset = hermknown = PETSC_FALSE
 *         CHKERR( MatIsHermitianKnown(mat,&hermset,&hermknown) )             # <<<<<<<<<<<<<<
 *         if hermset and hermknown:
 *             CHKERR( MatMult(mat,x,y) )
 */
    __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatIsHermitianKnown(__pyx_v_mat, (&__pyx_v_hermset), (&__pyx_v_hermknown))); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 925, __pyx_L1_error)

    /* "libpetsc4py.pyx":926
 *         hermset = hermknown = PETSC_FALSE
 *         CHKERR( MatIsHermitianKnown(mat,&hermset,&hermknown) )
 *         if hermset and hermknown:             # <<<<<<<<<<<<<<
 *             CHKERR( MatMult(mat,x,y) )
 *             return FunctionEnd()
 */
    if (__pyx_v_hermset) {
    } else {
      __pyx_t_4 = __pyx_v_hermset;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_4 = __pyx_v_hermknown;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_4) {

      /* "libpetsc4py.pyx":927
 *         CHKERR( MatIsHermitianKnown(mat,&hermset,&hermknown) )
 *         if hermset and hermknown:
 *             CHKERR( MatMult(mat,x,y) )             # <<<<<<<<<<<<<<
 *             return FunctionEnd()
 *     if multHermitian is None: return UNSUPPORTED(b"multHermitian")
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatMult(__pyx_v_mat, __pyx_v_x, __pyx_v_y)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 927, __pyx_L1_error)

      /* "libpetsc4py.pyx":928
 *         if hermset and hermknown:
 *             CHKERR( MatMult(mat,x,y) )
 *             return FunctionEnd()             # <<<<<<<<<<<<<<
 *     if multHermitian is None: return UNSUPPORTED(b"multHermitian")
 *     multHermitian(Mat_(mat), Vec_(x), Vec_(y))
 */
      __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
      goto __pyx_L0;

      /* "libpetsc4py.pyx":926
 *         hermset = hermknown = PETSC_FALSE
 *         CHKERR( MatIsHermitianKnown(mat,&hermset,&hermknown) )
 *         if hermset and hermknown:             # <<<<<<<<<<<<<<
 *             CHKERR( MatMult(mat,x,y) )
 *             return FunctionEnd()
 */
    }

    /* "libpetsc4py.pyx":923
 *     cdef multHermitian = PyMat(mat).multHermitian
 *     cdef PetscBool hermset, hermknown
 *     if multHermitian is None:             # <<<<<<<<<<<<<<
 *         hermset = hermknown = PETSC_FALSE
 *         CHKERR( MatIsHermitianKnown(mat,&hermset,&hermknown) )
 */
  }

  /* "libpetsc4py.pyx":929
 *             CHKERR( MatMult(mat,x,y) )
 *             return FunctionEnd()
 *     if multHermitian is None: return UNSUPPORTED(b"multHermitian")             # <<<<<<<<<<<<<<
 *     multHermitian(Mat_(mat), Vec_(x), Vec_(y))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_multHermitian == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"multHermitian"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":930
 *             return FunctionEnd()
 *     if multHermitian is None: return UNSUPPORTED(b"multHermitian")
 *     multHermitian(Mat_(mat), Vec_(x), Vec_(y))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_multHermitian);
  __pyx_t_8 = __pyx_v_multHermitian; __pyx_t_9 = NULL;
  __pyx_t_5 = 0;
  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_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_1, __pyx_t_6, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 930, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_1, __pyx_t_6, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 930, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 930, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_5, __pyx_t_7);
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 930, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":931
 *     if multHermitian is None: return UNSUPPORTED(b"multHermitian")
 *     multHermitian(Mat_(mat), Vec_(x), Vec_(y))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatMultAdd_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":914
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultHermitian_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __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_AddTraceback("libpetsc4py.MatMultHermitian_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_multHermitian);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":933
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultAdd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatMultAdd_Python(Mat __pyx_v_mat, Vec __pyx_v_x, Vec __pyx_v_v, Vec __pyx_v_y) {
  PyObject *__pyx_v_multAdd = 0;
  Vec __pyx_v_t;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatMultAdd_Python", 0);

  /* "libpetsc4py.pyx":940
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultAdd_Python")             # <<<<<<<<<<<<<<
 *     cdef multAdd = PyMat(mat).multAdd
 *     cdef PetscVec t = NULL
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatMultAdd_Python"));

  /* "libpetsc4py.pyx":941
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultAdd_Python")
 *     cdef multAdd = PyMat(mat).multAdd             # <<<<<<<<<<<<<<
 *     cdef PetscVec t = NULL
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_multAdd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_multAdd = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":942
 *     FunctionBegin(b"MatMultAdd_Python")
 *     cdef multAdd = PyMat(mat).multAdd
 *     cdef PetscVec t = NULL             # <<<<<<<<<<<<<<
 * 
 *     if multAdd is None:
 */
  __pyx_v_t = NULL;

  /* "libpetsc4py.pyx":944
 *     cdef PetscVec t = NULL
 * 
 *     if multAdd is None:             # <<<<<<<<<<<<<<
 *         if v == y:
 *             CHKERR( VecDuplicate(y, &t) )
 */
  __pyx_t_3 = (__pyx_v_multAdd == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":945
 * 
 *     if multAdd is None:
 *         if v == y:             # <<<<<<<<<<<<<<
 *             CHKERR( VecDuplicate(y, &t) )
 *             CHKERR( MatMult(mat,x,t) )
 */
    __pyx_t_4 = ((__pyx_v_v == __pyx_v_y) != 0);
    if (__pyx_t_4) {

      /* "libpetsc4py.pyx":946
 *     if multAdd is None:
 *         if v == y:
 *             CHKERR( VecDuplicate(y, &t) )             # <<<<<<<<<<<<<<
 *             CHKERR( MatMult(mat,x,t) )
 *             CHKERR( VecAXPY(y,1.0,t) )
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(VecDuplicate(__pyx_v_y, (&__pyx_v_t))); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 946, __pyx_L1_error)

      /* "libpetsc4py.pyx":947
 *         if v == y:
 *             CHKERR( VecDuplicate(y, &t) )
 *             CHKERR( MatMult(mat,x,t) )             # <<<<<<<<<<<<<<
 *             CHKERR( VecAXPY(y,1.0,t) )
 *             CHKERR( VecDestroy(&t) )
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatMult(__pyx_v_mat, __pyx_v_x, __pyx_v_t)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 947, __pyx_L1_error)

      /* "libpetsc4py.pyx":948
 *             CHKERR( VecDuplicate(y, &t) )
 *             CHKERR( MatMult(mat,x,t) )
 *             CHKERR( VecAXPY(y,1.0,t) )             # <<<<<<<<<<<<<<
 *             CHKERR( VecDestroy(&t) )
 *         else:
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(VecAXPY(__pyx_v_y, 1.0, __pyx_v_t)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 948, __pyx_L1_error)

      /* "libpetsc4py.pyx":949
 *             CHKERR( MatMult(mat,x,t) )
 *             CHKERR( VecAXPY(y,1.0,t) )
 *             CHKERR( VecDestroy(&t) )             # <<<<<<<<<<<<<<
 *         else:
 *             CHKERR( MatMult(mat,x,y) )
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(VecDestroy((&__pyx_v_t))); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 949, __pyx_L1_error)

      /* "libpetsc4py.pyx":945
 * 
 *     if multAdd is None:
 *         if v == y:             # <<<<<<<<<<<<<<
 *             CHKERR( VecDuplicate(y, &t) )
 *             CHKERR( MatMult(mat,x,t) )
 */
      goto __pyx_L4;
    }

    /* "libpetsc4py.pyx":951
 *             CHKERR( VecDestroy(&t) )
 *         else:
 *             CHKERR( MatMult(mat,x,y) )             # <<<<<<<<<<<<<<
 *             CHKERR( VecAXPY(y,1.0,v) )
 *         return FunctionEnd()
 */
    /*else*/ {
      __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatMult(__pyx_v_mat, __pyx_v_x, __pyx_v_y)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 951, __pyx_L1_error)

      /* "libpetsc4py.pyx":952
 *         else:
 *             CHKERR( MatMult(mat,x,y) )
 *             CHKERR( VecAXPY(y,1.0,v) )             # <<<<<<<<<<<<<<
 *         return FunctionEnd()
 *     if multAdd is None: return UNSUPPORTED(b"multAdd")
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(VecAXPY(__pyx_v_y, 1.0, __pyx_v_v)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 952, __pyx_L1_error)
    }
    __pyx_L4:;

    /* "libpetsc4py.pyx":953
 *             CHKERR( MatMult(mat,x,y) )
 *             CHKERR( VecAXPY(y,1.0,v) )
 *         return FunctionEnd()             # <<<<<<<<<<<<<<
 *     if multAdd is None: return UNSUPPORTED(b"multAdd")
 *     multAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))
 */
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;

    /* "libpetsc4py.pyx":944
 *     cdef PetscVec t = NULL
 * 
 *     if multAdd is None:             # <<<<<<<<<<<<<<
 *         if v == y:
 *             CHKERR( VecDuplicate(y, &t) )
 */
  }

  /* "libpetsc4py.pyx":954
 *             CHKERR( VecAXPY(y,1.0,v) )
 *         return FunctionEnd()
 *     if multAdd is None: return UNSUPPORTED(b"multAdd")             # <<<<<<<<<<<<<<
 *     multAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_multAdd == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"multAdd"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":955
 *         return FunctionEnd()
 *     if multAdd is None: return UNSUPPORTED(b"multAdd")
 *     multAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 955, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 955, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_v)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 955, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 955, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_multAdd);
  __pyx_t_9 = __pyx_v_multAdd; __pyx_t_10 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 955, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 955, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 955, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_5, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_5, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_5, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_5, __pyx_t_8);
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 955, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":956
 *     if multAdd is None: return UNSUPPORTED(b"multAdd")
 *     multAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatMultTransposeAdd_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":933
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultAdd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __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_11);
  __Pyx_AddTraceback("libpetsc4py.MatMultAdd_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_multAdd);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":958
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultTransposeAdd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatMultTransposeAdd_Python(Mat __pyx_v_mat, Vec __pyx_v_x, Vec __pyx_v_v, Vec __pyx_v_y) {
  PyObject *__pyx_v_multTransposeAdd = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatMultTransposeAdd_Python", 0);

  /* "libpetsc4py.pyx":965
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultTransposeAdd_Python")             # <<<<<<<<<<<<<<
 *     cdef multTransposeAdd = PyMat(mat).multTransposeAdd
 *     if multTransposeAdd is None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatMultTransposeAdd_Python"));

  /* "libpetsc4py.pyx":966
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultTransposeAdd_Python")
 *     cdef multTransposeAdd = PyMat(mat).multTransposeAdd             # <<<<<<<<<<<<<<
 *     if multTransposeAdd is None:
 *         CHKERR( MatMultTranspose(mat,x,y) )
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_multTransposeAdd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_multTransposeAdd = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":967
 *     FunctionBegin(b"MatMultTransposeAdd_Python")
 *     cdef multTransposeAdd = PyMat(mat).multTransposeAdd
 *     if multTransposeAdd is None:             # <<<<<<<<<<<<<<
 *         CHKERR( MatMultTranspose(mat,x,y) )
 *         CHKERR( VecAXPY(y,1.0,v)          )
 */
  __pyx_t_3 = (__pyx_v_multTransposeAdd == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":968
 *     cdef multTransposeAdd = PyMat(mat).multTransposeAdd
 *     if multTransposeAdd is None:
 *         CHKERR( MatMultTranspose(mat,x,y) )             # <<<<<<<<<<<<<<
 *         CHKERR( VecAXPY(y,1.0,v)          )
 *         return FunctionEnd()
 */
    __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatMultTranspose(__pyx_v_mat, __pyx_v_x, __pyx_v_y)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 968, __pyx_L1_error)

    /* "libpetsc4py.pyx":969
 *     if multTransposeAdd is None:
 *         CHKERR( MatMultTranspose(mat,x,y) )
 *         CHKERR( VecAXPY(y,1.0,v)          )             # <<<<<<<<<<<<<<
 *         return FunctionEnd()
 *     if multTransposeAdd is None: return UNSUPPORTED(b"multTransposeAdd")
 */
    __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(VecAXPY(__pyx_v_y, 1.0, __pyx_v_v)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 969, __pyx_L1_error)

    /* "libpetsc4py.pyx":970
 *         CHKERR( MatMultTranspose(mat,x,y) )
 *         CHKERR( VecAXPY(y,1.0,v)          )
 *         return FunctionEnd()             # <<<<<<<<<<<<<<
 *     if multTransposeAdd is None: return UNSUPPORTED(b"multTransposeAdd")
 *     multTransposeAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))
 */
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;

    /* "libpetsc4py.pyx":967
 *     FunctionBegin(b"MatMultTransposeAdd_Python")
 *     cdef multTransposeAdd = PyMat(mat).multTransposeAdd
 *     if multTransposeAdd is None:             # <<<<<<<<<<<<<<
 *         CHKERR( MatMultTranspose(mat,x,y) )
 *         CHKERR( VecAXPY(y,1.0,v)          )
 */
  }

  /* "libpetsc4py.pyx":971
 *         CHKERR( VecAXPY(y,1.0,v)          )
 *         return FunctionEnd()
 *     if multTransposeAdd is None: return UNSUPPORTED(b"multTransposeAdd")             # <<<<<<<<<<<<<<
 *     multTransposeAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_multTransposeAdd == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"multTransposeAdd"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":972
 *         return FunctionEnd()
 *     if multTransposeAdd is None: return UNSUPPORTED(b"multTransposeAdd")
 *     multTransposeAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 972, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 972, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_v)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 972, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 972, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_multTransposeAdd);
  __pyx_t_9 = __pyx_v_multTransposeAdd; __pyx_t_10 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_5, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_5, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_5, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_5, __pyx_t_8);
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":973
 *     if multTransposeAdd is None: return UNSUPPORTED(b"multTransposeAdd")
 *     multTransposeAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatMultHermitianAdd_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":958
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultTransposeAdd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __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_11);
  __Pyx_AddTraceback("libpetsc4py.MatMultTransposeAdd_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_multTransposeAdd);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":975
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultHermitianAdd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatMultHermitianAdd_Python(Mat __pyx_v_mat, Vec __pyx_v_x, Vec __pyx_v_v, Vec __pyx_v_y) {
  PyObject *__pyx_v_multHermitianAdd = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatMultHermitianAdd_Python", 0);

  /* "libpetsc4py.pyx":982
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultHermitianAdd_Python")             # <<<<<<<<<<<<<<
 *     cdef multHermitianAdd = PyMat(mat).multHermitianAdd
 *     if multHermitianAdd is None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatMultHermitianAdd_Python"));

  /* "libpetsc4py.pyx":983
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultHermitianAdd_Python")
 *     cdef multHermitianAdd = PyMat(mat).multHermitianAdd             # <<<<<<<<<<<<<<
 *     if multHermitianAdd is None:
 *         CHKERR( MatMultHermitian(mat,x,y) )
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_multHermitianAdd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_multHermitianAdd = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":984
 *     FunctionBegin(b"MatMultHermitianAdd_Python")
 *     cdef multHermitianAdd = PyMat(mat).multHermitianAdd
 *     if multHermitianAdd is None:             # <<<<<<<<<<<<<<
 *         CHKERR( MatMultHermitian(mat,x,y) )
 *         CHKERR( VecAXPY(y,1.0,v)          )
 */
  __pyx_t_3 = (__pyx_v_multHermitianAdd == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":985
 *     cdef multHermitianAdd = PyMat(mat).multHermitianAdd
 *     if multHermitianAdd is None:
 *         CHKERR( MatMultHermitian(mat,x,y) )             # <<<<<<<<<<<<<<
 *         CHKERR( VecAXPY(y,1.0,v)          )
 *         return FunctionEnd()
 */
    __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatMultHermitianTranspose(__pyx_v_mat, __pyx_v_x, __pyx_v_y)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 985, __pyx_L1_error)

    /* "libpetsc4py.pyx":986
 *     if multHermitianAdd is None:
 *         CHKERR( MatMultHermitian(mat,x,y) )
 *         CHKERR( VecAXPY(y,1.0,v)          )             # <<<<<<<<<<<<<<
 *         return FunctionEnd()
 *     if multHermitianAdd is None: return UNSUPPORTED(b"multHermitianAdd")
 */
    __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(VecAXPY(__pyx_v_y, 1.0, __pyx_v_v)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 986, __pyx_L1_error)

    /* "libpetsc4py.pyx":987
 *         CHKERR( MatMultHermitian(mat,x,y) )
 *         CHKERR( VecAXPY(y,1.0,v)          )
 *         return FunctionEnd()             # <<<<<<<<<<<<<<
 *     if multHermitianAdd is None: return UNSUPPORTED(b"multHermitianAdd")
 *     multHermitianAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))
 */
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;

    /* "libpetsc4py.pyx":984
 *     FunctionBegin(b"MatMultHermitianAdd_Python")
 *     cdef multHermitianAdd = PyMat(mat).multHermitianAdd
 *     if multHermitianAdd is None:             # <<<<<<<<<<<<<<
 *         CHKERR( MatMultHermitian(mat,x,y) )
 *         CHKERR( VecAXPY(y,1.0,v)          )
 */
  }

  /* "libpetsc4py.pyx":988
 *         CHKERR( VecAXPY(y,1.0,v)          )
 *         return FunctionEnd()
 *     if multHermitianAdd is None: return UNSUPPORTED(b"multHermitianAdd")             # <<<<<<<<<<<<<<
 *     multHermitianAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_multHermitianAdd == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"multHermitianAdd"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":989
 *         return FunctionEnd()
 *     if multHermitianAdd is None: return UNSUPPORTED(b"multHermitianAdd")
 *     multHermitianAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 989, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 989, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_v)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 989, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 989, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_multHermitianAdd);
  __pyx_t_9 = __pyx_v_multHermitianAdd; __pyx_t_10 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 989, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 989, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 989, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_5, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_5, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_5, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_5, __pyx_t_8);
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 989, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":990
 *     if multHermitianAdd is None: return UNSUPPORTED(b"multHermitianAdd")
 *     multHermitianAdd(Mat_(mat), Vec_(x), Vec_(v), Vec_(y))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatMultDiagonalBlock_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":975
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultHermitianAdd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __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_11);
  __Pyx_AddTraceback("libpetsc4py.MatMultHermitianAdd_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_multHermitianAdd);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":992
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultDiagonalBlock_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatMultDiagonalBlock_Python(Mat __pyx_v_mat, Vec __pyx_v_x, Vec __pyx_v_y) {
  PyObject *__pyx_v_multDiagonalBlock = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatMultDiagonalBlock_Python", 0);

  /* "libpetsc4py.pyx":998
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultDiagonalBlock_Python")             # <<<<<<<<<<<<<<
 *     cdef multDiagonalBlock = PyMat(mat).multDiagonalBlock
 *     if multDiagonalBlock is None: return UNSUPPORTED(b"multDiagonalBlock")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatMultDiagonalBlock_Python"));

  /* "libpetsc4py.pyx":999
 *     except IERR with gil:
 *     FunctionBegin(b"MatMultDiagonalBlock_Python")
 *     cdef multDiagonalBlock = PyMat(mat).multDiagonalBlock             # <<<<<<<<<<<<<<
 *     if multDiagonalBlock is None: return UNSUPPORTED(b"multDiagonalBlock")
 *     multDiagonalBlock(Mat_(mat), Vec_(x), Vec_(y))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 999, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_multDiagonalBlock); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 999, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_multDiagonalBlock = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1000
 *     FunctionBegin(b"MatMultDiagonalBlock_Python")
 *     cdef multDiagonalBlock = PyMat(mat).multDiagonalBlock
 *     if multDiagonalBlock is None: return UNSUPPORTED(b"multDiagonalBlock")             # <<<<<<<<<<<<<<
 *     multDiagonalBlock(Mat_(mat), Vec_(x), Vec_(y))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_multDiagonalBlock == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"multDiagonalBlock"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1001
 *     cdef multDiagonalBlock = PyMat(mat).multDiagonalBlock
 *     if multDiagonalBlock is None: return UNSUPPORTED(b"multDiagonalBlock")
 *     multDiagonalBlock(Mat_(mat), Vec_(x), Vec_(y))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_multDiagonalBlock);
  __pyx_t_7 = __pyx_v_multDiagonalBlock; __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  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_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1001, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1001, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1001, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1001, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1002
 *     if multDiagonalBlock is None: return UNSUPPORTED(b"multDiagonalBlock")
 *     multDiagonalBlock(Mat_(mat), Vec_(x), Vec_(y))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatSolve_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":992
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMultDiagonalBlock_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.MatMultDiagonalBlock_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_multDiagonalBlock);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1004
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSolve_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec b,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatSolve_Python(Mat __pyx_v_mat, Vec __pyx_v_b, Vec __pyx_v_x) {
  PyObject *__pyx_v_solve = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatSolve_Python", 0);

  /* "libpetsc4py.pyx":1010
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatSolve_Python")             # <<<<<<<<<<<<<<
 *     cdef solve = PyMat(mat).solve
 *     if solve is None: return UNSUPPORTED(b"solve")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatSolve_Python"));

  /* "libpetsc4py.pyx":1011
 *     except IERR with gil:
 *     FunctionBegin(b"MatSolve_Python")
 *     cdef solve = PyMat(mat).solve             # <<<<<<<<<<<<<<
 *     if solve is None: return UNSUPPORTED(b"solve")
 *     solve(Mat_(mat), Vec_(b), Vec_(x))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1011, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_solve); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1011, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_solve = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1012
 *     FunctionBegin(b"MatSolve_Python")
 *     cdef solve = PyMat(mat).solve
 *     if solve is None: return UNSUPPORTED(b"solve")             # <<<<<<<<<<<<<<
 *     solve(Mat_(mat), Vec_(b), Vec_(x))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_solve == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"solve"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1013
 *     cdef solve = PyMat(mat).solve
 *     if solve is None: return UNSUPPORTED(b"solve")
 *     solve(Mat_(mat), Vec_(b), Vec_(x))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_b)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_solve);
  __pyx_t_7 = __pyx_v_solve; __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  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_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1013, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1013, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1013, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1013, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1014
 *     if solve is None: return UNSUPPORTED(b"solve")
 *     solve(Mat_(mat), Vec_(b), Vec_(x))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatSolveTranspose_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1004
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSolve_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec b,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.MatSolve_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_solve);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1016
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSolveTranspose_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec b,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatSolveTranspose_Python(Mat __pyx_v_mat, Vec __pyx_v_b, Vec __pyx_v_x) {
  PyObject *__pyx_v_solveTranspose = 0;
  PetscBool __pyx_v_symmset;
  PetscBool __pyx_v_symmknown;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatSolveTranspose_Python", 0);

  /* "libpetsc4py.pyx":1022
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatSolveTranspose_Python")             # <<<<<<<<<<<<<<
 *     cdef solveTranspose = PyMat(mat).solveTranspose
 *     cdef PetscBool symmset, symmknown
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatSolveTranspose_Python"));

  /* "libpetsc4py.pyx":1023
 *     except IERR with gil:
 *     FunctionBegin(b"MatSolveTranspose_Python")
 *     cdef solveTranspose = PyMat(mat).solveTranspose             # <<<<<<<<<<<<<<
 *     cdef PetscBool symmset, symmknown
 *     if solveTranspose is None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1023, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_solveTranspose); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1023, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_solveTranspose = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1025
 *     cdef solveTranspose = PyMat(mat).solveTranspose
 *     cdef PetscBool symmset, symmknown
 *     if solveTranspose is None:             # <<<<<<<<<<<<<<
 *         symmset = symmknown = PETSC_FALSE
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 */
  __pyx_t_3 = (__pyx_v_solveTranspose == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1026
 *     cdef PetscBool symmset, symmknown
 *     if solveTranspose is None:
 *         symmset = symmknown = PETSC_FALSE             # <<<<<<<<<<<<<<
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 *         if symmset and symmknown:
 */
    __pyx_v_symmset = PETSC_FALSE;
    __pyx_v_symmknown = PETSC_FALSE;

    /* "libpetsc4py.pyx":1027
 *     if solveTranspose is None:
 *         symmset = symmknown = PETSC_FALSE
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )             # <<<<<<<<<<<<<<
 *         if symmset and symmknown:
 *             CHKERR( MatSolve(mat,b,x) )
 */
    __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatIsSymmetricKnown(__pyx_v_mat, (&__pyx_v_symmset), (&__pyx_v_symmknown))); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1027, __pyx_L1_error)

    /* "libpetsc4py.pyx":1028
 *         symmset = symmknown = PETSC_FALSE
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 *         if symmset and symmknown:             # <<<<<<<<<<<<<<
 *             CHKERR( MatSolve(mat,b,x) )
 *             return FunctionEnd()
 */
    if (__pyx_v_symmset) {
    } else {
      __pyx_t_4 = __pyx_v_symmset;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_4 = __pyx_v_symmknown;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_4) {

      /* "libpetsc4py.pyx":1029
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 *         if symmset and symmknown:
 *             CHKERR( MatSolve(mat,b,x) )             # <<<<<<<<<<<<<<
 *             return FunctionEnd()
 *     if solveTranspose is None: return UNSUPPORTED(b"solveTranspose")
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatSolve(__pyx_v_mat, __pyx_v_b, __pyx_v_x)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1029, __pyx_L1_error)

      /* "libpetsc4py.pyx":1030
 *         if symmset and symmknown:
 *             CHKERR( MatSolve(mat,b,x) )
 *             return FunctionEnd()             # <<<<<<<<<<<<<<
 *     if solveTranspose is None: return UNSUPPORTED(b"solveTranspose")
 *     solveTranspose(Mat_(mat), Vec_(b), Vec_(x))
 */
      __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
      goto __pyx_L0;

      /* "libpetsc4py.pyx":1028
 *         symmset = symmknown = PETSC_FALSE
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 *         if symmset and symmknown:             # <<<<<<<<<<<<<<
 *             CHKERR( MatSolve(mat,b,x) )
 *             return FunctionEnd()
 */
    }

    /* "libpetsc4py.pyx":1025
 *     cdef solveTranspose = PyMat(mat).solveTranspose
 *     cdef PetscBool symmset, symmknown
 *     if solveTranspose is None:             # <<<<<<<<<<<<<<
 *         symmset = symmknown = PETSC_FALSE
 *         CHKERR( MatIsSymmetricKnown(mat,&symmset,&symmknown) )
 */
  }

  /* "libpetsc4py.pyx":1031
 *             CHKERR( MatSolve(mat,b,x) )
 *             return FunctionEnd()
 *     if solveTranspose is None: return UNSUPPORTED(b"solveTranspose")             # <<<<<<<<<<<<<<
 *     solveTranspose(Mat_(mat), Vec_(b), Vec_(x))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_solveTranspose == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"solveTranspose"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1032
 *             return FunctionEnd()
 *     if solveTranspose is None: return UNSUPPORTED(b"solveTranspose")
 *     solveTranspose(Mat_(mat), Vec_(b), Vec_(x))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1032, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_b)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1032, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1032, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_solveTranspose);
  __pyx_t_8 = __pyx_v_solveTranspose; __pyx_t_9 = NULL;
  __pyx_t_5 = 0;
  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_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_1, __pyx_t_6, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1032, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_1, __pyx_t_6, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1032, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1032, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_5, __pyx_t_7);
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1032, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1033
 *     if solveTranspose is None: return UNSUPPORTED(b"solveTranspose")
 *     solveTranspose(Mat_(mat), Vec_(b), Vec_(x))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatSolveAdd_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1016
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSolveTranspose_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec b,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __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_AddTraceback("libpetsc4py.MatSolveTranspose_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_solveTranspose);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1035
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSolveAdd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec b,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatSolveAdd_Python(Mat __pyx_v_mat, Vec __pyx_v_b, Vec __pyx_v_y, Vec __pyx_v_x) {
  PyObject *__pyx_v_solveAdd = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatSolveAdd_Python", 0);

  /* "libpetsc4py.pyx":1042
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatSolveAdd_Python")             # <<<<<<<<<<<<<<
 *     cdef solveAdd = PyMat(mat).solveAdd
 *     if solveAdd is None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatSolveAdd_Python"));

  /* "libpetsc4py.pyx":1043
 *     except IERR with gil:
 *     FunctionBegin(b"MatSolveAdd_Python")
 *     cdef solveAdd = PyMat(mat).solveAdd             # <<<<<<<<<<<<<<
 *     if solveAdd is None:
 *         CHKERR( MatSolve(mat,b,x) )
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_solveAdd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_solveAdd = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1044
 *     FunctionBegin(b"MatSolveAdd_Python")
 *     cdef solveAdd = PyMat(mat).solveAdd
 *     if solveAdd is None:             # <<<<<<<<<<<<<<
 *         CHKERR( MatSolve(mat,b,x) )
 *         CHKERR( VecAXPY(x,1.0,y)  )
 */
  __pyx_t_3 = (__pyx_v_solveAdd == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1045
 *     cdef solveAdd = PyMat(mat).solveAdd
 *     if solveAdd is None:
 *         CHKERR( MatSolve(mat,b,x) )             # <<<<<<<<<<<<<<
 *         CHKERR( VecAXPY(x,1.0,y)  )
 *         return FunctionEnd()
 */
    __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatSolve(__pyx_v_mat, __pyx_v_b, __pyx_v_x)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1045, __pyx_L1_error)

    /* "libpetsc4py.pyx":1046
 *     if solveAdd is None:
 *         CHKERR( MatSolve(mat,b,x) )
 *         CHKERR( VecAXPY(x,1.0,y)  )             # <<<<<<<<<<<<<<
 *         return FunctionEnd()
 *     if solveAdd is None: return UNSUPPORTED(b"solveAdd")
 */
    __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(VecAXPY(__pyx_v_x, 1.0, __pyx_v_y)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1046, __pyx_L1_error)

    /* "libpetsc4py.pyx":1047
 *         CHKERR( MatSolve(mat,b,x) )
 *         CHKERR( VecAXPY(x,1.0,y)  )
 *         return FunctionEnd()             # <<<<<<<<<<<<<<
 *     if solveAdd is None: return UNSUPPORTED(b"solveAdd")
 *     solveAdd(Mat_(mat), Vec_(b), Vec_(y), Vec_(x))
 */
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;

    /* "libpetsc4py.pyx":1044
 *     FunctionBegin(b"MatSolveAdd_Python")
 *     cdef solveAdd = PyMat(mat).solveAdd
 *     if solveAdd is None:             # <<<<<<<<<<<<<<
 *         CHKERR( MatSolve(mat,b,x) )
 *         CHKERR( VecAXPY(x,1.0,y)  )
 */
  }

  /* "libpetsc4py.pyx":1048
 *         CHKERR( VecAXPY(x,1.0,y)  )
 *         return FunctionEnd()
 *     if solveAdd is None: return UNSUPPORTED(b"solveAdd")             # <<<<<<<<<<<<<<
 *     solveAdd(Mat_(mat), Vec_(b), Vec_(y), Vec_(x))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_solveAdd == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"solveAdd"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1049
 *         return FunctionEnd()
 *     if solveAdd is None: return UNSUPPORTED(b"solveAdd")
 *     solveAdd(Mat_(mat), Vec_(b), Vec_(y), Vec_(x))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1049, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_b)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1049, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1049, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1049, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_solveAdd);
  __pyx_t_9 = __pyx_v_solveAdd; __pyx_t_10 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1049, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1049, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_5, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_5, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_5, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_5, __pyx_t_8);
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1050
 *     if solveAdd is None: return UNSUPPORTED(b"solveAdd")
 *     solveAdd(Mat_(mat), Vec_(b), Vec_(y), Vec_(x))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatSolveTransposeAdd_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1035
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSolveAdd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec b,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __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_11);
  __Pyx_AddTraceback("libpetsc4py.MatSolveAdd_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_solveAdd);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1052
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSolveTransposeAdd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec b,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatSolveTransposeAdd_Python(Mat __pyx_v_mat, Vec __pyx_v_b, Vec __pyx_v_y, Vec __pyx_v_x) {
  PyObject *__pyx_v_solveTransposeAdd = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatSolveTransposeAdd_Python", 0);

  /* "libpetsc4py.pyx":1059
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatSolveTransposeAdd_Python")             # <<<<<<<<<<<<<<
 *     cdef solveTransposeAdd = PyMat(mat).solveTransposeAdd
 *     if solveTransposeAdd is None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatSolveTransposeAdd_Python"));

  /* "libpetsc4py.pyx":1060
 *     except IERR with gil:
 *     FunctionBegin(b"MatSolveTransposeAdd_Python")
 *     cdef solveTransposeAdd = PyMat(mat).solveTransposeAdd             # <<<<<<<<<<<<<<
 *     if solveTransposeAdd is None:
 *         CHKERR( MatSolveTranspose(mat,b,x) )
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_solveTransposeAdd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_solveTransposeAdd = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1061
 *     FunctionBegin(b"MatSolveTransposeAdd_Python")
 *     cdef solveTransposeAdd = PyMat(mat).solveTransposeAdd
 *     if solveTransposeAdd is None:             # <<<<<<<<<<<<<<
 *         CHKERR( MatSolveTranspose(mat,b,x) )
 *         CHKERR( VecAXPY(x,1.0,y)           )
 */
  __pyx_t_3 = (__pyx_v_solveTransposeAdd == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1062
 *     cdef solveTransposeAdd = PyMat(mat).solveTransposeAdd
 *     if solveTransposeAdd is None:
 *         CHKERR( MatSolveTranspose(mat,b,x) )             # <<<<<<<<<<<<<<
 *         CHKERR( VecAXPY(x,1.0,y)           )
 *         return FunctionEnd()
 */
    __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(MatSolveTranspose(__pyx_v_mat, __pyx_v_b, __pyx_v_x)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1062, __pyx_L1_error)

    /* "libpetsc4py.pyx":1063
 *     if solveTransposeAdd is None:
 *         CHKERR( MatSolveTranspose(mat,b,x) )
 *         CHKERR( VecAXPY(x,1.0,y)           )             # <<<<<<<<<<<<<<
 *         return FunctionEnd()
 *     if solveTransposeAdd is None: return UNSUPPORTED(b"solveTransposeAdd")
 */
    __pyx_t_5 = __pyx_f_11libpetsc4py_CHKERR(VecAXPY(__pyx_v_x, 1.0, __pyx_v_y)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1063, __pyx_L1_error)

    /* "libpetsc4py.pyx":1064
 *         CHKERR( MatSolveTranspose(mat,b,x) )
 *         CHKERR( VecAXPY(x,1.0,y)           )
 *         return FunctionEnd()             # <<<<<<<<<<<<<<
 *     if solveTransposeAdd is None: return UNSUPPORTED(b"solveTransposeAdd")
 *     solveTransposeAdd(Mat_(mat), Vec_(b), Vec_(y), Vec_(x))
 */
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;

    /* "libpetsc4py.pyx":1061
 *     FunctionBegin(b"MatSolveTransposeAdd_Python")
 *     cdef solveTransposeAdd = PyMat(mat).solveTransposeAdd
 *     if solveTransposeAdd is None:             # <<<<<<<<<<<<<<
 *         CHKERR( MatSolveTranspose(mat,b,x) )
 *         CHKERR( VecAXPY(x,1.0,y)           )
 */
  }

  /* "libpetsc4py.pyx":1065
 *         CHKERR( VecAXPY(x,1.0,y)           )
 *         return FunctionEnd()
 *     if solveTransposeAdd is None: return UNSUPPORTED(b"solveTransposeAdd")             # <<<<<<<<<<<<<<
 *     solveTransposeAdd(Mat_(mat), Vec_(b), Vec_(y), Vec_(x))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_solveTransposeAdd == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"solveTransposeAdd"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1066
 *         return FunctionEnd()
 *     if solveTransposeAdd is None: return UNSUPPORTED(b"solveTransposeAdd")
 *     solveTransposeAdd(Mat_(mat), Vec_(b), Vec_(y), Vec_(x))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_b)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_solveTransposeAdd);
  __pyx_t_9 = __pyx_v_solveTransposeAdd; __pyx_t_10 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1066, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_1, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1066, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1066, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_5, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_5, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_5, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_5, __pyx_t_8);
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1066, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1067
 *     if solveTransposeAdd is None: return UNSUPPORTED(b"solveTransposeAdd")
 *     solveTransposeAdd(Mat_(mat), Vec_(b), Vec_(y), Vec_(x))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatSOR_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1052
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSolveTransposeAdd_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec b,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __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_11);
  __Pyx_AddTraceback("libpetsc4py.MatSolveTransposeAdd_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_solveTransposeAdd);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1069
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSOR_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec b,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatSOR_Python(Mat __pyx_v_mat, Vec __pyx_v_b, PetscReal __pyx_v_omega, MatSORType __pyx_v_sortype, PetscReal __pyx_v_shift, PetscInt __pyx_v_its, PetscInt __pyx_v_lits, Vec __pyx_v_x) {
  PyObject *__pyx_v_SOR = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PetscReal __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PetscInt __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatSOR_Python", 0);

  /* "libpetsc4py.pyx":1080
 *     )\
 *     except IERR with gil:
 *     FunctionBegin(b"MatSOR_Python")             # <<<<<<<<<<<<<<
 *     cdef SOR = PyMat(mat).SOR
 *     if SOR is None: return UNSUPPORTED(b"SOR")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatSOR_Python"));

  /* "libpetsc4py.pyx":1081
 *     except IERR with gil:
 *     FunctionBegin(b"MatSOR_Python")
 *     cdef SOR = PyMat(mat).SOR             # <<<<<<<<<<<<<<
 *     if SOR is None: return UNSUPPORTED(b"SOR")
 *     SOR(Mat_(mat), Vec_(b), asReal(omega), asInt(sortype), asReal(shift), asInt(its), asInt(lits), Vec_(x))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1081, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_SOR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1081, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_SOR = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1082
 *     FunctionBegin(b"MatSOR_Python")
 *     cdef SOR = PyMat(mat).SOR
 *     if SOR is None: return UNSUPPORTED(b"SOR")             # <<<<<<<<<<<<<<
 *     SOR(Mat_(mat), Vec_(b), asReal(omega), asInt(sortype), asReal(shift), asInt(its), asInt(lits), Vec_(x))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_SOR == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"SOR"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1083
 *     cdef SOR = PyMat(mat).SOR
 *     if SOR is None: return UNSUPPORTED(b"SOR")
 *     SOR(Mat_(mat), Vec_(b), asReal(omega), asInt(sortype), asReal(shift), asInt(its), asInt(lits), Vec_(x))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_b)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_omega); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __pyx_f_11libpetsc4py_asReal(__pyx_t_6); if (unlikely(__pyx_t_7 == ((PetscReal)-1.0) && PyErr_Occurred())) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyFloat_FromDouble(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyInt_From_MatSORType(__pyx_v_sortype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __pyx_f_11libpetsc4py_asInt(__pyx_t_8); if (unlikely(__pyx_t_9 == ((PetscInt)-1L) && PyErr_Occurred())) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyInt_From_PetscInt(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_10 = PyFloat_FromDouble(__pyx_v_shift); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_7 = __pyx_f_11libpetsc4py_asReal(__pyx_t_10); if (unlikely(__pyx_t_7 == ((PetscReal)-1.0) && PyErr_Occurred())) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = PyFloat_FromDouble(__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __Pyx_PyInt_From_PetscInt(__pyx_v_its); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_9 = __pyx_f_11libpetsc4py_asInt(__pyx_t_11); if (unlikely(__pyx_t_9 == ((PetscInt)-1L) && PyErr_Occurred())) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyInt_From_PetscInt(__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = __Pyx_PyInt_From_PetscInt(__pyx_v_lits); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_9 = __pyx_f_11libpetsc4py_asInt(__pyx_t_12); if (unlikely(__pyx_t_9 == ((PetscInt)-1L) && PyErr_Occurred())) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyInt_From_PetscInt(__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_INCREF(__pyx_v_SOR);
  __pyx_t_14 = __pyx_v_SOR; __pyx_t_15 = NULL;
  __pyx_t_16 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
      __pyx_t_16 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_14)) {
    PyObject *__pyx_temp[9] = {__pyx_t_15, __pyx_t_1, __pyx_t_5, __pyx_t_6, __pyx_t_8, __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_16, 8+__pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1083, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
    PyObject *__pyx_temp[9] = {__pyx_t_15, __pyx_t_1, __pyx_t_5, __pyx_t_6, __pyx_t_8, __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_16, 8+__pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1083, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  {
    __pyx_t_17 = PyTuple_New(8+__pyx_t_16); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1083, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    if (__pyx_t_15) {
      __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_15); __pyx_t_15 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_16, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_16, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_17, 2+__pyx_t_16, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_17, 3+__pyx_t_16, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_17, 4+__pyx_t_16, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_17, 5+__pyx_t_16, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_17, 6+__pyx_t_16, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_17, 7+__pyx_t_16, __pyx_t_13);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_8 = 0;
    __pyx_t_10 = 0;
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1083, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  }
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1084
 *     if SOR is None: return UNSUPPORTED(b"SOR")
 *     SOR(Mat_(mat), Vec_(b), asReal(omega), asInt(sortype), asReal(shift), asInt(its), asInt(lits), Vec_(x))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatGetDiagonal_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1069
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSOR_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec b,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("libpetsc4py.MatSOR_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_SOR);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1086
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatGetDiagonal_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec v,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatGetDiagonal_Python(Mat __pyx_v_mat, Vec __pyx_v_v) {
  PyObject *__pyx_v_getDiagonal = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatGetDiagonal_Python", 0);

  /* "libpetsc4py.pyx":1091
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatGetDiagonal_Python")             # <<<<<<<<<<<<<<
 *     cdef getDiagonal = PyMat(mat).getDiagonal
 *     if getDiagonal is None: return UNSUPPORTED(b"getDiagonal")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatGetDiagonal_Python"));

  /* "libpetsc4py.pyx":1092
 *     except IERR with gil:
 *     FunctionBegin(b"MatGetDiagonal_Python")
 *     cdef getDiagonal = PyMat(mat).getDiagonal             # <<<<<<<<<<<<<<
 *     if getDiagonal is None: return UNSUPPORTED(b"getDiagonal")
 *     getDiagonal(Mat_(mat), Vec_(v))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1092, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_getDiagonal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1092, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_getDiagonal = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1093
 *     FunctionBegin(b"MatGetDiagonal_Python")
 *     cdef getDiagonal = PyMat(mat).getDiagonal
 *     if getDiagonal is None: return UNSUPPORTED(b"getDiagonal")             # <<<<<<<<<<<<<<
 *     getDiagonal(Mat_(mat), Vec_(v))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_getDiagonal == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"getDiagonal"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1094
 *     cdef getDiagonal = PyMat(mat).getDiagonal
 *     if getDiagonal is None: return UNSUPPORTED(b"getDiagonal")
 *     getDiagonal(Mat_(mat), Vec_(v))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1094, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_v)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1094, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_getDiagonal);
  __pyx_t_6 = __pyx_v_getDiagonal; __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1094, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __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_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1094, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1094, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1094, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1095
 *     if getDiagonal is None: return UNSUPPORTED(b"getDiagonal")
 *     getDiagonal(Mat_(mat), Vec_(v))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatSetDiagonal_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1086
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatGetDiagonal_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec v,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.MatGetDiagonal_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_getDiagonal);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1097
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSetDiagonal_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec v,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatSetDiagonal_Python(Mat __pyx_v_mat, Vec __pyx_v_v, InsertMode __pyx_v_im) {
  PyObject *__pyx_v_setDiagonal = 0;
  int __pyx_v_addv;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatSetDiagonal_Python", 0);

  /* "libpetsc4py.pyx":1103
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatSetDiagonal_Python")             # <<<<<<<<<<<<<<
 *     cdef setDiagonal = PyMat(mat).setDiagonal
 *     cdef bint addv = True if im == ADD_VALUES else False
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatSetDiagonal_Python"));

  /* "libpetsc4py.pyx":1104
 *     except IERR with gil:
 *     FunctionBegin(b"MatSetDiagonal_Python")
 *     cdef setDiagonal = PyMat(mat).setDiagonal             # <<<<<<<<<<<<<<
 *     cdef bint addv = True if im == ADD_VALUES else False
 *     if setDiagonal is None: return UNSUPPORTED(b"setDiagonal")
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_setDiagonal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_setDiagonal = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1105
 *     FunctionBegin(b"MatSetDiagonal_Python")
 *     cdef setDiagonal = PyMat(mat).setDiagonal
 *     cdef bint addv = True if im == ADD_VALUES else False             # <<<<<<<<<<<<<<
 *     if setDiagonal is None: return UNSUPPORTED(b"setDiagonal")
 *     setDiagonal(Mat_(mat), Vec_(v), addv)
 */
  if (((__pyx_v_im == ADD_VALUES) != 0)) {
    __pyx_t_3 = 1;
  } else {
    __pyx_t_3 = 0;
  }
  __pyx_v_addv = __pyx_t_3;

  /* "libpetsc4py.pyx":1106
 *     cdef setDiagonal = PyMat(mat).setDiagonal
 *     cdef bint addv = True if im == ADD_VALUES else False
 *     if setDiagonal is None: return UNSUPPORTED(b"setDiagonal")             # <<<<<<<<<<<<<<
 *     setDiagonal(Mat_(mat), Vec_(v), addv)
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_setDiagonal == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"setDiagonal"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1107
 *     cdef bint addv = True if im == ADD_VALUES else False
 *     if setDiagonal is None: return UNSUPPORTED(b"setDiagonal")
 *     setDiagonal(Mat_(mat), Vec_(v), addv)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_v)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_addv); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_setDiagonal);
  __pyx_t_7 = __pyx_v_setDiagonal; __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  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_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1107, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1107, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1108
 *     if setDiagonal is None: return UNSUPPORTED(b"setDiagonal")
 *     setDiagonal(Mat_(mat), Vec_(v), addv)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatDiagonalScale_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1097
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatSetDiagonal_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec v,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.MatSetDiagonal_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setDiagonal);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1110
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatDiagonalScale_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec l,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatDiagonalScale_Python(Mat __pyx_v_mat, Vec __pyx_v_l, Vec __pyx_v_r) {
  PyObject *__pyx_v_diagonalScale = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatDiagonalScale_Python", 0);

  /* "libpetsc4py.pyx":1116
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatDiagonalScale_Python")             # <<<<<<<<<<<<<<
 *     cdef diagonalScale = PyMat(mat).diagonalScale
 *     if diagonalScale is None: return UNSUPPORTED(b"diagonalScale")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatDiagonalScale_Python"));

  /* "libpetsc4py.pyx":1117
 *     except IERR with gil:
 *     FunctionBegin(b"MatDiagonalScale_Python")
 *     cdef diagonalScale = PyMat(mat).diagonalScale             # <<<<<<<<<<<<<<
 *     if diagonalScale is None: return UNSUPPORTED(b"diagonalScale")
 *     diagonalScale(Mat_(mat), Vec_(l), Vec_(r))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_diagonalScale); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_diagonalScale = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1118
 *     FunctionBegin(b"MatDiagonalScale_Python")
 *     cdef diagonalScale = PyMat(mat).diagonalScale
 *     if diagonalScale is None: return UNSUPPORTED(b"diagonalScale")             # <<<<<<<<<<<<<<
 *     diagonalScale(Mat_(mat), Vec_(l), Vec_(r))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_diagonalScale == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"diagonalScale"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1119
 *     cdef diagonalScale = PyMat(mat).diagonalScale
 *     if diagonalScale is None: return UNSUPPORTED(b"diagonalScale")
 *     diagonalScale(Mat_(mat), Vec_(l), Vec_(r))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_l)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_r)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_diagonalScale);
  __pyx_t_7 = __pyx_v_diagonalScale; __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  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_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1119, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1119, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1119, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1119, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1120
 *     if diagonalScale is None: return UNSUPPORTED(b"diagonalScale")
 *     diagonalScale(Mat_(mat), Vec_(l), Vec_(r))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatMissingDiagonal_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1110
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatDiagonalScale_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscVec l,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.MatDiagonalScale_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_diagonalScale);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1122
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMissingDiagonal_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscBool *missing,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatMissingDiagonal_Python(Mat __pyx_v_mat, PetscBool *__pyx_v_missing, PetscInt *__pyx_v_loc) {
  PyObject *__pyx_v_missingDiagonal = 0;
  PyObject *__pyx_v_pymissing = NULL;
  PyObject *__pyx_v_pyloc = NULL;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  PetscBool __pyx_t_8;
  PetscInt __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatMissingDiagonal_Python", 0);

  /* "libpetsc4py.pyx":1128
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatMissingDiagonal_Python")             # <<<<<<<<<<<<<<
 *     cdef missingDiagonal = PyMat(mat).missingDiagonal
 *     if missingDiagonal is None: return UNSUPPORTED(b"missingDiagonal")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatMissingDiagonal_Python"));

  /* "libpetsc4py.pyx":1129
 *     except IERR with gil:
 *     FunctionBegin(b"MatMissingDiagonal_Python")
 *     cdef missingDiagonal = PyMat(mat).missingDiagonal             # <<<<<<<<<<<<<<
 *     if missingDiagonal is None: return UNSUPPORTED(b"missingDiagonal")
 *     pymissing, pyloc = missingDiagonal(Mat_(mat))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_missingDiagonal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_missingDiagonal = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1130
 *     FunctionBegin(b"MatMissingDiagonal_Python")
 *     cdef missingDiagonal = PyMat(mat).missingDiagonal
 *     if missingDiagonal is None: return UNSUPPORTED(b"missingDiagonal")             # <<<<<<<<<<<<<<
 *     pymissing, pyloc = missingDiagonal(Mat_(mat))
 *     missing[0] = <PetscBool>pymissing
 */
  __pyx_t_3 = (__pyx_v_missingDiagonal == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"missingDiagonal"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1131
 *     cdef missingDiagonal = PyMat(mat).missingDiagonal
 *     if missingDiagonal is None: return UNSUPPORTED(b"missingDiagonal")
 *     pymissing, pyloc = missingDiagonal(Mat_(mat))             # <<<<<<<<<<<<<<
 *     missing[0] = <PetscBool>pymissing
 *     if loc:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_missingDiagonal);
  __pyx_t_5 = __pyx_v_missingDiagonal; __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1131, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1131, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1131, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1131, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    index = 0; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    index = 1; __pyx_t_1 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) __PYX_ERR(0, 1131, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1131, __pyx_L1_error)
    __pyx_L5_unpacking_done:;
  }
  __pyx_v_pymissing = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_pyloc = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":1132
 *     if missingDiagonal is None: return UNSUPPORTED(b"missingDiagonal")
 *     pymissing, pyloc = missingDiagonal(Mat_(mat))
 *     missing[0] = <PetscBool>pymissing             # <<<<<<<<<<<<<<
 *     if loc:
 *         loc[0] = asInt(pyloc)
 */
  __pyx_t_8 = ((PetscBool)__Pyx_PyInt_As_PetscBool(__pyx_v_pymissing)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1132, __pyx_L1_error)
  (__pyx_v_missing[0]) = ((PetscBool)__pyx_t_8);

  /* "libpetsc4py.pyx":1133
 *     pymissing, pyloc = missingDiagonal(Mat_(mat))
 *     missing[0] = <PetscBool>pymissing
 *     if loc:             # <<<<<<<<<<<<<<
 *         loc[0] = asInt(pyloc)
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_loc != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1134
 *     missing[0] = <PetscBool>pymissing
 *     if loc:
 *         loc[0] = asInt(pyloc)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_9 = __pyx_f_11libpetsc4py_asInt(__pyx_v_pyloc); if (unlikely(__pyx_t_9 == ((PetscInt)-1L) && PyErr_Occurred())) __PYX_ERR(0, 1134, __pyx_L1_error)
    (__pyx_v_loc[0]) = __pyx_t_9;

    /* "libpetsc4py.pyx":1133
 *     pymissing, pyloc = missingDiagonal(Mat_(mat))
 *     missing[0] = <PetscBool>pymissing
 *     if loc:             # <<<<<<<<<<<<<<
 *         loc[0] = asInt(pyloc)
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1135
 *     if loc:
 *         loc[0] = asInt(pyloc)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatNorm_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1122
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatMissingDiagonal_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     PetscBool *missing,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.MatMissingDiagonal_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_missingDiagonal);
  __Pyx_XDECREF(__pyx_v_pymissing);
  __Pyx_XDECREF(__pyx_v_pyloc);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1137
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatNorm_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     NormType ntype,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatNorm_Python(Mat __pyx_v_mat, NormType __pyx_v_ntype, PetscReal *__pyx_v_nrm) {
  PyObject *__pyx_v_norm = 0;
  PyObject *__pyx_v_retval = NULL;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PetscReal __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatNorm_Python", 0);

  /* "libpetsc4py.pyx":1143
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatNorm_Python")             # <<<<<<<<<<<<<<
 *     cdef norm = PyMat(mat).norm
 *     if norm is None: return UNSUPPORTED(b"norm")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatNorm_Python"));

  /* "libpetsc4py.pyx":1144
 *     except IERR with gil:
 *     FunctionBegin(b"MatNorm_Python")
 *     cdef norm = PyMat(mat).norm             # <<<<<<<<<<<<<<
 *     if norm is None: return UNSUPPORTED(b"norm")
 *     retval = norm(Mat_(mat), ntype)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_norm); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_norm = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1145
 *     FunctionBegin(b"MatNorm_Python")
 *     cdef norm = PyMat(mat).norm
 *     if norm is None: return UNSUPPORTED(b"norm")             # <<<<<<<<<<<<<<
 *     retval = norm(Mat_(mat), ntype)
 *     nrm[0] = <PetscReal>retval
 */
  __pyx_t_3 = (__pyx_v_norm == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"norm"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1146
 *     cdef norm = PyMat(mat).norm
 *     if norm is None: return UNSUPPORTED(b"norm")
 *     retval = norm(Mat_(mat), ntype)             # <<<<<<<<<<<<<<
 *     nrm[0] = <PetscReal>retval
 *     return FunctionEnd()
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyInt_From_NormType(__pyx_v_ntype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_norm);
  __pyx_t_6 = __pyx_v_norm; __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1146, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __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_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1146, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_retval = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1147
 *     if norm is None: return UNSUPPORTED(b"norm")
 *     retval = norm(Mat_(mat), ntype)
 *     nrm[0] = <PetscReal>retval             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_retval); if (unlikely((__pyx_t_10 == ((PetscReal)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1147, __pyx_L1_error)
  (__pyx_v_nrm[0]) = ((PetscReal)__pyx_t_10);

  /* "libpetsc4py.pyx":1148
 *     retval = norm(Mat_(mat), ntype)
 *     nrm[0] = <PetscReal>retval
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatRealPart_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1137
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatNorm_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     NormType ntype,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.MatNorm_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_norm);
  __Pyx_XDECREF(__pyx_v_retval);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1150
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatRealPart_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatRealPart_Python(Mat __pyx_v_mat) {
  PyObject *__pyx_v_realPart = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatRealPart_Python", 0);

  /* "libpetsc4py.pyx":1154
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatRealPart_Python")             # <<<<<<<<<<<<<<
 *     cdef realPart = PyMat(mat).realPart
 *     if realPart is None: return UNSUPPORTED(b"realPart")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatRealPart_Python"));

  /* "libpetsc4py.pyx":1155
 *     except IERR with gil:
 *     FunctionBegin(b"MatRealPart_Python")
 *     cdef realPart = PyMat(mat).realPart             # <<<<<<<<<<<<<<
 *     if realPart is None: return UNSUPPORTED(b"realPart")
 *     realPart(Mat_(mat))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_realPart); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_realPart = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1156
 *     FunctionBegin(b"MatRealPart_Python")
 *     cdef realPart = PyMat(mat).realPart
 *     if realPart is None: return UNSUPPORTED(b"realPart")             # <<<<<<<<<<<<<<
 *     realPart(Mat_(mat))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_realPart == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"realPart"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1157
 *     cdef realPart = PyMat(mat).realPart
 *     if realPart is None: return UNSUPPORTED(b"realPart")
 *     realPart(Mat_(mat))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_realPart);
  __pyx_t_5 = __pyx_v_realPart; __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1158
 *     if realPart is None: return UNSUPPORTED(b"realPart")
 *     realPart(Mat_(mat))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatImagPart_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1150
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatRealPart_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.MatRealPart_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_realPart);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1160
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatImagPart_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatImagPart_Python(Mat __pyx_v_mat) {
  PyObject *__pyx_v_imagPart = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatImagPart_Python", 0);

  /* "libpetsc4py.pyx":1164
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatImagPart_Python")             # <<<<<<<<<<<<<<
 *     cdef imagPart = PyMat(mat).imagPart
 *     if imagPart is None: return UNSUPPORTED(b"imagPart")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatImagPart_Python"));

  /* "libpetsc4py.pyx":1165
 *     except IERR with gil:
 *     FunctionBegin(b"MatImagPart_Python")
 *     cdef imagPart = PyMat(mat).imagPart             # <<<<<<<<<<<<<<
 *     if imagPart is None: return UNSUPPORTED(b"imagPart")
 *     imagPart(Mat_(mat))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_imagPart); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_imagPart = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1166
 *     FunctionBegin(b"MatImagPart_Python")
 *     cdef imagPart = PyMat(mat).imagPart
 *     if imagPart is None: return UNSUPPORTED(b"imagPart")             # <<<<<<<<<<<<<<
 *     imagPart(Mat_(mat))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_imagPart == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"imagPart"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1167
 *     cdef imagPart = PyMat(mat).imagPart
 *     if imagPart is None: return UNSUPPORTED(b"imagPart")
 *     imagPart(Mat_(mat))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_imagPart);
  __pyx_t_5 = __pyx_v_imagPart; __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1168
 *     if imagPart is None: return UNSUPPORTED(b"imagPart")
 *     imagPart(Mat_(mat))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode MatConjugate_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1160
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatImagPart_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.MatImagPart_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_imagPart);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1170
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatConjugate_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_MatConjugate_Python(Mat __pyx_v_mat) {
  PyObject *__pyx_v_conjugate = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("MatConjugate_Python", 0);

  /* "libpetsc4py.pyx":1174
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"MatConjugate_Python")             # <<<<<<<<<<<<<<
 *     cdef conjugate = PyMat(mat).conjugate
 *     if conjugate is None: return UNSUPPORTED(b"conjugate")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"MatConjugate_Python"));

  /* "libpetsc4py.pyx":1175
 *     except IERR with gil:
 *     FunctionBegin(b"MatConjugate_Python")
 *     cdef conjugate = PyMat(mat).conjugate             # <<<<<<<<<<<<<<
 *     if conjugate is None: return UNSUPPORTED(b"conjugate")
 *     conjugate(Mat_(mat))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyMat(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_conjugate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_conjugate = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1176
 *     FunctionBegin(b"MatConjugate_Python")
 *     cdef conjugate = PyMat(mat).conjugate
 *     if conjugate is None: return UNSUPPORTED(b"conjugate")             # <<<<<<<<<<<<<<
 *     conjugate(Mat_(mat))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_conjugate == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"conjugate"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1177
 *     cdef conjugate = PyMat(mat).conjugate
 *     if conjugate is None: return UNSUPPORTED(b"conjugate")
 *     conjugate(Mat_(mat))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_mat)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_conjugate);
  __pyx_t_5 = __pyx_v_conjugate; __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1178
 *     if conjugate is None: return UNSUPPORTED(b"conjugate")
 *     conjugate(Mat_(mat))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1170
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode MatConjugate_Python(             # <<<<<<<<<<<<<<
 *     PetscMat mat,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.MatConjugate_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_conjugate);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1202
 * @cython.internal
 * cdef class _PyPC(_PyObj): pass
 * cdef inline _PyPC PyPC(PetscPC pc):             # <<<<<<<<<<<<<<
 *     if pc != NULL and pc.data != NULL:
 *         return <_PyPC>pc.data
 */

static CYTHON_INLINE struct __pyx_obj_11libpetsc4py__PyPC *__pyx_f_11libpetsc4py_PyPC(PC __pyx_v_pc) {
  struct __pyx_obj_11libpetsc4py__PyPC *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyPC", 0);

  /* "libpetsc4py.pyx":1203
 * cdef class _PyPC(_PyObj): pass
 * cdef inline _PyPC PyPC(PetscPC pc):
 *     if pc != NULL and pc.data != NULL:             # <<<<<<<<<<<<<<
 *         return <_PyPC>pc.data
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_pc != NULL) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_pc->data != NULL) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":1204
 * cdef inline _PyPC PyPC(PetscPC pc):
 *     if pc != NULL and pc.data != NULL:
 *         return <_PyPC>pc.data             # <<<<<<<<<<<<<<
 *     else:
 *         return _PyPC.__new__(_PyPC)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_11libpetsc4py__PyPC *)__pyx_v_pc->data)));
    __pyx_r = ((struct __pyx_obj_11libpetsc4py__PyPC *)__pyx_v_pc->data);
    goto __pyx_L0;

    /* "libpetsc4py.pyx":1203
 * cdef class _PyPC(_PyObj): pass
 * cdef inline _PyPC PyPC(PetscPC pc):
 *     if pc != NULL and pc.data != NULL:             # <<<<<<<<<<<<<<
 *         return <_PyPC>pc.data
 *     else:
 */
  }

  /* "libpetsc4py.pyx":1206
 *         return <_PyPC>pc.data
 *     else:
 *         return _PyPC.__new__(_PyPC)             # <<<<<<<<<<<<<<
 * 
 * cdef public PetscErrorCode PCPythonGetContext(PetscPC pc, void **ctx) \
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_3 = ((PyObject *)__pyx_tp_new_11libpetsc4py__PyPC(((PyTypeObject *)__pyx_ptype_11libpetsc4py__PyPC), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1206, __pyx_L1_error)
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_r = ((struct __pyx_obj_11libpetsc4py__PyPC *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1202
 * @cython.internal
 * cdef class _PyPC(_PyObj): pass
 * cdef inline _PyPC PyPC(PetscPC pc):             # <<<<<<<<<<<<<<
 *     if pc != NULL and pc.data != NULL:
 *         return <_PyPC>pc.data
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libpetsc4py.PyPC", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":1208
 *         return _PyPC.__new__(_PyPC)
 * 
 * cdef public PetscErrorCode PCPythonGetContext(PetscPC pc, void **ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"PCPythonGetContext")
 */

PetscErrorCode PCPythonGetContext(PC __pyx_v_pc, void **__pyx_v_ctx) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PCPythonGetContext", 0);

  /* "libpetsc4py.pyx":1210
 * cdef public PetscErrorCode PCPythonGetContext(PetscPC pc, void **ctx) \
 *     except IERR:
 *     FunctionBegin(b"PCPythonGetContext")             # <<<<<<<<<<<<<<
 *     PyPC(pc).getcontext(ctx)
 *     return FunctionEnd()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCPythonGetContext"));

  /* "libpetsc4py.pyx":1211
 *     except IERR:
 *     FunctionBegin(b"PCPythonGetContext")
 *     PyPC(pc).getcontext(ctx)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_11libpetsc4py__PyPC *)((struct __pyx_obj_11libpetsc4py__PyPC *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.getcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_ctx); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1211, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":1212
 *     FunctionBegin(b"PCPythonGetContext")
 *     PyPC(pc).getcontext(ctx)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef public PetscErrorCode PCPythonSetContext(PetscPC pc, void *ctx) \
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1208
 *         return _PyPC.__new__(_PyPC)
 * 
 * cdef public PetscErrorCode PCPythonGetContext(PetscPC pc, void **ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"PCPythonGetContext")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.PCPythonGetContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":1214
 *     return FunctionEnd()
 * 
 * cdef public PetscErrorCode PCPythonSetContext(PetscPC pc, void *ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"PCPythonSetContext")
 */

PetscErrorCode PCPythonSetContext(PC __pyx_v_pc, void *__pyx_v_ctx) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PCPythonSetContext", 0);

  /* "libpetsc4py.pyx":1216
 * cdef public PetscErrorCode PCPythonSetContext(PetscPC pc, void *ctx) \
 *     except IERR:
 *     FunctionBegin(b"PCPythonSetContext")             # <<<<<<<<<<<<<<
 *     PyPC(pc).setcontext(ctx, PC_(pc))
 *     return FunctionEnd()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCPythonSetContext"));

  /* "libpetsc4py.pyx":1217
 *     except IERR:
 *     FunctionBegin(b"PCPythonSetContext")
 *     PyPC(pc).setcontext(ctx, PC_(pc))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PC_(__pyx_v_pc)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((struct __pyx_vtabstruct_11libpetsc4py__PyPC *)((struct __pyx_obj_11libpetsc4py__PyPC *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.setcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_ctx, ((struct PyPetscObjectObject *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1217, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1218
 *     FunctionBegin(b"PCPythonSetContext")
 *     PyPC(pc).setcontext(ctx, PC_(pc))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCPythonSetType_PYTHON(PetscPC pc, char name[]) \
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1214
 *     return FunctionEnd()
 * 
 * cdef public PetscErrorCode PCPythonSetContext(PetscPC pc, void *ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"PCPythonSetContext")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.PCPythonSetContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":1220
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCPythonSetType_PYTHON(PetscPC pc, char name[]) \             # <<<<<<<<<<<<<<
 *     except IERR with gil:
 *     FunctionBegin(b"PCPythonSetType_PYTHON")
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCPythonSetType_PYTHON(PC __pyx_v_pc, char *__pyx_v_name) {
  PyObject *__pyx_v_ctx = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PetscErrorCode __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCPythonSetType_PYTHON", 0);

  /* "libpetsc4py.pyx":1222
 * cdef PetscErrorCode PCPythonSetType_PYTHON(PetscPC pc, char name[]) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCPythonSetType_PYTHON")             # <<<<<<<<<<<<<<
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCPythonSetType_PYTHON"));

  /* "libpetsc4py.pyx":1223
 *     except IERR with gil:
 *     FunctionBegin(b"PCPythonSetType_PYTHON")
 *     if name == NULL: return FunctionEnd() # XXX             # <<<<<<<<<<<<<<
 *     cdef object ctx = createcontext(name)
 *     PCPythonSetContext(pc, <void*>ctx)
 */
  __pyx_t_1 = ((__pyx_v_name == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1224
 *     FunctionBegin(b"PCPythonSetType_PYTHON")
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)             # <<<<<<<<<<<<<<
 *     PCPythonSetContext(pc, <void*>ctx)
 *     PyPC(pc).setname(name)
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_createcontext(__pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_ctx = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1225
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)
 *     PCPythonSetContext(pc, <void*>ctx)             # <<<<<<<<<<<<<<
 *     PyPC(pc).setname(name)
 *     return FunctionEnd()
 */
  __pyx_t_3 = PCPythonSetContext(__pyx_v_pc, ((void *)__pyx_v_ctx)); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1225, __pyx_L1_error)

  /* "libpetsc4py.pyx":1226
 *     cdef object ctx = createcontext(name)
 *     PCPythonSetContext(pc, <void*>ctx)
 *     PyPC(pc).setname(name)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1226, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = ((struct __pyx_vtabstruct_11libpetsc4py__PyPC *)((struct __pyx_obj_11libpetsc4py__PyPC *)__pyx_t_2)->__pyx_base.__pyx_vtab)->__pyx_base.setname(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_2), __pyx_v_name); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1226, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1227
 *     PCPythonSetContext(pc, <void*>ctx)
 *     PyPC(pc).setname(name)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCCreate_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1220
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCPythonSetType_PYTHON(PetscPC pc, char name[]) \             # <<<<<<<<<<<<<<
 *     except IERR with gil:
 *     FunctionBegin(b"PCPythonSetType_PYTHON")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.PCPythonSetType_PYTHON", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ctx);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1229
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCCreate_Python(             # <<<<<<<<<<<<<<
 *     PetscPC pc,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCCreate_Python(PC __pyx_v_pc) {
  PCOps __pyx_v_ops;
  PyObject *__pyx_v_ctx = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PCOps __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCCreate_Python", 0);

  /* "libpetsc4py.pyx":1233
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCCreate_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef PCOps ops          = pc.ops
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCCreate_Python"));

  /* "libpetsc4py.pyx":1235
 *     FunctionBegin(b"PCCreate_Python")
 *     #
 *     cdef PCOps ops          = pc.ops             # <<<<<<<<<<<<<<
 *     ops.reset               = PCReset_Python
 *     ops.destroy             = PCDestroy_Python
 */
  __pyx_t_1 = __pyx_v_pc->ops;
  __pyx_v_ops = __pyx_t_1;

  /* "libpetsc4py.pyx":1236
 *     #
 *     cdef PCOps ops          = pc.ops
 *     ops.reset               = PCReset_Python             # <<<<<<<<<<<<<<
 *     ops.destroy             = PCDestroy_Python
 *     ops.setup               = PCSetUp_Python
 */
  __pyx_v_ops->reset = __pyx_f_11libpetsc4py_PCReset_Python;

  /* "libpetsc4py.pyx":1237
 *     cdef PCOps ops          = pc.ops
 *     ops.reset               = PCReset_Python
 *     ops.destroy             = PCDestroy_Python             # <<<<<<<<<<<<<<
 *     ops.setup               = PCSetUp_Python
 *     ops.setfromoptions      = PCSetFromOptions_Python
 */
  __pyx_v_ops->destroy = __pyx_f_11libpetsc4py_PCDestroy_Python;

  /* "libpetsc4py.pyx":1238
 *     ops.reset               = PCReset_Python
 *     ops.destroy             = PCDestroy_Python
 *     ops.setup               = PCSetUp_Python             # <<<<<<<<<<<<<<
 *     ops.setfromoptions      = PCSetFromOptions_Python
 *     ops.view                = PCView_Python
 */
  __pyx_v_ops->setup = __pyx_f_11libpetsc4py_PCSetUp_Python;

  /* "libpetsc4py.pyx":1239
 *     ops.destroy             = PCDestroy_Python
 *     ops.setup               = PCSetUp_Python
 *     ops.setfromoptions      = PCSetFromOptions_Python             # <<<<<<<<<<<<<<
 *     ops.view                = PCView_Python
 *     ops.presolve            = PCPreSolve_Python
 */
  __pyx_v_ops->setfromoptions = __pyx_f_11libpetsc4py_PCSetFromOptions_Python;

  /* "libpetsc4py.pyx":1240
 *     ops.setup               = PCSetUp_Python
 *     ops.setfromoptions      = PCSetFromOptions_Python
 *     ops.view                = PCView_Python             # <<<<<<<<<<<<<<
 *     ops.presolve            = PCPreSolve_Python
 *     ops.postsolve           = PCPostSolve_Python
 */
  __pyx_v_ops->view = __pyx_f_11libpetsc4py_PCView_Python;

  /* "libpetsc4py.pyx":1241
 *     ops.setfromoptions      = PCSetFromOptions_Python
 *     ops.view                = PCView_Python
 *     ops.presolve            = PCPreSolve_Python             # <<<<<<<<<<<<<<
 *     ops.postsolve           = PCPostSolve_Python
 *     ops.apply               = PCApply_Python
 */
  __pyx_v_ops->presolve = __pyx_f_11libpetsc4py_PCPreSolve_Python;

  /* "libpetsc4py.pyx":1242
 *     ops.view                = PCView_Python
 *     ops.presolve            = PCPreSolve_Python
 *     ops.postsolve           = PCPostSolve_Python             # <<<<<<<<<<<<<<
 *     ops.apply               = PCApply_Python
 *     ops.applytranspose      = PCApplyTranspose_Python
 */
  __pyx_v_ops->postsolve = __pyx_f_11libpetsc4py_PCPostSolve_Python;

  /* "libpetsc4py.pyx":1243
 *     ops.presolve            = PCPreSolve_Python
 *     ops.postsolve           = PCPostSolve_Python
 *     ops.apply               = PCApply_Python             # <<<<<<<<<<<<<<
 *     ops.applytranspose      = PCApplyTranspose_Python
 *     ops.applysymmetricleft  = PCApplySymmetricLeft_Python
 */
  __pyx_v_ops->apply = __pyx_f_11libpetsc4py_PCApply_Python;

  /* "libpetsc4py.pyx":1244
 *     ops.postsolve           = PCPostSolve_Python
 *     ops.apply               = PCApply_Python
 *     ops.applytranspose      = PCApplyTranspose_Python             # <<<<<<<<<<<<<<
 *     ops.applysymmetricleft  = PCApplySymmetricLeft_Python
 *     ops.applysymmetricright = PCApplySymmetricRight_Python
 */
  __pyx_v_ops->applytranspose = __pyx_f_11libpetsc4py_PCApplyTranspose_Python;

  /* "libpetsc4py.pyx":1245
 *     ops.apply               = PCApply_Python
 *     ops.applytranspose      = PCApplyTranspose_Python
 *     ops.applysymmetricleft  = PCApplySymmetricLeft_Python             # <<<<<<<<<<<<<<
 *     ops.applysymmetricright = PCApplySymmetricRight_Python
 *     #
 */
  __pyx_v_ops->applysymmetricleft = __pyx_f_11libpetsc4py_PCApplySymmetricLeft_Python;

  /* "libpetsc4py.pyx":1246
 *     ops.applytranspose      = PCApplyTranspose_Python
 *     ops.applysymmetricleft  = PCApplySymmetricLeft_Python
 *     ops.applysymmetricright = PCApplySymmetricRight_Python             # <<<<<<<<<<<<<<
 *     #
 *     CHKERR( PetscObjectComposeFunction(
 */
  __pyx_v_ops->applysymmetricright = __pyx_f_11libpetsc4py_PCApplySymmetricRight_Python;

  /* "libpetsc4py.pyx":1248
 *     ops.applysymmetricright = PCApplySymmetricRight_Python
 *     #
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>pc, b"PCPythonSetType_C",
 *             <PetscVoidFunction>PCPythonSetType_PYTHON) )
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_pc), ((char *)"PCPythonSetType_C"), ((PetscVoidFunction)__pyx_f_11libpetsc4py_PCPythonSetType_PYTHON))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1248, __pyx_L1_error)

  /* "libpetsc4py.pyx":1252
 *             <PetscVoidFunction>PCPythonSetType_PYTHON) )
 *     #
 *     cdef ctx = PyPC(NULL)             # <<<<<<<<<<<<<<
 *     pc.data = <void*> ctx
 *     Py_INCREF(<PyObject*>pc.data)
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ctx = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":1253
 *     #
 *     cdef ctx = PyPC(NULL)
 *     pc.data = <void*> ctx             # <<<<<<<<<<<<<<
 *     Py_INCREF(<PyObject*>pc.data)
 *     return FunctionEnd()
 */
  __pyx_v_pc->data = ((void *)__pyx_v_ctx);

  /* "libpetsc4py.pyx":1254
 *     cdef ctx = PyPC(NULL)
 *     pc.data = <void*> ctx
 *     Py_INCREF(<PyObject*>pc.data)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_pc->data));

  /* "libpetsc4py.pyx":1255
 *     pc.data = <void*> ctx
 *     Py_INCREF(<PyObject*>pc.data)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCDestroy_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1229
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCCreate_Python(             # <<<<<<<<<<<<<<
 *     PetscPC pc,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libpetsc4py.PCCreate_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ctx);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1257
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCDestroy_Python(             # <<<<<<<<<<<<<<
 *     PetscPC pc,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCDestroy_Python(PC __pyx_v_pc) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PetscErrorCode __pyx_t_3;
  int __pyx_t_4;
  char const *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCDestroy_Python", 0);

  /* "libpetsc4py.pyx":1261
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCDestroy_Python")             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectComposeFunction(
 *             <PetscObject>pc, b"PCPythonSetType_C",
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCDestroy_Python"));

  /* "libpetsc4py.pyx":1262
 *     except IERR with gil:
 *     FunctionBegin(b"PCDestroy_Python")
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>pc, b"PCPythonSetType_C",
 *             <PetscVoidFunction>NULL) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_pc), ((char *)"PCPythonSetType_C"), ((PetscVoidFunction)NULL))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1262, __pyx_L1_error)

  /* "libpetsc4py.pyx":1266
 *             <PetscVoidFunction>NULL) )
 *     #
 *     if not Py_IsInitialized(): return FunctionEnd()             # <<<<<<<<<<<<<<
 *     try:
 *         addRef(pc)
 */
  __pyx_t_2 = ((!(Py_IsInitialized() != 0)) != 0);
  if (__pyx_t_2) {
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1267
 *     #
 *     if not Py_IsInitialized(): return FunctionEnd()
 *     try:             # <<<<<<<<<<<<<<
 *         addRef(pc)
 *         PCPythonSetContext(pc, NULL)
 */
  /*try:*/ {

    /* "libpetsc4py.pyx":1268
 *     if not Py_IsInitialized(): return FunctionEnd()
 *     try:
 *         addRef(pc)             # <<<<<<<<<<<<<<
 *         PCPythonSetContext(pc, NULL)
 *     finally:
 */
    __pyx_f_11libpetsc4py_addRef(__pyx_v_pc);

    /* "libpetsc4py.pyx":1269
 *     try:
 *         addRef(pc)
 *         PCPythonSetContext(pc, NULL)             # <<<<<<<<<<<<<<
 *     finally:
 *         delRef(pc)
 */
    __pyx_t_3 = PCPythonSetContext(__pyx_v_pc, NULL); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1269, __pyx_L5_error)
  }

  /* "libpetsc4py.pyx":1271
 *         PCPythonSetContext(pc, NULL)
 *     finally:
 *         delRef(pc)             # <<<<<<<<<<<<<<
 *         Py_DECREF(<PyObject*>pc.data)
 *         pc.data = NULL
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_f_11libpetsc4py_delRef(__pyx_v_pc);

      /* "libpetsc4py.pyx":1272
 *     finally:
 *         delRef(pc)
 *         Py_DECREF(<PyObject*>pc.data)             # <<<<<<<<<<<<<<
 *         pc.data = NULL
 *     return FunctionEnd()
 */
      Py_DECREF(((PyObject *)__pyx_v_pc->data));

      /* "libpetsc4py.pyx":1273
 *         delRef(pc)
 *         Py_DECREF(<PyObject*>pc.data)
 *         pc.data = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
      __pyx_v_pc->data = NULL;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __pyx_t_1 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename;
      {

        /* "libpetsc4py.pyx":1271
 *         PCPythonSetContext(pc, NULL)
 *     finally:
 *         delRef(pc)             # <<<<<<<<<<<<<<
 *         Py_DECREF(<PyObject*>pc.data)
 *         pc.data = NULL
 */
        __pyx_f_11libpetsc4py_delRef(__pyx_v_pc);

        /* "libpetsc4py.pyx":1272
 *     finally:
 *         delRef(pc)
 *         Py_DECREF(<PyObject*>pc.data)             # <<<<<<<<<<<<<<
 *         pc.data = NULL
 *     return FunctionEnd()
 */
        Py_DECREF(((PyObject *)__pyx_v_pc->data));

        /* "libpetsc4py.pyx":1273
 *         delRef(pc)
 *         Py_DECREF(<PyObject*>pc.data)
 *         pc.data = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
        __pyx_v_pc->data = NULL;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      __pyx_lineno = __pyx_t_1; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "libpetsc4py.pyx":1274
 *         Py_DECREF(<PyObject*>pc.data)
 *         pc.data = NULL
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCSetUp_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1257
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCDestroy_Python(             # <<<<<<<<<<<<<<
 *     PetscPC pc,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.PCDestroy_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1276
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCSetUp_Python(             # <<<<<<<<<<<<<<
 *     PetscPC pc,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCSetUp_Python(PC __pyx_v_pc) {
  char __pyx_v_name[0x800];
  PetscBool __pyx_v_found;
  PyObject *__pyx_v_setUp = 0;
  PyObject *__pyx_v_o = 0;
  PCOps __pyx_v_ops;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PetscErrorCode __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PCOps __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCSetUp_Python", 0);

  /* "libpetsc4py.pyx":1280
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCSetUp_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef char name[2048]
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCSetUp_Python"));

  /* "libpetsc4py.pyx":1283
 *     #
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE             # <<<<<<<<<<<<<<
 *     if PyPC(pc).self is None:
 *         CHKERR( PetscOptionsGetString(NULL,
 */
  __pyx_v_found = PETSC_FALSE;

  /* "libpetsc4py.pyx":1284
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyPC(pc).self is None:             # <<<<<<<<<<<<<<
 *         CHKERR( PetscOptionsGetString(NULL,
 *                 getPrefix(pc), b"-pc_python_type",
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (((struct __pyx_obj_11libpetsc4py__PyPC *)__pyx_t_1)->__pyx_base.self == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":1285
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyPC(pc).self is None:
 *         CHKERR( PetscOptionsGetString(NULL,             # <<<<<<<<<<<<<<
 *                 getPrefix(pc), b"-pc_python_type",
 *                 name,sizeof(name),&found) )
 */
    __pyx_t_4 = __pyx_f_11libpetsc4py_CHKERR(PetscOptionsGetString(NULL, __pyx_f_11libpetsc4py_getPrefix(__pyx_v_pc), ((char *)"-pc_python_type"), __pyx_v_name, (sizeof(__pyx_v_name)), (&__pyx_v_found))); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1285, __pyx_L1_error)

    /* "libpetsc4py.pyx":1288
 *                 getPrefix(pc), b"-pc_python_type",
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:             # <<<<<<<<<<<<<<
 *             CHKERR( PCPythonSetType_PYTHON(pc,name) )
 *     if PyPC(pc).self is None:
 */
    if (__pyx_v_found) {
    } else {
      __pyx_t_3 = __pyx_v_found;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_name[0]) != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_3) {

      /* "libpetsc4py.pyx":1289
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:
 *             CHKERR( PCPythonSetType_PYTHON(pc,name) )             # <<<<<<<<<<<<<<
 *     if PyPC(pc).self is None:
 *         return PetscSETERR(PETSC_ERR_USER,
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_PCPythonSetType_PYTHON(__pyx_v_pc, __pyx_v_name); if (unlikely(__pyx_t_5 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1289, __pyx_L1_error)
      __pyx_t_4 = __pyx_f_11libpetsc4py_CHKERR(__pyx_t_5); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1289, __pyx_L1_error)

      /* "libpetsc4py.pyx":1288
 *                 getPrefix(pc), b"-pc_python_type",
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:             # <<<<<<<<<<<<<<
 *             CHKERR( PCPythonSetType_PYTHON(pc,name) )
 *     if PyPC(pc).self is None:
 */
    }

    /* "libpetsc4py.pyx":1284
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyPC(pc).self is None:             # <<<<<<<<<<<<<<
 *         CHKERR( PetscOptionsGetString(NULL,
 *                 getPrefix(pc), b"-pc_python_type",
 */
  }

  /* "libpetsc4py.pyx":1290
 *         if found and name[0]:
 *             CHKERR( PCPythonSetType_PYTHON(pc,name) )
 *     if PyPC(pc).self is None:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER,
 *             "Python context not set, call one of \n"
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = (((struct __pyx_obj_11libpetsc4py__PyPC *)__pyx_t_1)->__pyx_base.self == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":1291
 *             CHKERR( PCPythonSetType_PYTHON(pc,name) )
 *     if PyPC(pc).self is None:
 *         return PetscSETERR(PETSC_ERR_USER,             # <<<<<<<<<<<<<<
 *             "Python context not set, call one of \n"
 *             " * PCPythonSetType(pc,\"[package.]module.class\")\n"
 */
    __pyx_r = __pyx_f_11libpetsc4py_PetscSETERR(PETSC_ERR_USER, ((char *)"Python context not set, call one of \n * PCPythonSetType(pc,\"[package.]module.class\")\n * PCSetFromOptions(pc) and pass option -pc_python_type [package.]module.class"));
    goto __pyx_L0;

    /* "libpetsc4py.pyx":1290
 *         if found and name[0]:
 *             CHKERR( PCPythonSetType_PYTHON(pc,name) )
 *     if PyPC(pc).self is None:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER,
 *             "Python context not set, call one of \n"
 */
  }

  /* "libpetsc4py.pyx":1297
 *             "-pc_python_type [package.]module.class")
 *     #
 *     cdef setUp = PyPC(pc).setUp             # <<<<<<<<<<<<<<
 *     if setUp is not None:
 *         setUp(PC_(pc))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_setUp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_setUp = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "libpetsc4py.pyx":1298
 *     #
 *     cdef setUp = PyPC(pc).setUp
 *     if setUp is not None:             # <<<<<<<<<<<<<<
 *         setUp(PC_(pc))
 *     #
 */
  __pyx_t_2 = (__pyx_v_setUp != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":1299
 *     cdef setUp = PyPC(pc).setUp
 *     if setUp is not None:
 *         setUp(PC_(pc))             # <<<<<<<<<<<<<<
 *     #
 *     cdef o = PyPC(pc)
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PC_(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_setUp);
    __pyx_t_7 = __pyx_v_setUp; __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_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "libpetsc4py.pyx":1298
 *     #
 *     cdef setUp = PyPC(pc).setUp
 *     if setUp is not None:             # <<<<<<<<<<<<<<
 *         setUp(PC_(pc))
 *     #
 */
  }

  /* "libpetsc4py.pyx":1301
 *         setUp(PC_(pc))
 *     #
 *     cdef o = PyPC(pc)             # <<<<<<<<<<<<<<
 *     cdef PCOps ops = pc.ops
 *     if o.applyTranspose is None:
 */
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_o = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "libpetsc4py.pyx":1302
 *     #
 *     cdef o = PyPC(pc)
 *     cdef PCOps ops = pc.ops             # <<<<<<<<<<<<<<
 *     if o.applyTranspose is None:
 *         ops.applytranspose = NULL
 */
  __pyx_t_9 = __pyx_v_pc->ops;
  __pyx_v_ops = __pyx_t_9;

  /* "libpetsc4py.pyx":1303
 *     cdef o = PyPC(pc)
 *     cdef PCOps ops = pc.ops
 *     if o.applyTranspose is None:             # <<<<<<<<<<<<<<
 *         ops.applytranspose = NULL
 *     if o.applySymmetricLeft is None:
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_o, __pyx_n_s_applyTranspose); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = (__pyx_t_6 == Py_None);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":1304
 *     cdef PCOps ops = pc.ops
 *     if o.applyTranspose is None:
 *         ops.applytranspose = NULL             # <<<<<<<<<<<<<<
 *     if o.applySymmetricLeft is None:
 *         ops.applysymmetricleft = NULL
 */
    __pyx_v_ops->applytranspose = NULL;

    /* "libpetsc4py.pyx":1303
 *     cdef o = PyPC(pc)
 *     cdef PCOps ops = pc.ops
 *     if o.applyTranspose is None:             # <<<<<<<<<<<<<<
 *         ops.applytranspose = NULL
 *     if o.applySymmetricLeft is None:
 */
  }

  /* "libpetsc4py.pyx":1305
 *     if o.applyTranspose is None:
 *         ops.applytranspose = NULL
 *     if o.applySymmetricLeft is None:             # <<<<<<<<<<<<<<
 *         ops.applysymmetricleft = NULL
 *     if o.applySymmetricRight is None:
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_o, __pyx_n_s_applySymmetricLeft); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = (__pyx_t_6 == Py_None);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":1306
 *         ops.applytranspose = NULL
 *     if o.applySymmetricLeft is None:
 *         ops.applysymmetricleft = NULL             # <<<<<<<<<<<<<<
 *     if o.applySymmetricRight is None:
 *         ops.applysymmetricright = NULL
 */
    __pyx_v_ops->applysymmetricleft = NULL;

    /* "libpetsc4py.pyx":1305
 *     if o.applyTranspose is None:
 *         ops.applytranspose = NULL
 *     if o.applySymmetricLeft is None:             # <<<<<<<<<<<<<<
 *         ops.applysymmetricleft = NULL
 *     if o.applySymmetricRight is None:
 */
  }

  /* "libpetsc4py.pyx":1307
 *     if o.applySymmetricLeft is None:
 *         ops.applysymmetricleft = NULL
 *     if o.applySymmetricRight is None:             # <<<<<<<<<<<<<<
 *         ops.applysymmetricright = NULL
 *     #
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_o, __pyx_n_s_applySymmetricRight); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = (__pyx_t_6 == Py_None);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":1308
 *         ops.applysymmetricleft = NULL
 *     if o.applySymmetricRight is None:
 *         ops.applysymmetricright = NULL             # <<<<<<<<<<<<<<
 *     #
 *     return FunctionEnd()
 */
    __pyx_v_ops->applysymmetricright = NULL;

    /* "libpetsc4py.pyx":1307
 *     if o.applySymmetricLeft is None:
 *         ops.applysymmetricleft = NULL
 *     if o.applySymmetricRight is None:             # <<<<<<<<<<<<<<
 *         ops.applysymmetricright = NULL
 *     #
 */
  }

  /* "libpetsc4py.pyx":1310
 *         ops.applysymmetricright = NULL
 *     #
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCReset_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1276
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCSetUp_Python(             # <<<<<<<<<<<<<<
 *     PetscPC pc,
 *     ) \
 */

  /* 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_AddTraceback("libpetsc4py.PCSetUp_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setUp);
  __Pyx_XDECREF(__pyx_v_o);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1312
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCReset_Python(             # <<<<<<<<<<<<<<
 *     PetscPC pc,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCReset_Python(PC __pyx_v_pc) {
  PyObject *__pyx_v_reset = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCReset_Python", 0);

  /* "libpetsc4py.pyx":1316
 *     ) \
 *     except IERR with gil:
 *     if getRef(pc) == 0: return 0             # <<<<<<<<<<<<<<
 *     FunctionBegin(b"PCReset_Python")
 *     cdef reset = PyPC(pc).reset
 */
  __pyx_t_1 = ((__pyx_f_11libpetsc4py_getRef(__pyx_v_pc) == 0) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1317
 *     except IERR with gil:
 *     if getRef(pc) == 0: return 0
 *     FunctionBegin(b"PCReset_Python")             # <<<<<<<<<<<<<<
 *     cdef reset = PyPC(pc).reset
 *     if reset is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCReset_Python"));

  /* "libpetsc4py.pyx":1318
 *     if getRef(pc) == 0: return 0
 *     FunctionBegin(b"PCReset_Python")
 *     cdef reset = PyPC(pc).reset             # <<<<<<<<<<<<<<
 *     if reset is not None:
 *         reset(PC_(pc))
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_reset); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_reset = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":1319
 *     FunctionBegin(b"PCReset_Python")
 *     cdef reset = PyPC(pc).reset
 *     if reset is not None:             # <<<<<<<<<<<<<<
 *         reset(PC_(pc))
 *     return FunctionEnd()
 */
  __pyx_t_1 = (__pyx_v_reset != Py_None);
  __pyx_t_4 = (__pyx_t_1 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1320
 *     cdef reset = PyPC(pc).reset
 *     if reset is not None:
 *         reset(PC_(pc))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PC_(__pyx_v_pc)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1320, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_reset);
    __pyx_t_5 = __pyx_v_reset; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1320, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libpetsc4py.pyx":1319
 *     FunctionBegin(b"PCReset_Python")
 *     cdef reset = PyPC(pc).reset
 *     if reset is not None:             # <<<<<<<<<<<<<<
 *         reset(PC_(pc))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1321
 *     if reset is not None:
 *         reset(PC_(pc))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCSetFromOptions_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1312
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCReset_Python(             # <<<<<<<<<<<<<<
 *     PetscPC pc,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.PCReset_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_reset);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1323
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCSetFromOptions_Python(             # <<<<<<<<<<<<<<
 *     PetscOptionItems *PetscOptionsObject,
 *     PetscPC pc,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCSetFromOptions_Python(PetscOptionItems *__pyx_v_PetscOptionsObject, PC __pyx_v_pc) {
  char __pyx_v_name[0x800];
  char *__pyx_v_defval;
  PetscBool __pyx_v_found;
  PetscOptionItems *PetscOptionsObject;
  PyObject *__pyx_v_setFromOptions = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PetscErrorCode __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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCSetFromOptions_Python", 0);

  /* "libpetsc4py.pyx":1328
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCSetFromOptions_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef char name[2048], *defval = PyPC(pc).getname()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCSetFromOptions_Python"));

  /* "libpetsc4py.pyx":1330
 *     FunctionBegin(b"PCSetFromOptions_Python")
 *     #
 *     cdef char name[2048], *defval = PyPC(pc).getname()             # <<<<<<<<<<<<<<
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_11libpetsc4py__PyPC *)((struct __pyx_obj_11libpetsc4py__PyPC *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.getname(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1)); if (unlikely(__pyx_t_2 == ((char *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 1330, __pyx_L1_error)
  __pyx_v_defval = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":1331
 *     #
 *     cdef char name[2048], *defval = PyPC(pc).getname()
 *     cdef PetscBool found = PETSC_FALSE             # <<<<<<<<<<<<<<
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 *     CHKERR( PetscOptionsString(
 */
  __pyx_v_found = PETSC_FALSE;

  /* "libpetsc4py.pyx":1332
 *     cdef char name[2048], *defval = PyPC(pc).getname()
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject             # <<<<<<<<<<<<<<
 *     CHKERR( PetscOptionsString(
 *             b"-pc_python_type",b"Python [package.]module[.{class|function}]",
 */
  PetscOptionsObject = __pyx_v_PetscOptionsObject;

  /* "libpetsc4py.pyx":1333
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 *     CHKERR( PetscOptionsString(             # <<<<<<<<<<<<<<
 *             b"-pc_python_type",b"Python [package.]module[.{class|function}]",
 *             b"PCPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 */
  __pyx_t_3 = __pyx_f_11libpetsc4py_CHKERR(PetscOptionsString(((char *)"-pc_python_type"), ((char *)"Python [package.]module[.{class|function}]"), ((char *)"PCPythonSetType"), __pyx_v_defval, __pyx_v_name, (sizeof(__pyx_v_name)), (&__pyx_v_found))); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1333, __pyx_L1_error)

  /* "libpetsc4py.pyx":1335
 *     CHKERR( PetscOptionsString(
 *             b"-pc_python_type",b"Python [package.]module[.{class|function}]",
 *             b"PCPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;             # <<<<<<<<<<<<<<
 *     if found and name[0]:
 *         CHKERR( PCPythonSetType_PYTHON(pc,name) )
 */
  ((void)PetscOptionsObject);

  /* "libpetsc4py.pyx":1336
 *             b"-pc_python_type",b"Python [package.]module[.{class|function}]",
 *             b"PCPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:             # <<<<<<<<<<<<<<
 *         CHKERR( PCPythonSetType_PYTHON(pc,name) )
 *     #
 */
  if (__pyx_v_found) {
  } else {
    __pyx_t_4 = __pyx_v_found;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_name[0]) != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1337
 *             b"PCPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:
 *         CHKERR( PCPythonSetType_PYTHON(pc,name) )             # <<<<<<<<<<<<<<
 *     #
 *     cdef setFromOptions = PyPC(pc).setFromOptions
 */
    __pyx_t_6 = __pyx_f_11libpetsc4py_PCPythonSetType_PYTHON(__pyx_v_pc, __pyx_v_name); if (unlikely(__pyx_t_6 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1337, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_11libpetsc4py_CHKERR(__pyx_t_6); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1337, __pyx_L1_error)

    /* "libpetsc4py.pyx":1336
 *             b"-pc_python_type",b"Python [package.]module[.{class|function}]",
 *             b"PCPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:             # <<<<<<<<<<<<<<
 *         CHKERR( PCPythonSetType_PYTHON(pc,name) )
 *     #
 */
  }

  /* "libpetsc4py.pyx":1339
 *         CHKERR( PCPythonSetType_PYTHON(pc,name) )
 *     #
 *     cdef setFromOptions = PyPC(pc).setFromOptions             # <<<<<<<<<<<<<<
 *     if setFromOptions is not None:
 *         setFromOptions(PC_(pc))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_setFromOptions); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_setFromOptions = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "libpetsc4py.pyx":1340
 *     #
 *     cdef setFromOptions = PyPC(pc).setFromOptions
 *     if setFromOptions is not None:             # <<<<<<<<<<<<<<
 *         setFromOptions(PC_(pc))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_setFromOptions != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":1341
 *     cdef setFromOptions = PyPC(pc).setFromOptions
 *     if setFromOptions is not None:
 *         setFromOptions(PC_(pc))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PC_(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1341, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_setFromOptions);
    __pyx_t_8 = __pyx_v_setFromOptions; __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_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __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, 1341, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "libpetsc4py.pyx":1340
 *     #
 *     cdef setFromOptions = PyPC(pc).setFromOptions
 *     if setFromOptions is not None:             # <<<<<<<<<<<<<<
 *         setFromOptions(PC_(pc))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1342
 *     if setFromOptions is not None:
 *         setFromOptions(PC_(pc))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCView_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1323
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCSetFromOptions_Python(             # <<<<<<<<<<<<<<
 *     PetscOptionItems *PetscOptionsObject,
 *     PetscPC pc,
 */

  /* function exit code */
  __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("libpetsc4py.PCSetFromOptions_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setFromOptions);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1344
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCView_Python(             # <<<<<<<<<<<<<<
 *     PetscPC     pc,
 *     PetscViewer vwr,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCView_Python(PC __pyx_v_pc, PetscViewer __pyx_v_vwr) {
  PyObject *__pyx_v_view = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCView_Python", 0);

  /* "libpetsc4py.pyx":1349
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCView_Python")             # <<<<<<<<<<<<<<
 *     viewcontext(PyPC(pc), vwr)
 *     cdef view = PyPC(pc).view
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCView_Python"));

  /* "libpetsc4py.pyx":1350
 *     except IERR with gil:
 *     FunctionBegin(b"PCView_Python")
 *     viewcontext(PyPC(pc), vwr)             # <<<<<<<<<<<<<<
 *     cdef view = PyPC(pc).view
 *     if view is not None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_11libpetsc4py_viewcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_vwr); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1350, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":1351
 *     FunctionBegin(b"PCView_Python")
 *     viewcontext(PyPC(pc), vwr)
 *     cdef view = PyPC(pc).view             # <<<<<<<<<<<<<<
 *     if view is not None:
 *         view(PC_(pc), Viewer_(vwr))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_view); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_view = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":1352
 *     viewcontext(PyPC(pc), vwr)
 *     cdef view = PyPC(pc).view
 *     if view is not None:             # <<<<<<<<<<<<<<
 *         view(PC_(pc), Viewer_(vwr))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_view != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":1353
 *     cdef view = PyPC(pc).view
 *     if view is not None:
 *         view(PC_(pc), Viewer_(vwr))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PC_(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Viewer_(__pyx_v_vwr)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1353, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_view);
    __pyx_t_7 = __pyx_v_view; __pyx_t_8 = NULL;
    __pyx_t_2 = 0;
    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_2 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_2, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_2, __pyx_t_6);
      __pyx_t_1 = 0;
      __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1353, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libpetsc4py.pyx":1352
 *     viewcontext(PyPC(pc), vwr)
 *     cdef view = PyPC(pc).view
 *     if view is not None:             # <<<<<<<<<<<<<<
 *         view(PC_(pc), Viewer_(vwr))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1354
 *     if view is not None:
 *         view(PC_(pc), Viewer_(vwr))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCPreSolve_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1344
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCView_Python(             # <<<<<<<<<<<<<<
 *     PetscPC     pc,
 *     PetscViewer vwr,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.PCView_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_view);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1356
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCPreSolve_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscKSP ksp,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCPreSolve_Python(PC __pyx_v_pc, KSP __pyx_v_ksp, Vec __pyx_v_b, Vec __pyx_v_x) {
  PyObject *__pyx_v_preSolve = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCPreSolve_Python", 0);

  /* "libpetsc4py.pyx":1363
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCPreSolve_Python")             # <<<<<<<<<<<<<<
 *     cdef preSolve = PyPC(pc).preSolve
 *     if preSolve is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCPreSolve_Python"));

  /* "libpetsc4py.pyx":1364
 *     except IERR with gil:
 *     FunctionBegin(b"PCPreSolve_Python")
 *     cdef preSolve = PyPC(pc).preSolve             # <<<<<<<<<<<<<<
 *     if preSolve is not None:
 *         preSolve(PC_(pc), KSP_(ksp), Vec_(b), Vec_(x))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_preSolve); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_preSolve = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1365
 *     FunctionBegin(b"PCPreSolve_Python")
 *     cdef preSolve = PyPC(pc).preSolve
 *     if preSolve is not None:             # <<<<<<<<<<<<<<
 *         preSolve(PC_(pc), KSP_(ksp), Vec_(b), Vec_(x))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_preSolve != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1366
 *     cdef preSolve = PyPC(pc).preSolve
 *     if preSolve is not None:
 *         preSolve(PC_(pc), KSP_(ksp), Vec_(b), Vec_(x))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PC_(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_b)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_preSolve);
    __pyx_t_8 = __pyx_v_preSolve; __pyx_t_9 = NULL;
    __pyx_t_10 = 0;
    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_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_1, __pyx_t_5, __pyx_t_6, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1366, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_1, __pyx_t_5, __pyx_t_6, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1366, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1366, __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_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_7);
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1366, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":1365
 *     FunctionBegin(b"PCPreSolve_Python")
 *     cdef preSolve = PyPC(pc).preSolve
 *     if preSolve is not None:             # <<<<<<<<<<<<<<
 *         preSolve(PC_(pc), KSP_(ksp), Vec_(b), Vec_(x))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1367
 *     if preSolve is not None:
 *         preSolve(PC_(pc), KSP_(ksp), Vec_(b), Vec_(x))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCPostSolve_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1356
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCPreSolve_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscKSP ksp,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("libpetsc4py.PCPreSolve_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_preSolve);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1369
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCPostSolve_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscKSP ksp,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCPostSolve_Python(PC __pyx_v_pc, KSP __pyx_v_ksp, Vec __pyx_v_b, Vec __pyx_v_x) {
  PyObject *__pyx_v_postSolve = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCPostSolve_Python", 0);

  /* "libpetsc4py.pyx":1376
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCPostSolve_Python")             # <<<<<<<<<<<<<<
 *     cdef postSolve = PyPC(pc).postSolve
 *     if postSolve is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCPostSolve_Python"));

  /* "libpetsc4py.pyx":1377
 *     except IERR with gil:
 *     FunctionBegin(b"PCPostSolve_Python")
 *     cdef postSolve = PyPC(pc).postSolve             # <<<<<<<<<<<<<<
 *     if postSolve is not None:
 *         postSolve(PC_(pc), KSP_(ksp), Vec_(b), Vec_(x))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_postSolve); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_postSolve = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1378
 *     FunctionBegin(b"PCPostSolve_Python")
 *     cdef postSolve = PyPC(pc).postSolve
 *     if postSolve is not None:             # <<<<<<<<<<<<<<
 *         postSolve(PC_(pc), KSP_(ksp), Vec_(b), Vec_(x))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_postSolve != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1379
 *     cdef postSolve = PyPC(pc).postSolve
 *     if postSolve is not None:
 *         postSolve(PC_(pc), KSP_(ksp), Vec_(b), Vec_(x))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PC_(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_b)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1379, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_postSolve);
    __pyx_t_8 = __pyx_v_postSolve; __pyx_t_9 = NULL;
    __pyx_t_10 = 0;
    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_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_1, __pyx_t_5, __pyx_t_6, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1379, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_1, __pyx_t_5, __pyx_t_6, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1379, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1379, __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_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_7);
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1379, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":1378
 *     FunctionBegin(b"PCPostSolve_Python")
 *     cdef postSolve = PyPC(pc).postSolve
 *     if postSolve is not None:             # <<<<<<<<<<<<<<
 *         postSolve(PC_(pc), KSP_(ksp), Vec_(b), Vec_(x))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1380
 *     if postSolve is not None:
 *         postSolve(PC_(pc), KSP_(ksp), Vec_(b), Vec_(x))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCApply_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1369
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCPostSolve_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscKSP ksp,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("libpetsc4py.PCPostSolve_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_postSolve);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1382
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCApply_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscVec x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCApply_Python(PC __pyx_v_pc, Vec __pyx_v_x, Vec __pyx_v_y) {
  PyObject *__pyx_v_apply = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCApply_Python", 0);

  /* "libpetsc4py.pyx":1388
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCApply_Python")             # <<<<<<<<<<<<<<
 *     cdef apply = PyPC(pc).apply
 *     apply(PC_(pc), Vec_(x), Vec_(y))
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCApply_Python"));

  /* "libpetsc4py.pyx":1389
 *     except IERR with gil:
 *     FunctionBegin(b"PCApply_Python")
 *     cdef apply = PyPC(pc).apply             # <<<<<<<<<<<<<<
 *     apply(PC_(pc), Vec_(x), Vec_(y))
 *     return FunctionEnd()
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_apply); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_apply = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1390
 *     FunctionBegin(b"PCApply_Python")
 *     cdef apply = PyPC(pc).apply
 *     apply(PC_(pc), Vec_(x), Vec_(y))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PC_(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_apply);
  __pyx_t_5 = __pyx_v_apply; __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(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[4] = {__pyx_t_6, __pyx_t_1, __pyx_t_3, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1390, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __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[4] = {__pyx_t_6, __pyx_t_1, __pyx_t_3, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1390, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __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(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1390, __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_1);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_4);
    __pyx_t_1 = 0;
    __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, 1390, __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_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1391
 *     cdef apply = PyPC(pc).apply
 *     apply(PC_(pc), Vec_(x), Vec_(y))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCApplyTranspose_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1382
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCApply_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscVec x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("libpetsc4py.PCApply_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_apply);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1393
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCApplyTranspose_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscVec x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCApplyTranspose_Python(PC __pyx_v_pc, Vec __pyx_v_x, Vec __pyx_v_y) {
  PyObject *__pyx_v_applyTranspose = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCApplyTranspose_Python", 0);

  /* "libpetsc4py.pyx":1399
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCApplyTranspose_Python")             # <<<<<<<<<<<<<<
 *     cdef applyTranspose = PyPC(pc).applyTranspose
 *     applyTranspose(PC_(pc), Vec_(x), Vec_(y))
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCApplyTranspose_Python"));

  /* "libpetsc4py.pyx":1400
 *     except IERR with gil:
 *     FunctionBegin(b"PCApplyTranspose_Python")
 *     cdef applyTranspose = PyPC(pc).applyTranspose             # <<<<<<<<<<<<<<
 *     applyTranspose(PC_(pc), Vec_(x), Vec_(y))
 *     return FunctionEnd()
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_applyTranspose); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_applyTranspose = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1401
 *     FunctionBegin(b"PCApplyTranspose_Python")
 *     cdef applyTranspose = PyPC(pc).applyTranspose
 *     applyTranspose(PC_(pc), Vec_(x), Vec_(y))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PC_(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_applyTranspose);
  __pyx_t_5 = __pyx_v_applyTranspose; __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(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[4] = {__pyx_t_6, __pyx_t_1, __pyx_t_3, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1401, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __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[4] = {__pyx_t_6, __pyx_t_1, __pyx_t_3, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1401, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __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(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1401, __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_1);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_4);
    __pyx_t_1 = 0;
    __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, 1401, __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_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1402
 *     cdef applyTranspose = PyPC(pc).applyTranspose
 *     applyTranspose(PC_(pc), Vec_(x), Vec_(y))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCApplySymmetricLeft_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1393
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCApplyTranspose_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscVec x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("libpetsc4py.PCApplyTranspose_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_applyTranspose);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1404
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCApplySymmetricLeft_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscVec x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCApplySymmetricLeft_Python(PC __pyx_v_pc, Vec __pyx_v_x, Vec __pyx_v_y) {
  PyObject *__pyx_v_applySymmetricLeft = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCApplySymmetricLeft_Python", 0);

  /* "libpetsc4py.pyx":1410
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCApplySymmetricLeft_Python")             # <<<<<<<<<<<<<<
 *     cdef applySymmetricLeft = PyPC(pc).applySymmetricLeft
 *     applySymmetricLeft(PC_(pc), Vec_(x), Vec_(y))
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCApplySymmetricLeft_Python"));

  /* "libpetsc4py.pyx":1411
 *     except IERR with gil:
 *     FunctionBegin(b"PCApplySymmetricLeft_Python")
 *     cdef applySymmetricLeft = PyPC(pc).applySymmetricLeft             # <<<<<<<<<<<<<<
 *     applySymmetricLeft(PC_(pc), Vec_(x), Vec_(y))
 *     return FunctionEnd()
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_applySymmetricLeft); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_applySymmetricLeft = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1412
 *     FunctionBegin(b"PCApplySymmetricLeft_Python")
 *     cdef applySymmetricLeft = PyPC(pc).applySymmetricLeft
 *     applySymmetricLeft(PC_(pc), Vec_(x), Vec_(y))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PC_(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_applySymmetricLeft);
  __pyx_t_5 = __pyx_v_applySymmetricLeft; __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(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[4] = {__pyx_t_6, __pyx_t_1, __pyx_t_3, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1412, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __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[4] = {__pyx_t_6, __pyx_t_1, __pyx_t_3, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1412, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __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(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1412, __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_1);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_4);
    __pyx_t_1 = 0;
    __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, 1412, __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_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1413
 *     cdef applySymmetricLeft = PyPC(pc).applySymmetricLeft
 *     applySymmetricLeft(PC_(pc), Vec_(x), Vec_(y))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode PCApplySymmetricRight_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1404
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCApplySymmetricLeft_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscVec x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("libpetsc4py.PCApplySymmetricLeft_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_applySymmetricLeft);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1415
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCApplySymmetricRight_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscVec x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PCApplySymmetricRight_Python(PC __pyx_v_pc, Vec __pyx_v_x, Vec __pyx_v_y) {
  PyObject *__pyx_v_applySymmetricRight = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PCApplySymmetricRight_Python", 0);

  /* "libpetsc4py.pyx":1421
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PCApplySymmetricRight_Python")             # <<<<<<<<<<<<<<
 *     cdef applySymmetricRight = PyPC(pc).applySymmetricRight
 *     applySymmetricRight(PC_(pc), Vec_(x), Vec_(y))
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PCApplySymmetricRight_Python"));

  /* "libpetsc4py.pyx":1422
 *     except IERR with gil:
 *     FunctionBegin(b"PCApplySymmetricRight_Python")
 *     cdef applySymmetricRight = PyPC(pc).applySymmetricRight             # <<<<<<<<<<<<<<
 *     applySymmetricRight(PC_(pc), Vec_(x), Vec_(y))
 *     return FunctionEnd()
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyPC(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_applySymmetricRight); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_applySymmetricRight = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1423
 *     FunctionBegin(b"PCApplySymmetricRight_Python")
 *     cdef applySymmetricRight = PyPC(pc).applySymmetricRight
 *     applySymmetricRight(PC_(pc), Vec_(x), Vec_(y))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PC_(__pyx_v_pc)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_y)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_applySymmetricRight);
  __pyx_t_5 = __pyx_v_applySymmetricRight; __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(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[4] = {__pyx_t_6, __pyx_t_1, __pyx_t_3, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1423, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __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[4] = {__pyx_t_6, __pyx_t_1, __pyx_t_3, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1423, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __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(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1423, __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_1);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_4);
    __pyx_t_1 = 0;
    __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, 1423, __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_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1424
 *     cdef applySymmetricRight = PyPC(pc).applySymmetricRight
 *     applySymmetricRight(PC_(pc), Vec_(x), Vec_(y))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1415
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode PCApplySymmetricRight_Python(             # <<<<<<<<<<<<<<
 *     PetscPC  pc,
 *     PetscVec x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("libpetsc4py.PCApplySymmetricRight_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_applySymmetricRight);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1478
 * @cython.internal
 * cdef class _PyKSP(_PyObj): pass
 * cdef inline _PyKSP PyKSP(PetscKSP ksp):             # <<<<<<<<<<<<<<
 *     if ksp != NULL and ksp.data != NULL:
 *         return <_PyKSP>ksp.data
 */

static CYTHON_INLINE struct __pyx_obj_11libpetsc4py__PyKSP *__pyx_f_11libpetsc4py_PyKSP(KSP __pyx_v_ksp) {
  struct __pyx_obj_11libpetsc4py__PyKSP *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyKSP", 0);

  /* "libpetsc4py.pyx":1479
 * cdef class _PyKSP(_PyObj): pass
 * cdef inline _PyKSP PyKSP(PetscKSP ksp):
 *     if ksp != NULL and ksp.data != NULL:             # <<<<<<<<<<<<<<
 *         return <_PyKSP>ksp.data
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_ksp != NULL) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_ksp->data != NULL) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":1480
 * cdef inline _PyKSP PyKSP(PetscKSP ksp):
 *     if ksp != NULL and ksp.data != NULL:
 *         return <_PyKSP>ksp.data             # <<<<<<<<<<<<<<
 *     else:
 *         return _PyKSP.__new__(_PyKSP)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_11libpetsc4py__PyKSP *)__pyx_v_ksp->data)));
    __pyx_r = ((struct __pyx_obj_11libpetsc4py__PyKSP *)__pyx_v_ksp->data);
    goto __pyx_L0;

    /* "libpetsc4py.pyx":1479
 * cdef class _PyKSP(_PyObj): pass
 * cdef inline _PyKSP PyKSP(PetscKSP ksp):
 *     if ksp != NULL and ksp.data != NULL:             # <<<<<<<<<<<<<<
 *         return <_PyKSP>ksp.data
 *     else:
 */
  }

  /* "libpetsc4py.pyx":1482
 *         return <_PyKSP>ksp.data
 *     else:
 *         return _PyKSP.__new__(_PyKSP)             # <<<<<<<<<<<<<<
 * 
 * cdef public PetscErrorCode KSPPythonGetContext(PetscKSP ksp, void **ctx) \
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_3 = ((PyObject *)__pyx_tp_new_11libpetsc4py__PyKSP(((PyTypeObject *)__pyx_ptype_11libpetsc4py__PyKSP), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1482, __pyx_L1_error)
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_r = ((struct __pyx_obj_11libpetsc4py__PyKSP *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1478
 * @cython.internal
 * cdef class _PyKSP(_PyObj): pass
 * cdef inline _PyKSP PyKSP(PetscKSP ksp):             # <<<<<<<<<<<<<<
 *     if ksp != NULL and ksp.data != NULL:
 *         return <_PyKSP>ksp.data
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libpetsc4py.PyKSP", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":1484
 *         return _PyKSP.__new__(_PyKSP)
 * 
 * cdef public PetscErrorCode KSPPythonGetContext(PetscKSP ksp, void **ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"KSPPythonGetContext")
 */

PetscErrorCode KSPPythonGetContext(KSP __pyx_v_ksp, void **__pyx_v_ctx) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("KSPPythonGetContext", 0);

  /* "libpetsc4py.pyx":1486
 * cdef public PetscErrorCode KSPPythonGetContext(PetscKSP ksp, void **ctx) \
 *     except IERR:
 *     FunctionBegin(b"KSPPythonGetContext")             # <<<<<<<<<<<<<<
 *     PyKSP(ksp).getcontext(ctx)
 *     return FunctionEnd()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPPythonGetContext"));

  /* "libpetsc4py.pyx":1487
 *     except IERR:
 *     FunctionBegin(b"KSPPythonGetContext")
 *     PyKSP(ksp).getcontext(ctx)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1487, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_11libpetsc4py__PyKSP *)((struct __pyx_obj_11libpetsc4py__PyKSP *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.getcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_ctx); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1487, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":1488
 *     FunctionBegin(b"KSPPythonGetContext")
 *     PyKSP(ksp).getcontext(ctx)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef public PetscErrorCode KSPPythonSetContext(PetscKSP ksp, void *ctx) \
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1484
 *         return _PyKSP.__new__(_PyKSP)
 * 
 * cdef public PetscErrorCode KSPPythonGetContext(PetscKSP ksp, void **ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"KSPPythonGetContext")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.KSPPythonGetContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":1490
 *     return FunctionEnd()
 * 
 * cdef public PetscErrorCode KSPPythonSetContext(PetscKSP ksp, void *ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"KSPPythonSetContext")
 */

PetscErrorCode KSPPythonSetContext(KSP __pyx_v_ksp, void *__pyx_v_ctx) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("KSPPythonSetContext", 0);

  /* "libpetsc4py.pyx":1492
 * cdef public PetscErrorCode KSPPythonSetContext(PetscKSP ksp, void *ctx) \
 *     except IERR:
 *     FunctionBegin(b"KSPPythonSetContext")             # <<<<<<<<<<<<<<
 *     PyKSP(ksp).setcontext(ctx, KSP_(ksp))
 *     return FunctionEnd()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPPythonSetContext"));

  /* "libpetsc4py.pyx":1493
 *     except IERR:
 *     FunctionBegin(b"KSPPythonSetContext")
 *     PyKSP(ksp).setcontext(ctx, KSP_(ksp))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((struct __pyx_vtabstruct_11libpetsc4py__PyKSP *)((struct __pyx_obj_11libpetsc4py__PyKSP *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.setcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_ctx, ((struct PyPetscObjectObject *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1493, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1494
 *     FunctionBegin(b"KSPPythonSetContext")
 *     PyKSP(ksp).setcontext(ctx, KSP_(ksp))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPPythonSetType_PYTHON(PetscKSP ksp, char name[]) \
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1490
 *     return FunctionEnd()
 * 
 * cdef public PetscErrorCode KSPPythonSetContext(PetscKSP ksp, void *ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"KSPPythonSetContext")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.KSPPythonSetContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":1496
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPPythonSetType_PYTHON(PetscKSP ksp, char name[]) \             # <<<<<<<<<<<<<<
 *     except IERR with gil:
 *     FunctionBegin(b"KSPPythonSetType_PYTHON")
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPPythonSetType_PYTHON(KSP __pyx_v_ksp, char *__pyx_v_name) {
  PyObject *__pyx_v_ctx = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PetscErrorCode __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPPythonSetType_PYTHON", 0);

  /* "libpetsc4py.pyx":1498
 * cdef PetscErrorCode KSPPythonSetType_PYTHON(PetscKSP ksp, char name[]) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPPythonSetType_PYTHON")             # <<<<<<<<<<<<<<
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPPythonSetType_PYTHON"));

  /* "libpetsc4py.pyx":1499
 *     except IERR with gil:
 *     FunctionBegin(b"KSPPythonSetType_PYTHON")
 *     if name == NULL: return FunctionEnd() # XXX             # <<<<<<<<<<<<<<
 *     cdef object ctx = createcontext(name)
 *     KSPPythonSetContext(ksp, <void*>ctx)
 */
  __pyx_t_1 = ((__pyx_v_name == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1500
 *     FunctionBegin(b"KSPPythonSetType_PYTHON")
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)             # <<<<<<<<<<<<<<
 *     KSPPythonSetContext(ksp, <void*>ctx)
 *     PyKSP(ksp).setname(name)
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_createcontext(__pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_ctx = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1501
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)
 *     KSPPythonSetContext(ksp, <void*>ctx)             # <<<<<<<<<<<<<<
 *     PyKSP(ksp).setname(name)
 *     return FunctionEnd()
 */
  __pyx_t_3 = KSPPythonSetContext(__pyx_v_ksp, ((void *)__pyx_v_ctx)); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1501, __pyx_L1_error)

  /* "libpetsc4py.pyx":1502
 *     cdef object ctx = createcontext(name)
 *     KSPPythonSetContext(ksp, <void*>ctx)
 *     PyKSP(ksp).setname(name)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = ((struct __pyx_vtabstruct_11libpetsc4py__PyKSP *)((struct __pyx_obj_11libpetsc4py__PyKSP *)__pyx_t_2)->__pyx_base.__pyx_vtab)->__pyx_base.setname(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_2), __pyx_v_name); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1502, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1503
 *     KSPPythonSetContext(ksp, <void*>ctx)
 *     PyKSP(ksp).setname(name)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPCreate_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1496
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPPythonSetType_PYTHON(PetscKSP ksp, char name[]) \             # <<<<<<<<<<<<<<
 *     except IERR with gil:
 *     FunctionBegin(b"KSPPythonSetType_PYTHON")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.KSPPythonSetType_PYTHON", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ctx);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1505
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPCreate_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPCreate_Python(KSP __pyx_v_ksp) {
  KSPOps __pyx_v_ops;
  PyObject *__pyx_v_ctx = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  KSPOps __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPCreate_Python", 0);

  /* "libpetsc4py.pyx":1509
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPCreate_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef KSPOps ops    = ksp.ops
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPCreate_Python"));

  /* "libpetsc4py.pyx":1511
 *     FunctionBegin(b"KSPCreate_Python")
 *     #
 *     cdef KSPOps ops    = ksp.ops             # <<<<<<<<<<<<<<
 *     ops.reset          = KSPReset_Python
 *     ops.destroy        = KSPDestroy_Python
 */
  __pyx_t_1 = __pyx_v_ksp->ops;
  __pyx_v_ops = __pyx_t_1;

  /* "libpetsc4py.pyx":1512
 *     #
 *     cdef KSPOps ops    = ksp.ops
 *     ops.reset          = KSPReset_Python             # <<<<<<<<<<<<<<
 *     ops.destroy        = KSPDestroy_Python
 *     ops.setup          = KSPSetUp_Python
 */
  __pyx_v_ops->reset = __pyx_f_11libpetsc4py_KSPReset_Python;

  /* "libpetsc4py.pyx":1513
 *     cdef KSPOps ops    = ksp.ops
 *     ops.reset          = KSPReset_Python
 *     ops.destroy        = KSPDestroy_Python             # <<<<<<<<<<<<<<
 *     ops.setup          = KSPSetUp_Python
 *     ops.setfromoptions = KSPSetFromOptions_Python
 */
  __pyx_v_ops->destroy = __pyx_f_11libpetsc4py_KSPDestroy_Python;

  /* "libpetsc4py.pyx":1514
 *     ops.reset          = KSPReset_Python
 *     ops.destroy        = KSPDestroy_Python
 *     ops.setup          = KSPSetUp_Python             # <<<<<<<<<<<<<<
 *     ops.setfromoptions = KSPSetFromOptions_Python
 *     ops.view           = KSPView_Python
 */
  __pyx_v_ops->setup = __pyx_f_11libpetsc4py_KSPSetUp_Python;

  /* "libpetsc4py.pyx":1515
 *     ops.destroy        = KSPDestroy_Python
 *     ops.setup          = KSPSetUp_Python
 *     ops.setfromoptions = KSPSetFromOptions_Python             # <<<<<<<<<<<<<<
 *     ops.view           = KSPView_Python
 *     ops.solve          = KSPSolve_Python
 */
  __pyx_v_ops->setfromoptions = __pyx_f_11libpetsc4py_KSPSetFromOptions_Python;

  /* "libpetsc4py.pyx":1516
 *     ops.setup          = KSPSetUp_Python
 *     ops.setfromoptions = KSPSetFromOptions_Python
 *     ops.view           = KSPView_Python             # <<<<<<<<<<<<<<
 *     ops.solve          = KSPSolve_Python
 *     ops.buildsolution  = KSPBuildSolution_Python
 */
  __pyx_v_ops->view = __pyx_f_11libpetsc4py_KSPView_Python;

  /* "libpetsc4py.pyx":1517
 *     ops.setfromoptions = KSPSetFromOptions_Python
 *     ops.view           = KSPView_Python
 *     ops.solve          = KSPSolve_Python             # <<<<<<<<<<<<<<
 *     ops.buildsolution  = KSPBuildSolution_Python
 *     ops.buildresidual  = KSPBuildResidual_Python
 */
  __pyx_v_ops->solve = __pyx_f_11libpetsc4py_KSPSolve_Python;

  /* "libpetsc4py.pyx":1518
 *     ops.view           = KSPView_Python
 *     ops.solve          = KSPSolve_Python
 *     ops.buildsolution  = KSPBuildSolution_Python             # <<<<<<<<<<<<<<
 *     ops.buildresidual  = KSPBuildResidual_Python
 *     #
 */
  __pyx_v_ops->buildsolution = __pyx_f_11libpetsc4py_KSPBuildSolution_Python;

  /* "libpetsc4py.pyx":1519
 *     ops.solve          = KSPSolve_Python
 *     ops.buildsolution  = KSPBuildSolution_Python
 *     ops.buildresidual  = KSPBuildResidual_Python             # <<<<<<<<<<<<<<
 *     #
 *     CHKERR( PetscObjectComposeFunction(
 */
  __pyx_v_ops->buildresidual = __pyx_f_11libpetsc4py_KSPBuildResidual_Python;

  /* "libpetsc4py.pyx":1521
 *     ops.buildresidual  = KSPBuildResidual_Python
 *     #
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>ksp, b"KSPPythonSetType_C",
 *             <PetscVoidFunction>KSPPythonSetType_PYTHON) )
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_ksp), ((char *)"KSPPythonSetType_C"), ((PetscVoidFunction)__pyx_f_11libpetsc4py_KSPPythonSetType_PYTHON))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1521, __pyx_L1_error)

  /* "libpetsc4py.pyx":1525
 *             <PetscVoidFunction>KSPPythonSetType_PYTHON) )
 *     #
 *     cdef ctx = PyKSP(NULL)             # <<<<<<<<<<<<<<
 *     ksp.data = <void*> ctx
 *     Py_INCREF(<PyObject*>ksp.data)
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ctx = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":1526
 *     #
 *     cdef ctx = PyKSP(NULL)
 *     ksp.data = <void*> ctx             # <<<<<<<<<<<<<<
 *     Py_INCREF(<PyObject*>ksp.data)
 *     #
 */
  __pyx_v_ksp->data = ((void *)__pyx_v_ctx);

  /* "libpetsc4py.pyx":1527
 *     cdef ctx = PyKSP(NULL)
 *     ksp.data = <void*> ctx
 *     Py_INCREF(<PyObject*>ksp.data)             # <<<<<<<<<<<<<<
 *     #
 *     CHKERR( KSPSetSupportedNorm(
 */
  Py_INCREF(((PyObject *)__pyx_v_ksp->data));

  /* "libpetsc4py.pyx":1529
 *     Py_INCREF(<PyObject*>ksp.data)
 *     #
 *     CHKERR( KSPSetSupportedNorm(             # <<<<<<<<<<<<<<
 *             ksp, KSP_NORM_PRECONDITIONED,   PC_LEFT,      3) )
 *     CHKERR( KSPSetSupportedNorm(
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(KSPSetSupportedNorm(__pyx_v_ksp, KSP_NORM_PRECONDITIONED, PC_LEFT, 3)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1529, __pyx_L1_error)

  /* "libpetsc4py.pyx":1531
 *     CHKERR( KSPSetSupportedNorm(
 *             ksp, KSP_NORM_PRECONDITIONED,   PC_LEFT,      3) )
 *     CHKERR( KSPSetSupportedNorm(             # <<<<<<<<<<<<<<
 *             ksp, KSP_NORM_UNPRECONDITIONED, PC_RIGHT,     3) )
 *     CHKERR( KSPSetSupportedNorm(
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(KSPSetSupportedNorm(__pyx_v_ksp, KSP_NORM_UNPRECONDITIONED, PC_RIGHT, 3)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1531, __pyx_L1_error)

  /* "libpetsc4py.pyx":1533
 *     CHKERR( KSPSetSupportedNorm(
 *             ksp, KSP_NORM_UNPRECONDITIONED, PC_RIGHT,     3) )
 *     CHKERR( KSPSetSupportedNorm(             # <<<<<<<<<<<<<<
 *             ksp, KSP_NORM_UNPRECONDITIONED, PC_LEFT,      2) )
 *     CHKERR( KSPSetSupportedNorm(
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(KSPSetSupportedNorm(__pyx_v_ksp, KSP_NORM_UNPRECONDITIONED, PC_LEFT, 2)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1533, __pyx_L1_error)

  /* "libpetsc4py.pyx":1535
 *     CHKERR( KSPSetSupportedNorm(
 *             ksp, KSP_NORM_UNPRECONDITIONED, PC_LEFT,      2) )
 *     CHKERR( KSPSetSupportedNorm(             # <<<<<<<<<<<<<<
 *             ksp, KSP_NORM_PRECONDITIONED,   PC_RIGHT,     2) )
 *     CHKERR( KSPSetSupportedNorm(
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(KSPSetSupportedNorm(__pyx_v_ksp, KSP_NORM_PRECONDITIONED, PC_RIGHT, 2)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1535, __pyx_L1_error)

  /* "libpetsc4py.pyx":1537
 *     CHKERR( KSPSetSupportedNorm(
 *             ksp, KSP_NORM_PRECONDITIONED,   PC_RIGHT,     2) )
 *     CHKERR( KSPSetSupportedNorm(             # <<<<<<<<<<<<<<
 *             ksp, KSP_NORM_PRECONDITIONED,   PC_SYMMETRIC, 1) )
 *     CHKERR( KSPSetSupportedNorm(
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(KSPSetSupportedNorm(__pyx_v_ksp, KSP_NORM_PRECONDITIONED, PC_SYMMETRIC, 1)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1537, __pyx_L1_error)

  /* "libpetsc4py.pyx":1539
 *     CHKERR( KSPSetSupportedNorm(
 *             ksp, KSP_NORM_PRECONDITIONED,   PC_SYMMETRIC, 1) )
 *     CHKERR( KSPSetSupportedNorm(             # <<<<<<<<<<<<<<
 *             ksp, KSP_NORM_UNPRECONDITIONED, PC_SYMMETRIC, 1) )
 *     return FunctionEnd()
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(KSPSetSupportedNorm(__pyx_v_ksp, KSP_NORM_UNPRECONDITIONED, PC_SYMMETRIC, 1)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1539, __pyx_L1_error)

  /* "libpetsc4py.pyx":1541
 *     CHKERR( KSPSetSupportedNorm(
 *             ksp, KSP_NORM_UNPRECONDITIONED, PC_SYMMETRIC, 1) )
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPDestroy_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1505
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPCreate_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libpetsc4py.KSPCreate_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ctx);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1543
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPDestroy_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPDestroy_Python(KSP __pyx_v_ksp) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PetscErrorCode __pyx_t_3;
  int __pyx_t_4;
  char const *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPDestroy_Python", 0);

  /* "libpetsc4py.pyx":1547
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPDestroy_Python")             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectComposeFunction(
 *             <PetscObject>ksp, b"KSPPythonSetType_C",
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPDestroy_Python"));

  /* "libpetsc4py.pyx":1548
 *     except IERR with gil:
 *     FunctionBegin(b"KSPDestroy_Python")
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>ksp, b"KSPPythonSetType_C",
 *             <PetscVoidFunction>NULL))
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_ksp), ((char *)"KSPPythonSetType_C"), ((PetscVoidFunction)NULL))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1548, __pyx_L1_error)

  /* "libpetsc4py.pyx":1552
 *             <PetscVoidFunction>NULL))
 *     #
 *     if not Py_IsInitialized(): return FunctionEnd()             # <<<<<<<<<<<<<<
 *     try:
 *         addRef(ksp)
 */
  __pyx_t_2 = ((!(Py_IsInitialized() != 0)) != 0);
  if (__pyx_t_2) {
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1553
 *     #
 *     if not Py_IsInitialized(): return FunctionEnd()
 *     try:             # <<<<<<<<<<<<<<
 *         addRef(ksp)
 *         KSPPythonSetContext(ksp, NULL)
 */
  /*try:*/ {

    /* "libpetsc4py.pyx":1554
 *     if not Py_IsInitialized(): return FunctionEnd()
 *     try:
 *         addRef(ksp)             # <<<<<<<<<<<<<<
 *         KSPPythonSetContext(ksp, NULL)
 *     finally:
 */
    __pyx_f_11libpetsc4py_addRef(__pyx_v_ksp);

    /* "libpetsc4py.pyx":1555
 *     try:
 *         addRef(ksp)
 *         KSPPythonSetContext(ksp, NULL)             # <<<<<<<<<<<<<<
 *     finally:
 *         delRef(ksp)
 */
    __pyx_t_3 = KSPPythonSetContext(__pyx_v_ksp, NULL); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1555, __pyx_L5_error)
  }

  /* "libpetsc4py.pyx":1557
 *         KSPPythonSetContext(ksp, NULL)
 *     finally:
 *         delRef(ksp)             # <<<<<<<<<<<<<<
 *         Py_DECREF(<PyObject*>ksp.data)
 *         ksp.data = NULL
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_f_11libpetsc4py_delRef(__pyx_v_ksp);

      /* "libpetsc4py.pyx":1558
 *     finally:
 *         delRef(ksp)
 *         Py_DECREF(<PyObject*>ksp.data)             # <<<<<<<<<<<<<<
 *         ksp.data = NULL
 *     return FunctionEnd()
 */
      Py_DECREF(((PyObject *)__pyx_v_ksp->data));

      /* "libpetsc4py.pyx":1559
 *         delRef(ksp)
 *         Py_DECREF(<PyObject*>ksp.data)
 *         ksp.data = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
      __pyx_v_ksp->data = NULL;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __pyx_t_1 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename;
      {

        /* "libpetsc4py.pyx":1557
 *         KSPPythonSetContext(ksp, NULL)
 *     finally:
 *         delRef(ksp)             # <<<<<<<<<<<<<<
 *         Py_DECREF(<PyObject*>ksp.data)
 *         ksp.data = NULL
 */
        __pyx_f_11libpetsc4py_delRef(__pyx_v_ksp);

        /* "libpetsc4py.pyx":1558
 *     finally:
 *         delRef(ksp)
 *         Py_DECREF(<PyObject*>ksp.data)             # <<<<<<<<<<<<<<
 *         ksp.data = NULL
 *     return FunctionEnd()
 */
        Py_DECREF(((PyObject *)__pyx_v_ksp->data));

        /* "libpetsc4py.pyx":1559
 *         delRef(ksp)
 *         Py_DECREF(<PyObject*>ksp.data)
 *         ksp.data = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
        __pyx_v_ksp->data = NULL;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      __pyx_lineno = __pyx_t_1; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "libpetsc4py.pyx":1560
 *         Py_DECREF(<PyObject*>ksp.data)
 *         ksp.data = NULL
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPSetUp_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1543
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPDestroy_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.KSPDestroy_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1562
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPSetUp_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPSetUp_Python(KSP __pyx_v_ksp) {
  char __pyx_v_name[0x800];
  PetscBool __pyx_v_found;
  PyObject *__pyx_v_setUp = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PetscErrorCode __pyx_t_5;
  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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPSetUp_Python", 0);

  /* "libpetsc4py.pyx":1566
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPSetUp_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef char name[2048]
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPSetUp_Python"));

  /* "libpetsc4py.pyx":1569
 *     #
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE             # <<<<<<<<<<<<<<
 *     if PyKSP(ksp).self is None:
 *         CHKERR( PetscOptionsGetString(NULL,
 */
  __pyx_v_found = PETSC_FALSE;

  /* "libpetsc4py.pyx":1570
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyKSP(ksp).self is None:             # <<<<<<<<<<<<<<
 *         CHKERR( PetscOptionsGetString(NULL,
 *                 getPrefix(ksp), b"-ksp_python_type",
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1570, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (((struct __pyx_obj_11libpetsc4py__PyKSP *)__pyx_t_1)->__pyx_base.self == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":1571
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyKSP(ksp).self is None:
 *         CHKERR( PetscOptionsGetString(NULL,             # <<<<<<<<<<<<<<
 *                 getPrefix(ksp), b"-ksp_python_type",
 *                 name,sizeof(name),&found) )
 */
    __pyx_t_4 = __pyx_f_11libpetsc4py_CHKERR(PetscOptionsGetString(NULL, __pyx_f_11libpetsc4py_getPrefix(__pyx_v_ksp), ((char *)"-ksp_python_type"), __pyx_v_name, (sizeof(__pyx_v_name)), (&__pyx_v_found))); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1571, __pyx_L1_error)

    /* "libpetsc4py.pyx":1574
 *                 getPrefix(ksp), b"-ksp_python_type",
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:             # <<<<<<<<<<<<<<
 *             CHKERR( KSPPythonSetType_PYTHON(ksp,name) )
 *     if PyKSP(ksp).self is None:
 */
    if (__pyx_v_found) {
    } else {
      __pyx_t_3 = __pyx_v_found;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_name[0]) != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_3) {

      /* "libpetsc4py.pyx":1575
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:
 *             CHKERR( KSPPythonSetType_PYTHON(ksp,name) )             # <<<<<<<<<<<<<<
 *     if PyKSP(ksp).self is None:
 *         return PetscSETERR(PETSC_ERR_USER,
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_KSPPythonSetType_PYTHON(__pyx_v_ksp, __pyx_v_name); if (unlikely(__pyx_t_5 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1575, __pyx_L1_error)
      __pyx_t_4 = __pyx_f_11libpetsc4py_CHKERR(__pyx_t_5); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1575, __pyx_L1_error)

      /* "libpetsc4py.pyx":1574
 *                 getPrefix(ksp), b"-ksp_python_type",
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:             # <<<<<<<<<<<<<<
 *             CHKERR( KSPPythonSetType_PYTHON(ksp,name) )
 *     if PyKSP(ksp).self is None:
 */
    }

    /* "libpetsc4py.pyx":1570
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyKSP(ksp).self is None:             # <<<<<<<<<<<<<<
 *         CHKERR( PetscOptionsGetString(NULL,
 *                 getPrefix(ksp), b"-ksp_python_type",
 */
  }

  /* "libpetsc4py.pyx":1576
 *         if found and name[0]:
 *             CHKERR( KSPPythonSetType_PYTHON(ksp,name) )
 *     if PyKSP(ksp).self is None:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER,
 *             "Python context not set, call one of \n"
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1576, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = (((struct __pyx_obj_11libpetsc4py__PyKSP *)__pyx_t_1)->__pyx_base.self == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":1577
 *             CHKERR( KSPPythonSetType_PYTHON(ksp,name) )
 *     if PyKSP(ksp).self is None:
 *         return PetscSETERR(PETSC_ERR_USER,             # <<<<<<<<<<<<<<
 *             "Python context not set, call one of \n"
 *             " * KSPPythonSetType(ksp,\"[package.]module.class\")\n"
 */
    __pyx_r = __pyx_f_11libpetsc4py_PetscSETERR(PETSC_ERR_USER, ((char *)"Python context not set, call one of \n * KSPPythonSetType(ksp,\"[package.]module.class\")\n * KSPSetFromOptions(ksp) and pass option -ksp_python_type [package.]module.class"));
    goto __pyx_L0;

    /* "libpetsc4py.pyx":1576
 *         if found and name[0]:
 *             CHKERR( KSPPythonSetType_PYTHON(ksp,name) )
 *     if PyKSP(ksp).self is None:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER,
 *             "Python context not set, call one of \n"
 */
  }

  /* "libpetsc4py.pyx":1583
 *             "-ksp_python_type [package.]module.class")
 *     #
 *     cdef setUp = PyKSP(ksp).setUp             # <<<<<<<<<<<<<<
 *     if setUp is not None:
 *         setUp(KSP_(ksp))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_setUp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_setUp = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "libpetsc4py.pyx":1584
 *     #
 *     cdef setUp = PyKSP(ksp).setUp
 *     if setUp is not None:             # <<<<<<<<<<<<<<
 *         setUp(KSP_(ksp))
 *     return FunctionEnd()
 */
  __pyx_t_2 = (__pyx_v_setUp != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":1585
 *     cdef setUp = PyKSP(ksp).setUp
 *     if setUp is not None:
 *         setUp(KSP_(ksp))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1585, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_setUp);
    __pyx_t_7 = __pyx_v_setUp; __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_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1585, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "libpetsc4py.pyx":1584
 *     #
 *     cdef setUp = PyKSP(ksp).setUp
 *     if setUp is not None:             # <<<<<<<<<<<<<<
 *         setUp(KSP_(ksp))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1586
 *     if setUp is not None:
 *         setUp(KSP_(ksp))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPReset_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1562
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPSetUp_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

  /* 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_AddTraceback("libpetsc4py.KSPSetUp_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setUp);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1588
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPReset_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPReset_Python(KSP __pyx_v_ksp) {
  PyObject *__pyx_v_reset = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPReset_Python", 0);

  /* "libpetsc4py.pyx":1592
 *     ) \
 *     except IERR with gil:
 *     if getRef(ksp) == 0: return 0             # <<<<<<<<<<<<<<
 *     FunctionBegin(b"KSPReset_Python")
 *     CHKERR( PetscObjectCompose(<PetscObject>ksp,b"@ksp.vec_work_sol",NULL) )
 */
  __pyx_t_1 = ((__pyx_f_11libpetsc4py_getRef(__pyx_v_ksp) == 0) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1593
 *     except IERR with gil:
 *     if getRef(ksp) == 0: return 0
 *     FunctionBegin(b"KSPReset_Python")             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectCompose(<PetscObject>ksp,b"@ksp.vec_work_sol",NULL) )
 *     CHKERR( PetscObjectCompose(<PetscObject>ksp,b"@ksp.vec_work_res",NULL) )
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPReset_Python"));

  /* "libpetsc4py.pyx":1594
 *     if getRef(ksp) == 0: return 0
 *     FunctionBegin(b"KSPReset_Python")
 *     CHKERR( PetscObjectCompose(<PetscObject>ksp,b"@ksp.vec_work_sol",NULL) )             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectCompose(<PetscObject>ksp,b"@ksp.vec_work_res",NULL) )
 *     cdef reset = PyKSP(ksp).reset
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectCompose(((PetscObject)__pyx_v_ksp), ((char *)"@ksp.vec_work_sol"), NULL)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1594, __pyx_L1_error)

  /* "libpetsc4py.pyx":1595
 *     FunctionBegin(b"KSPReset_Python")
 *     CHKERR( PetscObjectCompose(<PetscObject>ksp,b"@ksp.vec_work_sol",NULL) )
 *     CHKERR( PetscObjectCompose(<PetscObject>ksp,b"@ksp.vec_work_res",NULL) )             # <<<<<<<<<<<<<<
 *     cdef reset = PyKSP(ksp).reset
 *     if reset is not None:
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectCompose(((PetscObject)__pyx_v_ksp), ((char *)"@ksp.vec_work_res"), NULL)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1595, __pyx_L1_error)

  /* "libpetsc4py.pyx":1596
 *     CHKERR( PetscObjectCompose(<PetscObject>ksp,b"@ksp.vec_work_sol",NULL) )
 *     CHKERR( PetscObjectCompose(<PetscObject>ksp,b"@ksp.vec_work_res",NULL) )
 *     cdef reset = PyKSP(ksp).reset             # <<<<<<<<<<<<<<
 *     if reset is not None:
 *         reset(KSP_(ksp))
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1596, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_reset); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1596, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_reset = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "libpetsc4py.pyx":1597
 *     CHKERR( PetscObjectCompose(<PetscObject>ksp,b"@ksp.vec_work_res",NULL) )
 *     cdef reset = PyKSP(ksp).reset
 *     if reset is not None:             # <<<<<<<<<<<<<<
 *         reset(KSP_(ksp))
 *     return FunctionEnd()
 */
  __pyx_t_1 = (__pyx_v_reset != Py_None);
  __pyx_t_5 = (__pyx_t_1 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":1598
 *     cdef reset = PyKSP(ksp).reset
 *     if reset is not None:
 *         reset(KSP_(ksp))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_reset);
    __pyx_t_6 = __pyx_v_reset; __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "libpetsc4py.pyx":1597
 *     CHKERR( PetscObjectCompose(<PetscObject>ksp,b"@ksp.vec_work_res",NULL) )
 *     cdef reset = PyKSP(ksp).reset
 *     if reset is not None:             # <<<<<<<<<<<<<<
 *         reset(KSP_(ksp))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1599
 *     if reset is not None:
 *         reset(KSP_(ksp))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPSetFromOptions_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1588
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPReset_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libpetsc4py.KSPReset_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_reset);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1601
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPSetFromOptions_Python(             # <<<<<<<<<<<<<<
 *     PetscOptionItems *PetscOptionsObject,
 *     PetscKSP ksp,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPSetFromOptions_Python(PetscOptionItems *__pyx_v_PetscOptionsObject, KSP __pyx_v_ksp) {
  char __pyx_v_name[0x800];
  char *__pyx_v_defval;
  PetscBool __pyx_v_found;
  PetscOptionItems *PetscOptionsObject;
  PyObject *__pyx_v_setFromOptions = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PetscErrorCode __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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPSetFromOptions_Python", 0);

  /* "libpetsc4py.pyx":1606
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPSetFromOptions_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef char name[2048], *defval = PyKSP(ksp).getname()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPSetFromOptions_Python"));

  /* "libpetsc4py.pyx":1608
 *     FunctionBegin(b"KSPSetFromOptions_Python")
 *     #
 *     cdef char name[2048], *defval = PyKSP(ksp).getname()             # <<<<<<<<<<<<<<
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1608, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_11libpetsc4py__PyKSP *)((struct __pyx_obj_11libpetsc4py__PyKSP *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.getname(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1)); if (unlikely(__pyx_t_2 == ((char *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 1608, __pyx_L1_error)
  __pyx_v_defval = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":1609
 *     #
 *     cdef char name[2048], *defval = PyKSP(ksp).getname()
 *     cdef PetscBool found = PETSC_FALSE             # <<<<<<<<<<<<<<
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 *     CHKERR( PetscOptionsString(
 */
  __pyx_v_found = PETSC_FALSE;

  /* "libpetsc4py.pyx":1610
 *     cdef char name[2048], *defval = PyKSP(ksp).getname()
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject             # <<<<<<<<<<<<<<
 *     CHKERR( PetscOptionsString(
 *             b"-ksp_python_type",b"Python [package.]module[.{class|function}]",
 */
  PetscOptionsObject = __pyx_v_PetscOptionsObject;

  /* "libpetsc4py.pyx":1611
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 *     CHKERR( PetscOptionsString(             # <<<<<<<<<<<<<<
 *             b"-ksp_python_type",b"Python [package.]module[.{class|function}]",
 *             b"KSPPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 */
  __pyx_t_3 = __pyx_f_11libpetsc4py_CHKERR(PetscOptionsString(((char *)"-ksp_python_type"), ((char *)"Python [package.]module[.{class|function}]"), ((char *)"KSPPythonSetType"), __pyx_v_defval, __pyx_v_name, (sizeof(__pyx_v_name)), (&__pyx_v_found))); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1611, __pyx_L1_error)

  /* "libpetsc4py.pyx":1613
 *     CHKERR( PetscOptionsString(
 *             b"-ksp_python_type",b"Python [package.]module[.{class|function}]",
 *             b"KSPPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;             # <<<<<<<<<<<<<<
 *     if found and name[0]:
 *         CHKERR( KSPPythonSetType_PYTHON(ksp,name) )
 */
  ((void)PetscOptionsObject);

  /* "libpetsc4py.pyx":1614
 *             b"-ksp_python_type",b"Python [package.]module[.{class|function}]",
 *             b"KSPPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:             # <<<<<<<<<<<<<<
 *         CHKERR( KSPPythonSetType_PYTHON(ksp,name) )
 *     #
 */
  if (__pyx_v_found) {
  } else {
    __pyx_t_4 = __pyx_v_found;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_name[0]) != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1615
 *             b"KSPPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:
 *         CHKERR( KSPPythonSetType_PYTHON(ksp,name) )             # <<<<<<<<<<<<<<
 *     #
 *     cdef setFromOptions = PyKSP(ksp).setFromOptions
 */
    __pyx_t_6 = __pyx_f_11libpetsc4py_KSPPythonSetType_PYTHON(__pyx_v_ksp, __pyx_v_name); if (unlikely(__pyx_t_6 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1615, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_11libpetsc4py_CHKERR(__pyx_t_6); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1615, __pyx_L1_error)

    /* "libpetsc4py.pyx":1614
 *             b"-ksp_python_type",b"Python [package.]module[.{class|function}]",
 *             b"KSPPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:             # <<<<<<<<<<<<<<
 *         CHKERR( KSPPythonSetType_PYTHON(ksp,name) )
 *     #
 */
  }

  /* "libpetsc4py.pyx":1617
 *         CHKERR( KSPPythonSetType_PYTHON(ksp,name) )
 *     #
 *     cdef setFromOptions = PyKSP(ksp).setFromOptions             # <<<<<<<<<<<<<<
 *     if setFromOptions is not None:
 *         setFromOptions(KSP_(ksp))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_setFromOptions); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_setFromOptions = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "libpetsc4py.pyx":1618
 *     #
 *     cdef setFromOptions = PyKSP(ksp).setFromOptions
 *     if setFromOptions is not None:             # <<<<<<<<<<<<<<
 *         setFromOptions(KSP_(ksp))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_setFromOptions != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":1619
 *     cdef setFromOptions = PyKSP(ksp).setFromOptions
 *     if setFromOptions is not None:
 *         setFromOptions(KSP_(ksp))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_setFromOptions);
    __pyx_t_8 = __pyx_v_setFromOptions; __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_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __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, 1619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "libpetsc4py.pyx":1618
 *     #
 *     cdef setFromOptions = PyKSP(ksp).setFromOptions
 *     if setFromOptions is not None:             # <<<<<<<<<<<<<<
 *         setFromOptions(KSP_(ksp))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1620
 *     if setFromOptions is not None:
 *         setFromOptions(KSP_(ksp))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPView_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1601
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPSetFromOptions_Python(             # <<<<<<<<<<<<<<
 *     PetscOptionItems *PetscOptionsObject,
 *     PetscKSP ksp,
 */

  /* function exit code */
  __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("libpetsc4py.KSPSetFromOptions_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setFromOptions);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1622
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPView_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP    ksp,
 *     PetscViewer vwr,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPView_Python(KSP __pyx_v_ksp, PetscViewer __pyx_v_vwr) {
  PyObject *__pyx_v_view = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPView_Python", 0);

  /* "libpetsc4py.pyx":1627
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPView_Python")             # <<<<<<<<<<<<<<
 *     viewcontext(PyKSP(ksp), vwr)
 *     cdef view = PyKSP(ksp).view
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPView_Python"));

  /* "libpetsc4py.pyx":1628
 *     except IERR with gil:
 *     FunctionBegin(b"KSPView_Python")
 *     viewcontext(PyKSP(ksp), vwr)             # <<<<<<<<<<<<<<
 *     cdef view = PyKSP(ksp).view
 *     if view is not None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_11libpetsc4py_viewcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_vwr); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1628, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":1629
 *     FunctionBegin(b"KSPView_Python")
 *     viewcontext(PyKSP(ksp), vwr)
 *     cdef view = PyKSP(ksp).view             # <<<<<<<<<<<<<<
 *     if view is not None:
 *         view(KSP_(ksp), Viewer_(vwr))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_view); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_view = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":1630
 *     viewcontext(PyKSP(ksp), vwr)
 *     cdef view = PyKSP(ksp).view
 *     if view is not None:             # <<<<<<<<<<<<<<
 *         view(KSP_(ksp), Viewer_(vwr))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_view != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":1631
 *     cdef view = PyKSP(ksp).view
 *     if view is not None:
 *         view(KSP_(ksp), Viewer_(vwr))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Viewer_(__pyx_v_vwr)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_view);
    __pyx_t_7 = __pyx_v_view; __pyx_t_8 = NULL;
    __pyx_t_2 = 0;
    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_2 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1631, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1631, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1631, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_2, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_2, __pyx_t_6);
      __pyx_t_1 = 0;
      __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1631, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libpetsc4py.pyx":1630
 *     viewcontext(PyKSP(ksp), vwr)
 *     cdef view = PyKSP(ksp).view
 *     if view is not None:             # <<<<<<<<<<<<<<
 *         view(KSP_(ksp), Viewer_(vwr))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1632
 *     if view is not None:
 *         view(KSP_(ksp), Viewer_(vwr))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPBuildSolution_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1622
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPView_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP    ksp,
 *     PetscViewer vwr,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.KSPView_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_view);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1634
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPBuildSolution_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     PetscVec v,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPBuildSolution_Python(KSP __pyx_v_ksp, Vec __pyx_v_v, Vec *__pyx_v_V) {
  Vec __pyx_v_x;
  PyObject *__pyx_v_buildSolution = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPBuildSolution_Python", 0);

  /* "libpetsc4py.pyx":1640
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPBuildSolution_Python")             # <<<<<<<<<<<<<<
 *     cdef PetscVec x = v
 *     cdef buildSolution = PyKSP(ksp).buildSolution
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPBuildSolution_Python"));

  /* "libpetsc4py.pyx":1641
 *     except IERR with gil:
 *     FunctionBegin(b"KSPBuildSolution_Python")
 *     cdef PetscVec x = v             # <<<<<<<<<<<<<<
 *     cdef buildSolution = PyKSP(ksp).buildSolution
 *     if buildSolution is not None:
 */
  __pyx_v_x = __pyx_v_v;

  /* "libpetsc4py.pyx":1642
 *     FunctionBegin(b"KSPBuildSolution_Python")
 *     cdef PetscVec x = v
 *     cdef buildSolution = PyKSP(ksp).buildSolution             # <<<<<<<<<<<<<<
 *     if buildSolution is not None:
 *         if x == NULL: pass # XXX
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_buildSolution); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_buildSolution = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1643
 *     cdef PetscVec x = v
 *     cdef buildSolution = PyKSP(ksp).buildSolution
 *     if buildSolution is not None:             # <<<<<<<<<<<<<<
 *         if x == NULL: pass # XXX
 *         buildSolution(KSP_(ksp), Vec_(x))
 */
  __pyx_t_3 = (__pyx_v_buildSolution != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1644
 *     cdef buildSolution = PyKSP(ksp).buildSolution
 *     if buildSolution is not None:
 *         if x == NULL: pass # XXX             # <<<<<<<<<<<<<<
 *         buildSolution(KSP_(ksp), Vec_(x))
 *         if V != NULL: V[0] = x
 */
    __pyx_t_4 = ((__pyx_v_x == NULL) != 0);
    if (__pyx_t_4) {
    }

    /* "libpetsc4py.pyx":1645
 *     if buildSolution is not None:
 *         if x == NULL: pass # XXX
 *         buildSolution(KSP_(ksp), Vec_(x))             # <<<<<<<<<<<<<<
 *         if V != NULL: V[0] = x
 *     else:
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1645, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1645, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_buildSolution);
    __pyx_t_6 = __pyx_v_buildSolution; __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1645, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __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_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_1, __pyx_t_5};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1645, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1645, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5);
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1645, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":1646
 *         if x == NULL: pass # XXX
 *         buildSolution(KSP_(ksp), Vec_(x))
 *         if V != NULL: V[0] = x             # <<<<<<<<<<<<<<
 *     else:
 *         CHKERR( KSPBuildSolutionDefault(ksp, v, V) )
 */
    __pyx_t_4 = ((__pyx_v_V != NULL) != 0);
    if (__pyx_t_4) {
      (__pyx_v_V[0]) = __pyx_v_x;
    }

    /* "libpetsc4py.pyx":1643
 *     cdef PetscVec x = v
 *     cdef buildSolution = PyKSP(ksp).buildSolution
 *     if buildSolution is not None:             # <<<<<<<<<<<<<<
 *         if x == NULL: pass # XXX
 *         buildSolution(KSP_(ksp), Vec_(x))
 */
    goto __pyx_L3;
  }

  /* "libpetsc4py.pyx":1648
 *         if V != NULL: V[0] = x
 *     else:
 *         CHKERR( KSPBuildSolutionDefault(ksp, v, V) )             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  /*else*/ {
    __pyx_t_8 = __pyx_f_11libpetsc4py_CHKERR(KSPBuildSolutionDefault(__pyx_v_ksp, __pyx_v_v, __pyx_v_V)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1648, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "libpetsc4py.pyx":1649
 *     else:
 *         CHKERR( KSPBuildSolutionDefault(ksp, v, V) )
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPBuildResidual_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1634
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPBuildSolution_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     PetscVec v,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.KSPBuildSolution_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_buildSolution);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1651
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPBuildResidual_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     PetscVec t,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPBuildResidual_Python(KSP __pyx_v_ksp, Vec __pyx_v_t, Vec __pyx_v_v, Vec *__pyx_v_V) {
  PyObject *__pyx_v_buildResidual = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPBuildResidual_Python", 0);

  /* "libpetsc4py.pyx":1658
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPBuildResidual_Python")             # <<<<<<<<<<<<<<
 *     cdef buildResidual = PyKSP(ksp).buildResidual
 *     if buildResidual is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPBuildResidual_Python"));

  /* "libpetsc4py.pyx":1659
 *     except IERR with gil:
 *     FunctionBegin(b"KSPBuildResidual_Python")
 *     cdef buildResidual = PyKSP(ksp).buildResidual             # <<<<<<<<<<<<<<
 *     if buildResidual is not None:
 *         buildResidual(KSP_(ksp), Vec_(t), Vec_(v))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_buildResidual); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_buildResidual = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1660
 *     FunctionBegin(b"KSPBuildResidual_Python")
 *     cdef buildResidual = PyKSP(ksp).buildResidual
 *     if buildResidual is not None:             # <<<<<<<<<<<<<<
 *         buildResidual(KSP_(ksp), Vec_(t), Vec_(v))
 *         if V != NULL: V[0] = v
 */
  __pyx_t_3 = (__pyx_v_buildResidual != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1661
 *     cdef buildResidual = PyKSP(ksp).buildResidual
 *     if buildResidual is not None:
 *         buildResidual(KSP_(ksp), Vec_(t), Vec_(v))             # <<<<<<<<<<<<<<
 *         if V != NULL: V[0] = v
 *     else:
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_t)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_v)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_buildResidual);
    __pyx_t_7 = __pyx_v_buildResidual; __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    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_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1661, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1661, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1661, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1661, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":1662
 *     if buildResidual is not None:
 *         buildResidual(KSP_(ksp), Vec_(t), Vec_(v))
 *         if V != NULL: V[0] = v             # <<<<<<<<<<<<<<
 *     else:
 *         CHKERR( KSPBuildResidualDefault(ksp, t, v, V) )
 */
    __pyx_t_4 = ((__pyx_v_V != NULL) != 0);
    if (__pyx_t_4) {
      (__pyx_v_V[0]) = __pyx_v_v;
    }

    /* "libpetsc4py.pyx":1660
 *     FunctionBegin(b"KSPBuildResidual_Python")
 *     cdef buildResidual = PyKSP(ksp).buildResidual
 *     if buildResidual is not None:             # <<<<<<<<<<<<<<
 *         buildResidual(KSP_(ksp), Vec_(t), Vec_(v))
 *         if V != NULL: V[0] = v
 */
    goto __pyx_L3;
  }

  /* "libpetsc4py.pyx":1664
 *         if V != NULL: V[0] = v
 *     else:
 *         CHKERR( KSPBuildResidualDefault(ksp, t, v, V) )             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  /*else*/ {
    __pyx_t_9 = __pyx_f_11libpetsc4py_CHKERR(KSPBuildResidualDefault(__pyx_v_ksp, __pyx_v_t, __pyx_v_v, __pyx_v_V)); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1664, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "libpetsc4py.pyx":1665
 *     else:
 *         CHKERR( KSPBuildResidualDefault(ksp, t, v, V) )
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPSolve_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1651
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPBuildResidual_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     PetscVec t,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.KSPBuildResidual_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_buildResidual);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1667
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPSolve_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPSolve_Python(KSP __pyx_v_ksp) {
  Vec __pyx_v_B;
  Vec __pyx_v_X;
  PyObject *__pyx_v_solve = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PetscErrorCode __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPSolve_Python", 0);

  /* "libpetsc4py.pyx":1671
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPSolve_Python")             # <<<<<<<<<<<<<<
 *     cdef PetscVec B = NULL, X = NULL
 *     CHKERR( KSPGetRhs(ksp,&B)      )
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPSolve_Python"));

  /* "libpetsc4py.pyx":1672
 *     except IERR with gil:
 *     FunctionBegin(b"KSPSolve_Python")
 *     cdef PetscVec B = NULL, X = NULL             # <<<<<<<<<<<<<<
 *     CHKERR( KSPGetRhs(ksp,&B)      )
 *     CHKERR( KSPGetSolution(ksp,&X) )
 */
  __pyx_v_B = NULL;
  __pyx_v_X = NULL;

  /* "libpetsc4py.pyx":1673
 *     FunctionBegin(b"KSPSolve_Python")
 *     cdef PetscVec B = NULL, X = NULL
 *     CHKERR( KSPGetRhs(ksp,&B)      )             # <<<<<<<<<<<<<<
 *     CHKERR( KSPGetSolution(ksp,&X) )
 *     #
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPGetRhs(__pyx_v_ksp, (&__pyx_v_B))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1673, __pyx_L1_error)

  /* "libpetsc4py.pyx":1674
 *     cdef PetscVec B = NULL, X = NULL
 *     CHKERR( KSPGetRhs(ksp,&B)      )
 *     CHKERR( KSPGetSolution(ksp,&X) )             # <<<<<<<<<<<<<<
 *     #
 *     ksp.iter = 0
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPGetSolution(__pyx_v_ksp, (&__pyx_v_X))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1674, __pyx_L1_error)

  /* "libpetsc4py.pyx":1676
 *     CHKERR( KSPGetSolution(ksp,&X) )
 *     #
 *     ksp.iter = 0             # <<<<<<<<<<<<<<
 *     ksp.reason = KSP_CONVERGED_ITERATING
 *     #
 */
  __pyx_v_ksp->its = 0;

  /* "libpetsc4py.pyx":1677
 *     #
 *     ksp.iter = 0
 *     ksp.reason = KSP_CONVERGED_ITERATING             # <<<<<<<<<<<<<<
 *     #
 *     cdef solve = None
 */
  __pyx_v_ksp->reason = KSP_CONVERGED_ITERATING;

  /* "libpetsc4py.pyx":1679
 *     ksp.reason = KSP_CONVERGED_ITERATING
 *     #
 *     cdef solve = None             # <<<<<<<<<<<<<<
 *     if ksp.transpose_solve:
 *         solve = PyKSP(ksp).solveTranspose
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_solve = Py_None;

  /* "libpetsc4py.pyx":1680
 *     #
 *     cdef solve = None
 *     if ksp.transpose_solve:             # <<<<<<<<<<<<<<
 *         solve = PyKSP(ksp).solveTranspose
 *     else:
 */
  if (__pyx_v_ksp->transpose_solve) {

    /* "libpetsc4py.pyx":1681
 *     cdef solve = None
 *     if ksp.transpose_solve:
 *         solve = PyKSP(ksp).solveTranspose             # <<<<<<<<<<<<<<
 *     else:
 *         solve = PyKSP(ksp).solve
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_solveTranspose); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_solve, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "libpetsc4py.pyx":1680
 *     #
 *     cdef solve = None
 *     if ksp.transpose_solve:             # <<<<<<<<<<<<<<
 *         solve = PyKSP(ksp).solveTranspose
 *     else:
 */
    goto __pyx_L3;
  }

  /* "libpetsc4py.pyx":1683
 *         solve = PyKSP(ksp).solveTranspose
 *     else:
 *         solve = PyKSP(ksp).solve             # <<<<<<<<<<<<<<
 *     if solve is not None:
 *         solve(KSP_(ksp),Vec_(B),Vec_(X))
 */
  /*else*/ {
    __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1683, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_solve); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1683, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_solve, __pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "libpetsc4py.pyx":1684
 *     else:
 *         solve = PyKSP(ksp).solve
 *     if solve is not None:             # <<<<<<<<<<<<<<
 *         solve(KSP_(ksp),Vec_(B),Vec_(X))
 *     else:
 */
  __pyx_t_4 = (__pyx_v_solve != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":1685
 *         solve = PyKSP(ksp).solve
 *     if solve is not None:
 *         solve(KSP_(ksp),Vec_(B),Vec_(X))             # <<<<<<<<<<<<<<
 *     else:
 *         KSPSolve_Python_default(ksp,B,X)
 */
    __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1685, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_B)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1685, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_X)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1685, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_solve);
    __pyx_t_8 = __pyx_v_solve; __pyx_t_9 = NULL;
    __pyx_t_1 = 0;
    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 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_3, __pyx_t_6, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_1, 3+__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1685, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_3, __pyx_t_6, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_1, 3+__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1685, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1685, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_1, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_1, __pyx_t_7);
      __pyx_t_3 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1685, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":1684
 *     else:
 *         solve = PyKSP(ksp).solve
 *     if solve is not None:             # <<<<<<<<<<<<<<
 *         solve(KSP_(ksp),Vec_(B),Vec_(X))
 *     else:
 */
    goto __pyx_L4;
  }

  /* "libpetsc4py.pyx":1687
 *         solve(KSP_(ksp),Vec_(B),Vec_(X))
 *     else:
 *         KSPSolve_Python_default(ksp,B,X)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  /*else*/ {
    __pyx_t_11 = __pyx_f_11libpetsc4py_KSPSolve_Python_default(__pyx_v_ksp, __pyx_v_B, __pyx_v_X); if (unlikely(__pyx_t_11 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1687, __pyx_L1_error)
  }
  __pyx_L4:;

  /* "libpetsc4py.pyx":1688
 *     else:
 *         KSPSolve_Python_default(ksp,B,X)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPSolve_Python_default(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1667
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPSolve_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __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_AddTraceback("libpetsc4py.KSPSolve_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_solve);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1690
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPSolve_Python_default(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     PetscVec B,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPSolve_Python_default(KSP __pyx_v_ksp, Vec __pyx_v_B, Vec __pyx_v_X) {
  Vec __pyx_v_t;
  Vec __pyx_v_v;
  CYTHON_UNUSED PetscInt __pyx_v_its;
  Vec __pyx_v_R;
  PetscReal __pyx_v_rnorm;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PetscInt __pyx_t_3;
  PetscErrorCode __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPSolve_Python_default", 0);

  /* "libpetsc4py.pyx":1696
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPSolve_Python_default")             # <<<<<<<<<<<<<<
 *     #
 *     cdef PetscVec t = NULL
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPSolve_Python_default"));

  /* "libpetsc4py.pyx":1698
 *     FunctionBegin(b"KSPSolve_Python_default")
 *     #
 *     cdef PetscVec t = NULL             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectQuery(
 *             <PetscObject>ksp,
 */
  __pyx_v_t = NULL;

  /* "libpetsc4py.pyx":1699
 *     #
 *     cdef PetscVec t = NULL
 *     CHKERR( PetscObjectQuery(             # <<<<<<<<<<<<<<
 *             <PetscObject>ksp,
 *              b"@ksp.vec_work_sol",
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectQuery(((PetscObject)__pyx_v_ksp), ((char *)"@ksp.vec_work_sol"), ((PetscObject *)(&__pyx_v_t)))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1699, __pyx_L1_error)

  /* "libpetsc4py.pyx":1703
 *              b"@ksp.vec_work_sol",
 *              <PetscObject*>&t) )
 *     if t == NULL:             # <<<<<<<<<<<<<<
 *         CHKERR( VecDuplicate(X,&t) )
 *         CHKERR( PetscObjectCompose(
 */
  __pyx_t_2 = ((__pyx_v_t == NULL) != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":1704
 *              <PetscObject*>&t) )
 *     if t == NULL:
 *         CHKERR( VecDuplicate(X,&t) )             # <<<<<<<<<<<<<<
 *         CHKERR( PetscObjectCompose(
 *                 <PetscObject>ksp,
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecDuplicate(__pyx_v_X, (&__pyx_v_t))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1704, __pyx_L1_error)

    /* "libpetsc4py.pyx":1705
 *     if t == NULL:
 *         CHKERR( VecDuplicate(X,&t) )
 *         CHKERR( PetscObjectCompose(             # <<<<<<<<<<<<<<
 *                 <PetscObject>ksp,
 *                  b"@ksp.vec_work_sol",
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectCompose(((PetscObject)__pyx_v_ksp), ((char *)"@ksp.vec_work_sol"), ((PetscObject)__pyx_v_t))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1705, __pyx_L1_error)

    /* "libpetsc4py.pyx":1703
 *              b"@ksp.vec_work_sol",
 *              <PetscObject*>&t) )
 *     if t == NULL:             # <<<<<<<<<<<<<<
 *         CHKERR( VecDuplicate(X,&t) )
 *         CHKERR( PetscObjectCompose(
 */
  }

  /* "libpetsc4py.pyx":1709
 *                  b"@ksp.vec_work_sol",
 *                  <PetscObject>t) )
 *     cdef PetscVec v = NULL             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectQuery(
 *             <PetscObject>ksp,
 */
  __pyx_v_v = NULL;

  /* "libpetsc4py.pyx":1710
 *                  <PetscObject>t) )
 *     cdef PetscVec v = NULL
 *     CHKERR( PetscObjectQuery(             # <<<<<<<<<<<<<<
 *             <PetscObject>ksp,
 *              b"@ksp.vec_work_res",
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectQuery(((PetscObject)__pyx_v_ksp), ((char *)"@ksp.vec_work_res"), ((PetscObject *)(&__pyx_v_v)))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1710, __pyx_L1_error)

  /* "libpetsc4py.pyx":1714
 *              b"@ksp.vec_work_res",
 *              <PetscObject*>&v) )
 *     if v == NULL:             # <<<<<<<<<<<<<<
 *         CHKERR( VecDuplicate(B,&v) )
 *         CHKERR( PetscObjectCompose(
 */
  __pyx_t_2 = ((__pyx_v_v == NULL) != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":1715
 *              <PetscObject*>&v) )
 *     if v == NULL:
 *         CHKERR( VecDuplicate(B,&v) )             # <<<<<<<<<<<<<<
 *         CHKERR( PetscObjectCompose(
 *                 <PetscObject>ksp,
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecDuplicate(__pyx_v_B, (&__pyx_v_v))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1715, __pyx_L1_error)

    /* "libpetsc4py.pyx":1716
 *     if v == NULL:
 *         CHKERR( VecDuplicate(B,&v) )
 *         CHKERR( PetscObjectCompose(             # <<<<<<<<<<<<<<
 *                 <PetscObject>ksp,
 *                  b"@ksp.vec_work_res",
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectCompose(((PetscObject)__pyx_v_ksp), ((char *)"@ksp.vec_work_res"), ((PetscObject)__pyx_v_v))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1716, __pyx_L1_error)

    /* "libpetsc4py.pyx":1714
 *              b"@ksp.vec_work_res",
 *              <PetscObject*>&v) )
 *     if v == NULL:             # <<<<<<<<<<<<<<
 *         CHKERR( VecDuplicate(B,&v) )
 *         CHKERR( PetscObjectCompose(
 */
  }

  /* "libpetsc4py.pyx":1721
 *                  <PetscObject>v) )
 *     #
 *     cdef PetscInt its = 0             # <<<<<<<<<<<<<<
 *     cdef PetscVec R = NULL
 *     cdef PetscReal rnorm = 0
 */
  __pyx_v_its = 0;

  /* "libpetsc4py.pyx":1722
 *     #
 *     cdef PetscInt its = 0
 *     cdef PetscVec R = NULL             # <<<<<<<<<<<<<<
 *     cdef PetscReal rnorm = 0
 *     #
 */
  __pyx_v_R = NULL;

  /* "libpetsc4py.pyx":1723
 *     cdef PetscInt its = 0
 *     cdef PetscVec R = NULL
 *     cdef PetscReal rnorm = 0             # <<<<<<<<<<<<<<
 *     #
 *     CHKERR( KSPBuildResidual(ksp,t,v,&R) )
 */
  __pyx_v_rnorm = 0.0;

  /* "libpetsc4py.pyx":1725
 *     cdef PetscReal rnorm = 0
 *     #
 *     CHKERR( KSPBuildResidual(ksp,t,v,&R) )             # <<<<<<<<<<<<<<
 *     CHKERR( VecNorm(R,NORM_2,&rnorm)     )
 *     #
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPBuildResidual(__pyx_v_ksp, __pyx_v_t, __pyx_v_v, (&__pyx_v_R))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1725, __pyx_L1_error)

  /* "libpetsc4py.pyx":1726
 *     #
 *     CHKERR( KSPBuildResidual(ksp,t,v,&R) )
 *     CHKERR( VecNorm(R,NORM_2,&rnorm)     )             # <<<<<<<<<<<<<<
 *     #
 *     CHKERR( KSPConverged(ksp,ksp.iter,rnorm,&ksp.reason) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecNorm(__pyx_v_R, NORM_2, (&__pyx_v_rnorm))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1726, __pyx_L1_error)

  /* "libpetsc4py.pyx":1728
 *     CHKERR( VecNorm(R,NORM_2,&rnorm)     )
 *     #
 *     CHKERR( KSPConverged(ksp,ksp.iter,rnorm,&ksp.reason) )             # <<<<<<<<<<<<<<
 *     CHKERR( KSPLogHistory(ksp,ksp.norm) )
 *     CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPConverged(__pyx_v_ksp, __pyx_v_ksp->its, __pyx_v_rnorm, (&__pyx_v_ksp->reason))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1728, __pyx_L1_error)

  /* "libpetsc4py.pyx":1729
 *     #
 *     CHKERR( KSPConverged(ksp,ksp.iter,rnorm,&ksp.reason) )
 *     CHKERR( KSPLogHistory(ksp,ksp.norm) )             # <<<<<<<<<<<<<<
 *     CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )
 *     for its from 0 <= its < ksp.max_its:
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPLogHistory(__pyx_v_ksp, __pyx_v_ksp->rnorm)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1729, __pyx_L1_error)

  /* "libpetsc4py.pyx":1730
 *     CHKERR( KSPConverged(ksp,ksp.iter,rnorm,&ksp.reason) )
 *     CHKERR( KSPLogHistory(ksp,ksp.norm) )
 *     CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )             # <<<<<<<<<<<<<<
 *     for its from 0 <= its < ksp.max_its:
 *         if ksp.reason: break
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPMonitor(__pyx_v_ksp, __pyx_v_ksp->its, __pyx_v_ksp->rnorm)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1730, __pyx_L1_error)

  /* "libpetsc4py.pyx":1731
 *     CHKERR( KSPLogHistory(ksp,ksp.norm) )
 *     CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )
 *     for its from 0 <= its < ksp.max_its:             # <<<<<<<<<<<<<<
 *         if ksp.reason: break
 *         KSPPreStep_Python(ksp)
 */
  __pyx_t_3 = __pyx_v_ksp->max_it;
  for (__pyx_v_its = 0; __pyx_v_its < __pyx_t_3; __pyx_v_its++) {

    /* "libpetsc4py.pyx":1732
 *     CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )
 *     for its from 0 <= its < ksp.max_its:
 *         if ksp.reason: break             # <<<<<<<<<<<<<<
 *         KSPPreStep_Python(ksp)
 *         #
 */
    if (__pyx_v_ksp->reason) {
      goto __pyx_L6_break;
    }

    /* "libpetsc4py.pyx":1733
 *     for its from 0 <= its < ksp.max_its:
 *         if ksp.reason: break
 *         KSPPreStep_Python(ksp)             # <<<<<<<<<<<<<<
 *         #
 *         KSPStep_Python(ksp,B,X)
 */
    __pyx_t_4 = __pyx_f_11libpetsc4py_KSPPreStep_Python(__pyx_v_ksp); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1733, __pyx_L1_error)

    /* "libpetsc4py.pyx":1735
 *         KSPPreStep_Python(ksp)
 *         #
 *         KSPStep_Python(ksp,B,X)             # <<<<<<<<<<<<<<
 *         CHKERR( KSPBuildResidual(ksp,t,v,&R) )
 *         CHKERR( VecNorm(R,NORM_2,&rnorm)     )
 */
    __pyx_t_4 = __pyx_f_11libpetsc4py_KSPStep_Python(__pyx_v_ksp, __pyx_v_B, __pyx_v_X); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1735, __pyx_L1_error)

    /* "libpetsc4py.pyx":1736
 *         #
 *         KSPStep_Python(ksp,B,X)
 *         CHKERR( KSPBuildResidual(ksp,t,v,&R) )             # <<<<<<<<<<<<<<
 *         CHKERR( VecNorm(R,NORM_2,&rnorm)     )
 *         ksp.iter += 1
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPBuildResidual(__pyx_v_ksp, __pyx_v_t, __pyx_v_v, (&__pyx_v_R))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1736, __pyx_L1_error)

    /* "libpetsc4py.pyx":1737
 *         KSPStep_Python(ksp,B,X)
 *         CHKERR( KSPBuildResidual(ksp,t,v,&R) )
 *         CHKERR( VecNorm(R,NORM_2,&rnorm)     )             # <<<<<<<<<<<<<<
 *         ksp.iter += 1
 *         #
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecNorm(__pyx_v_R, NORM_2, (&__pyx_v_rnorm))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1737, __pyx_L1_error)

    /* "libpetsc4py.pyx":1738
 *         CHKERR( KSPBuildResidual(ksp,t,v,&R) )
 *         CHKERR( VecNorm(R,NORM_2,&rnorm)     )
 *         ksp.iter += 1             # <<<<<<<<<<<<<<
 *         #
 *         KSPPostStep_Python(ksp)
 */
    __pyx_v_ksp->its = (__pyx_v_ksp->its + 1);

    /* "libpetsc4py.pyx":1740
 *         ksp.iter += 1
 *         #
 *         KSPPostStep_Python(ksp)             # <<<<<<<<<<<<<<
 *         CHKERR( KSPConverged(ksp,ksp.iter,rnorm,&ksp.reason) )
 *         CHKERR( KSPLogHistory(ksp,ksp.norm) )
 */
    __pyx_t_4 = __pyx_f_11libpetsc4py_KSPPostStep_Python(__pyx_v_ksp); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1740, __pyx_L1_error)

    /* "libpetsc4py.pyx":1741
 *         #
 *         KSPPostStep_Python(ksp)
 *         CHKERR( KSPConverged(ksp,ksp.iter,rnorm,&ksp.reason) )             # <<<<<<<<<<<<<<
 *         CHKERR( KSPLogHistory(ksp,ksp.norm) )
 *         CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPConverged(__pyx_v_ksp, __pyx_v_ksp->its, __pyx_v_rnorm, (&__pyx_v_ksp->reason))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1741, __pyx_L1_error)

    /* "libpetsc4py.pyx":1742
 *         KSPPostStep_Python(ksp)
 *         CHKERR( KSPConverged(ksp,ksp.iter,rnorm,&ksp.reason) )
 *         CHKERR( KSPLogHistory(ksp,ksp.norm) )             # <<<<<<<<<<<<<<
 *         CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )
 *     if ksp.iter == ksp.max_its:
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPLogHistory(__pyx_v_ksp, __pyx_v_ksp->rnorm)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1742, __pyx_L1_error)

    /* "libpetsc4py.pyx":1743
 *         CHKERR( KSPConverged(ksp,ksp.iter,rnorm,&ksp.reason) )
 *         CHKERR( KSPLogHistory(ksp,ksp.norm) )
 *         CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )             # <<<<<<<<<<<<<<
 *     if ksp.iter == ksp.max_its:
 *         if ksp.reason == KSP_CONVERGED_ITERATING:
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPMonitor(__pyx_v_ksp, __pyx_v_ksp->its, __pyx_v_ksp->rnorm)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1743, __pyx_L1_error)
  }
  __pyx_L6_break:;

  /* "libpetsc4py.pyx":1744
 *         CHKERR( KSPLogHistory(ksp,ksp.norm) )
 *         CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )
 *     if ksp.iter == ksp.max_its:             # <<<<<<<<<<<<<<
 *         if ksp.reason == KSP_CONVERGED_ITERATING:
 *             ksp.reason = KSP_DIVERGED_ITS
 */
  __pyx_t_2 = ((__pyx_v_ksp->its == __pyx_v_ksp->max_it) != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":1745
 *         CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )
 *     if ksp.iter == ksp.max_its:
 *         if ksp.reason == KSP_CONVERGED_ITERATING:             # <<<<<<<<<<<<<<
 *             ksp.reason = KSP_DIVERGED_ITS
 *     #
 */
    __pyx_t_2 = ((__pyx_v_ksp->reason == KSP_CONVERGED_ITERATING) != 0);
    if (__pyx_t_2) {

      /* "libpetsc4py.pyx":1746
 *     if ksp.iter == ksp.max_its:
 *         if ksp.reason == KSP_CONVERGED_ITERATING:
 *             ksp.reason = KSP_DIVERGED_ITS             # <<<<<<<<<<<<<<
 *     #
 *     return FunctionEnd()
 */
      __pyx_v_ksp->reason = KSP_DIVERGED_ITS;

      /* "libpetsc4py.pyx":1745
 *         CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )
 *     if ksp.iter == ksp.max_its:
 *         if ksp.reason == KSP_CONVERGED_ITERATING:             # <<<<<<<<<<<<<<
 *             ksp.reason = KSP_DIVERGED_ITS
 *     #
 */
    }

    /* "libpetsc4py.pyx":1744
 *         CHKERR( KSPLogHistory(ksp,ksp.norm) )
 *         CHKERR( KSPMonitor(ksp,ksp.iter,ksp.norm) )
 *     if ksp.iter == ksp.max_its:             # <<<<<<<<<<<<<<
 *         if ksp.reason == KSP_CONVERGED_ITERATING:
 *             ksp.reason = KSP_DIVERGED_ITS
 */
  }

  /* "libpetsc4py.pyx":1748
 *             ksp.reason = KSP_DIVERGED_ITS
 *     #
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPPreStep_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1690
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPSolve_Python_default(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     PetscVec B,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.KSPSolve_Python_default", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1750
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPPreStep_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPPreStep_Python(KSP __pyx_v_ksp) {
  PyObject *__pyx_v_preStep = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPPreStep_Python", 0);

  /* "libpetsc4py.pyx":1754
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPPreStep_Python")             # <<<<<<<<<<<<<<
 *     cdef preStep = PyKSP(ksp).preStep
 *     if preStep is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPPreStep_Python"));

  /* "libpetsc4py.pyx":1755
 *     except IERR with gil:
 *     FunctionBegin(b"KSPPreStep_Python")
 *     cdef preStep = PyKSP(ksp).preStep             # <<<<<<<<<<<<<<
 *     if preStep is not None:
 *         preStep(KSP_(ksp))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_preStep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_preStep = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1756
 *     FunctionBegin(b"KSPPreStep_Python")
 *     cdef preStep = PyKSP(ksp).preStep
 *     if preStep is not None:             # <<<<<<<<<<<<<<
 *         preStep(KSP_(ksp))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_preStep != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1757
 *     cdef preStep = PyKSP(ksp).preStep
 *     if preStep is not None:
 *         preStep(KSP_(ksp))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1757, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_preStep);
    __pyx_t_5 = __pyx_v_preStep; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1757, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":1756
 *     FunctionBegin(b"KSPPreStep_Python")
 *     cdef preStep = PyKSP(ksp).preStep
 *     if preStep is not None:             # <<<<<<<<<<<<<<
 *         preStep(KSP_(ksp))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1758
 *     if preStep is not None:
 *         preStep(KSP_(ksp))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPPostStep_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1750
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPPreStep_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.KSPPreStep_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_preStep);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1760
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPPostStep_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPPostStep_Python(KSP __pyx_v_ksp) {
  PyObject *__pyx_v_postStep = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPPostStep_Python", 0);

  /* "libpetsc4py.pyx":1764
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPPostStep_Python")             # <<<<<<<<<<<<<<
 *     cdef postStep = PyKSP(ksp).postStep
 *     if postStep is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPPostStep_Python"));

  /* "libpetsc4py.pyx":1765
 *     except IERR with gil:
 *     FunctionBegin(b"KSPPostStep_Python")
 *     cdef postStep = PyKSP(ksp).postStep             # <<<<<<<<<<<<<<
 *     if postStep is not None:
 *         postStep(KSP_(ksp))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1765, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_postStep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1765, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_postStep = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1766
 *     FunctionBegin(b"KSPPostStep_Python")
 *     cdef postStep = PyKSP(ksp).postStep
 *     if postStep is not None:             # <<<<<<<<<<<<<<
 *         postStep(KSP_(ksp))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_postStep != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1767
 *     cdef postStep = PyKSP(ksp).postStep
 *     if postStep is not None:
 *         postStep(KSP_(ksp))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_postStep);
    __pyx_t_5 = __pyx_v_postStep; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":1766
 *     FunctionBegin(b"KSPPostStep_Python")
 *     cdef postStep = PyKSP(ksp).postStep
 *     if postStep is not None:             # <<<<<<<<<<<<<<
 *         postStep(KSP_(ksp))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1768
 *     if postStep is not None:
 *         postStep(KSP_(ksp))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode KSPStep_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1760
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPPostStep_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.KSPPostStep_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_postStep);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1770
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPStep_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     PetscVec B,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_KSPStep_Python(KSP __pyx_v_ksp, Vec __pyx_v_B, Vec __pyx_v_X) {
  PyObject *__pyx_v_step = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("KSPStep_Python", 0);

  /* "libpetsc4py.pyx":1776
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"KSPStep_Python")             # <<<<<<<<<<<<<<
 *     cdef step = None
 *     if ksp.transpose_solve:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"KSPStep_Python"));

  /* "libpetsc4py.pyx":1777
 *     except IERR with gil:
 *     FunctionBegin(b"KSPStep_Python")
 *     cdef step = None             # <<<<<<<<<<<<<<
 *     if ksp.transpose_solve:
 *         step = PyKSP(ksp).stepTranspose
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_step = Py_None;

  /* "libpetsc4py.pyx":1778
 *     FunctionBegin(b"KSPStep_Python")
 *     cdef step = None
 *     if ksp.transpose_solve:             # <<<<<<<<<<<<<<
 *         step = PyKSP(ksp).stepTranspose
 *         if step is None: return UNSUPPORTED(b"stepTranspose")
 */
  if (__pyx_v_ksp->transpose_solve) {

    /* "libpetsc4py.pyx":1779
 *     cdef step = None
 *     if ksp.transpose_solve:
 *         step = PyKSP(ksp).stepTranspose             # <<<<<<<<<<<<<<
 *         if step is None: return UNSUPPORTED(b"stepTranspose")
 *     else:
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_stepTranspose); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_step, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":1780
 *     if ksp.transpose_solve:
 *         step = PyKSP(ksp).stepTranspose
 *         if step is None: return UNSUPPORTED(b"stepTranspose")             # <<<<<<<<<<<<<<
 *     else:
 *         step = PyKSP(ksp).step
 */
    __pyx_t_3 = (__pyx_v_step == Py_None);
    __pyx_t_4 = (__pyx_t_3 != 0);
    if (__pyx_t_4) {
      __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"stepTranspose"));
      goto __pyx_L0;
    }

    /* "libpetsc4py.pyx":1778
 *     FunctionBegin(b"KSPStep_Python")
 *     cdef step = None
 *     if ksp.transpose_solve:             # <<<<<<<<<<<<<<
 *         step = PyKSP(ksp).stepTranspose
 *         if step is None: return UNSUPPORTED(b"stepTranspose")
 */
    goto __pyx_L3;
  }

  /* "libpetsc4py.pyx":1782
 *         if step is None: return UNSUPPORTED(b"stepTranspose")
 *     else:
 *         step = PyKSP(ksp).step             # <<<<<<<<<<<<<<
 *         if step is None: return UNSUPPORTED(b"step")
 *     step(KSP_(ksp),Vec_(B),Vec_(X))
 */
  /*else*/ {
    __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyKSP(__pyx_v_ksp)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_step); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_step, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "libpetsc4py.pyx":1783
 *     else:
 *         step = PyKSP(ksp).step
 *         if step is None: return UNSUPPORTED(b"step")             # <<<<<<<<<<<<<<
 *     step(KSP_(ksp),Vec_(B),Vec_(X))
 *     return FunctionEnd()
 */
    __pyx_t_4 = (__pyx_v_step == Py_None);
    __pyx_t_3 = (__pyx_t_4 != 0);
    if (__pyx_t_3) {
      __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"step"));
      goto __pyx_L0;
    }
  }
  __pyx_L3:;

  /* "libpetsc4py.pyx":1784
 *         step = PyKSP(ksp).step
 *         if step is None: return UNSUPPORTED(b"step")
 *     step(KSP_(ksp),Vec_(B),Vec_(X))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_KSP_(__pyx_v_ksp)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1784, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_B)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1784, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_X)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1784, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_step);
  __pyx_t_7 = __pyx_v_step; __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  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_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_2, __pyx_t_5, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1784, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __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;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_2, __pyx_t_5, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1784, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __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;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1784, __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_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":1785
 *         if step is None: return UNSUPPORTED(b"step")
 *     step(KSP_(ksp),Vec_(B),Vec_(X))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1770
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode KSPStep_Python(             # <<<<<<<<<<<<<<
 *     PetscKSP ksp,
 *     PetscVec B,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.KSPStep_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_step);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1840
 * @cython.internal
 * cdef class _PySNES(_PyObj): pass
 * cdef inline _PySNES PySNES(PetscSNES snes):             # <<<<<<<<<<<<<<
 *     if snes != NULL and snes.data != NULL:
 *         return <_PySNES>snes.data
 */

static CYTHON_INLINE struct __pyx_obj_11libpetsc4py__PySNES *__pyx_f_11libpetsc4py_PySNES(SNES __pyx_v_snes) {
  struct __pyx_obj_11libpetsc4py__PySNES *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PySNES", 0);

  /* "libpetsc4py.pyx":1841
 * cdef class _PySNES(_PyObj): pass
 * cdef inline _PySNES PySNES(PetscSNES snes):
 *     if snes != NULL and snes.data != NULL:             # <<<<<<<<<<<<<<
 *         return <_PySNES>snes.data
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_snes != NULL) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_snes->data != NULL) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":1842
 * cdef inline _PySNES PySNES(PetscSNES snes):
 *     if snes != NULL and snes.data != NULL:
 *         return <_PySNES>snes.data             # <<<<<<<<<<<<<<
 *     else:
 *         return _PySNES.__new__(_PySNES)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_11libpetsc4py__PySNES *)__pyx_v_snes->data)));
    __pyx_r = ((struct __pyx_obj_11libpetsc4py__PySNES *)__pyx_v_snes->data);
    goto __pyx_L0;

    /* "libpetsc4py.pyx":1841
 * cdef class _PySNES(_PyObj): pass
 * cdef inline _PySNES PySNES(PetscSNES snes):
 *     if snes != NULL and snes.data != NULL:             # <<<<<<<<<<<<<<
 *         return <_PySNES>snes.data
 *     else:
 */
  }

  /* "libpetsc4py.pyx":1844
 *         return <_PySNES>snes.data
 *     else:
 *         return _PySNES.__new__(_PySNES)             # <<<<<<<<<<<<<<
 * 
 * cdef public PetscErrorCode SNESPythonGetContext(PetscSNES snes, void **ctx) \
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_3 = ((PyObject *)__pyx_tp_new_11libpetsc4py__PySNES(((PyTypeObject *)__pyx_ptype_11libpetsc4py__PySNES), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1844, __pyx_L1_error)
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_r = ((struct __pyx_obj_11libpetsc4py__PySNES *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1840
 * @cython.internal
 * cdef class _PySNES(_PyObj): pass
 * cdef inline _PySNES PySNES(PetscSNES snes):             # <<<<<<<<<<<<<<
 *     if snes != NULL and snes.data != NULL:
 *         return <_PySNES>snes.data
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libpetsc4py.PySNES", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":1846
 *         return _PySNES.__new__(_PySNES)
 * 
 * cdef public PetscErrorCode SNESPythonGetContext(PetscSNES snes, void **ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"SNESPythonGetContext ")
 */

PetscErrorCode SNESPythonGetContext(SNES __pyx_v_snes, void **__pyx_v_ctx) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("SNESPythonGetContext", 0);

  /* "libpetsc4py.pyx":1848
 * cdef public PetscErrorCode SNESPythonGetContext(PetscSNES snes, void **ctx) \
 *     except IERR:
 *     FunctionBegin(b"SNESPythonGetContext ")             # <<<<<<<<<<<<<<
 *     PySNES(snes).getcontext(ctx)
 *     return FunctionEnd()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESPythonGetContext "));

  /* "libpetsc4py.pyx":1849
 *     except IERR:
 *     FunctionBegin(b"SNESPythonGetContext ")
 *     PySNES(snes).getcontext(ctx)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_11libpetsc4py__PySNES *)((struct __pyx_obj_11libpetsc4py__PySNES *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.getcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_ctx); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1849, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":1850
 *     FunctionBegin(b"SNESPythonGetContext ")
 *     PySNES(snes).getcontext(ctx)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef public PetscErrorCode SNESPythonSetContext(PetscSNES snes, void *ctx) \
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1846
 *         return _PySNES.__new__(_PySNES)
 * 
 * cdef public PetscErrorCode SNESPythonGetContext(PetscSNES snes, void **ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"SNESPythonGetContext ")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.SNESPythonGetContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":1852
 *     return FunctionEnd()
 * 
 * cdef public PetscErrorCode SNESPythonSetContext(PetscSNES snes, void *ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"SNESPythonSetContext ")
 */

PetscErrorCode SNESPythonSetContext(SNES __pyx_v_snes, void *__pyx_v_ctx) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("SNESPythonSetContext", 0);

  /* "libpetsc4py.pyx":1854
 * cdef public PetscErrorCode SNESPythonSetContext(PetscSNES snes, void *ctx) \
 *     except IERR:
 *     FunctionBegin(b"SNESPythonSetContext ")             # <<<<<<<<<<<<<<
 *     PySNES(snes).setcontext(ctx, SNES_(snes))
 *     return FunctionEnd()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESPythonSetContext "));

  /* "libpetsc4py.pyx":1855
 *     except IERR:
 *     FunctionBegin(b"SNESPythonSetContext ")
 *     PySNES(snes).setcontext(ctx, SNES_(snes))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_SNES_(__pyx_v_snes)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((struct __pyx_vtabstruct_11libpetsc4py__PySNES *)((struct __pyx_obj_11libpetsc4py__PySNES *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.setcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_ctx, ((struct PyPetscObjectObject *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1855, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1856
 *     FunctionBegin(b"SNESPythonSetContext ")
 *     PySNES(snes).setcontext(ctx, SNES_(snes))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESPythonSetType_PYTHON(PetscSNES snes, char name[]) \
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1852
 *     return FunctionEnd()
 * 
 * cdef public PetscErrorCode SNESPythonSetContext(PetscSNES snes, void *ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"SNESPythonSetContext ")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.SNESPythonSetContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":1858
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESPythonSetType_PYTHON(PetscSNES snes, char name[]) \             # <<<<<<<<<<<<<<
 *     except IERR with gil:
 *     FunctionBegin(b"SNESPythonSetType_PYTHON")
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESPythonSetType_PYTHON(SNES __pyx_v_snes, char *__pyx_v_name) {
  PyObject *__pyx_v_ctx = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PetscErrorCode __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESPythonSetType_PYTHON", 0);

  /* "libpetsc4py.pyx":1860
 * cdef PetscErrorCode SNESPythonSetType_PYTHON(PetscSNES snes, char name[]) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESPythonSetType_PYTHON")             # <<<<<<<<<<<<<<
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESPythonSetType_PYTHON"));

  /* "libpetsc4py.pyx":1861
 *     except IERR with gil:
 *     FunctionBegin(b"SNESPythonSetType_PYTHON")
 *     if name == NULL: return FunctionEnd() # XXX             # <<<<<<<<<<<<<<
 *     cdef object ctx = createcontext(name)
 *     SNESPythonSetContext(snes, <void*>ctx)
 */
  __pyx_t_1 = ((__pyx_v_name == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1862
 *     FunctionBegin(b"SNESPythonSetType_PYTHON")
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)             # <<<<<<<<<<<<<<
 *     SNESPythonSetContext(snes, <void*>ctx)
 *     PySNES(snes).setname(name)
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_createcontext(__pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1862, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_ctx = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1863
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)
 *     SNESPythonSetContext(snes, <void*>ctx)             # <<<<<<<<<<<<<<
 *     PySNES(snes).setname(name)
 *     return FunctionEnd()
 */
  __pyx_t_3 = SNESPythonSetContext(__pyx_v_snes, ((void *)__pyx_v_ctx)); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1863, __pyx_L1_error)

  /* "libpetsc4py.pyx":1864
 *     cdef object ctx = createcontext(name)
 *     SNESPythonSetContext(snes, <void*>ctx)
 *     PySNES(snes).setname(name)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = ((struct __pyx_vtabstruct_11libpetsc4py__PySNES *)((struct __pyx_obj_11libpetsc4py__PySNES *)__pyx_t_2)->__pyx_base.__pyx_vtab)->__pyx_base.setname(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_2), __pyx_v_name); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1864, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":1865
 *     SNESPythonSetContext(snes, <void*>ctx)
 *     PySNES(snes).setname(name)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESCreate_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1858
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESPythonSetType_PYTHON(PetscSNES snes, char name[]) \             # <<<<<<<<<<<<<<
 *     except IERR with gil:
 *     FunctionBegin(b"SNESPythonSetType_PYTHON")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.SNESPythonSetType_PYTHON", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ctx);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1867
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESCreate_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESCreate_Python(SNES __pyx_v_snes) {
  SNESOps __pyx_v_ops;
  SNESLineSearch __pyx_v_ls;
  PyObject *__pyx_v_ctx = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  SNESOps __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESCreate_Python", 0);

  /* "libpetsc4py.pyx":1871
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESCreate_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef SNESOps ops   = snes.ops
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESCreate_Python"));

  /* "libpetsc4py.pyx":1873
 *     FunctionBegin(b"SNESCreate_Python")
 *     #
 *     cdef SNESOps ops   = snes.ops             # <<<<<<<<<<<<<<
 *     cdef PetscSNESLineSearch ls = NULL
 *     ops.reset          = SNESReset_Python
 */
  __pyx_t_1 = __pyx_v_snes->ops;
  __pyx_v_ops = __pyx_t_1;

  /* "libpetsc4py.pyx":1874
 *     #
 *     cdef SNESOps ops   = snes.ops
 *     cdef PetscSNESLineSearch ls = NULL             # <<<<<<<<<<<<<<
 *     ops.reset          = SNESReset_Python
 *     ops.destroy        = SNESDestroy_Python
 */
  __pyx_v_ls = NULL;

  /* "libpetsc4py.pyx":1875
 *     cdef SNESOps ops   = snes.ops
 *     cdef PetscSNESLineSearch ls = NULL
 *     ops.reset          = SNESReset_Python             # <<<<<<<<<<<<<<
 *     ops.destroy        = SNESDestroy_Python
 *     ops.setup          = SNESSetUp_Python
 */
  __pyx_v_ops->reset = __pyx_f_11libpetsc4py_SNESReset_Python;

  /* "libpetsc4py.pyx":1876
 *     cdef PetscSNESLineSearch ls = NULL
 *     ops.reset          = SNESReset_Python
 *     ops.destroy        = SNESDestroy_Python             # <<<<<<<<<<<<<<
 *     ops.setup          = SNESSetUp_Python
 *     ops.setfromoptions = SNESSetFromOptions_Python
 */
  __pyx_v_ops->destroy = __pyx_f_11libpetsc4py_SNESDestroy_Python;

  /* "libpetsc4py.pyx":1877
 *     ops.reset          = SNESReset_Python
 *     ops.destroy        = SNESDestroy_Python
 *     ops.setup          = SNESSetUp_Python             # <<<<<<<<<<<<<<
 *     ops.setfromoptions = SNESSetFromOptions_Python
 *     ops.view           = SNESView_Python
 */
  __pyx_v_ops->setup = __pyx_f_11libpetsc4py_SNESSetUp_Python;

  /* "libpetsc4py.pyx":1878
 *     ops.destroy        = SNESDestroy_Python
 *     ops.setup          = SNESSetUp_Python
 *     ops.setfromoptions = SNESSetFromOptions_Python             # <<<<<<<<<<<<<<
 *     ops.view           = SNESView_Python
 *     ops.solve          = SNESSolve_Python
 */
  __pyx_v_ops->setfromoptions = __pyx_f_11libpetsc4py_SNESSetFromOptions_Python;

  /* "libpetsc4py.pyx":1879
 *     ops.setup          = SNESSetUp_Python
 *     ops.setfromoptions = SNESSetFromOptions_Python
 *     ops.view           = SNESView_Python             # <<<<<<<<<<<<<<
 *     ops.solve          = SNESSolve_Python
 *     #
 */
  __pyx_v_ops->view = __pyx_f_11libpetsc4py_SNESView_Python;

  /* "libpetsc4py.pyx":1880
 *     ops.setfromoptions = SNESSetFromOptions_Python
 *     ops.view           = SNESView_Python
 *     ops.solve          = SNESSolve_Python             # <<<<<<<<<<<<<<
 *     #
 *     CHKERR( PetscObjectComposeFunction(
 */
  __pyx_v_ops->solve = __pyx_f_11libpetsc4py_SNESSolve_Python;

  /* "libpetsc4py.pyx":1882
 *     ops.solve          = SNESSolve_Python
 *     #
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>snes, b"SNESPythonSetType_C",
 *             <PetscVoidFunction>SNESPythonSetType_PYTHON) )
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_snes), ((char *)"SNESPythonSetType_C"), ((PetscVoidFunction)__pyx_f_11libpetsc4py_SNESPythonSetType_PYTHON))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1882, __pyx_L1_error)

  /* "libpetsc4py.pyx":1886
 *             <PetscVoidFunction>SNESPythonSetType_PYTHON) )
 *     #
 *     cdef ctx = PySNES(NULL)             # <<<<<<<<<<<<<<
 *     snes.data = <void*> ctx
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ctx = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":1887
 *     #
 *     cdef ctx = PySNES(NULL)
 *     snes.data = <void*> ctx             # <<<<<<<<<<<<<<
 * 
 *     # Ensure that the SNES has a linesearch object early enough that
 */
  __pyx_v_snes->data = ((void *)__pyx_v_ctx);

  /* "libpetsc4py.pyx":1891
 *     # Ensure that the SNES has a linesearch object early enough that
 *     # it gets setFromOptions.
 *     CHKERR( SNESGetLineSearch(snes, &ls) )             # <<<<<<<<<<<<<<
 *     Py_INCREF(<PyObject*>snes.data)
 *     return FunctionEnd()
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(SNESGetLineSearch(__pyx_v_snes, (&__pyx_v_ls))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1891, __pyx_L1_error)

  /* "libpetsc4py.pyx":1892
 *     # it gets setFromOptions.
 *     CHKERR( SNESGetLineSearch(snes, &ls) )
 *     Py_INCREF(<PyObject*>snes.data)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_snes->data));

  /* "libpetsc4py.pyx":1893
 *     CHKERR( SNESGetLineSearch(snes, &ls) )
 *     Py_INCREF(<PyObject*>snes.data)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESDestroy_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1867
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESCreate_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libpetsc4py.SNESCreate_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ctx);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1895
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESDestroy_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESDestroy_Python(SNES __pyx_v_snes) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PetscErrorCode __pyx_t_3;
  int __pyx_t_4;
  char const *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESDestroy_Python", 0);

  /* "libpetsc4py.pyx":1899
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESDestroy_Python")             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectComposeFunction(
 *             <PetscObject>snes, b"SNESPythonSetType_C",
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESDestroy_Python"));

  /* "libpetsc4py.pyx":1900
 *     except IERR with gil:
 *     FunctionBegin(b"SNESDestroy_Python")
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>snes, b"SNESPythonSetType_C",
 *             <PetscVoidFunction>NULL) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_snes), ((char *)"SNESPythonSetType_C"), ((PetscVoidFunction)NULL))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1900, __pyx_L1_error)

  /* "libpetsc4py.pyx":1904
 *             <PetscVoidFunction>NULL) )
 *     #
 *     if not Py_IsInitialized(): return FunctionEnd()             # <<<<<<<<<<<<<<
 *     try:
 *         addRef(snes)
 */
  __pyx_t_2 = ((!(Py_IsInitialized() != 0)) != 0);
  if (__pyx_t_2) {
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1905
 *     #
 *     if not Py_IsInitialized(): return FunctionEnd()
 *     try:             # <<<<<<<<<<<<<<
 *         addRef(snes)
 *         SNESPythonSetContext(snes, NULL)
 */
  /*try:*/ {

    /* "libpetsc4py.pyx":1906
 *     if not Py_IsInitialized(): return FunctionEnd()
 *     try:
 *         addRef(snes)             # <<<<<<<<<<<<<<
 *         SNESPythonSetContext(snes, NULL)
 *     finally:
 */
    __pyx_f_11libpetsc4py_addRef(__pyx_v_snes);

    /* "libpetsc4py.pyx":1907
 *     try:
 *         addRef(snes)
 *         SNESPythonSetContext(snes, NULL)             # <<<<<<<<<<<<<<
 *     finally:
 *         delRef(snes)
 */
    __pyx_t_3 = SNESPythonSetContext(__pyx_v_snes, NULL); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1907, __pyx_L5_error)
  }

  /* "libpetsc4py.pyx":1909
 *         SNESPythonSetContext(snes, NULL)
 *     finally:
 *         delRef(snes)             # <<<<<<<<<<<<<<
 *         Py_DECREF(<PyObject*>snes.data)
 *         snes.data = NULL
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_f_11libpetsc4py_delRef(__pyx_v_snes);

      /* "libpetsc4py.pyx":1910
 *     finally:
 *         delRef(snes)
 *         Py_DECREF(<PyObject*>snes.data)             # <<<<<<<<<<<<<<
 *         snes.data = NULL
 *     return FunctionEnd()
 */
      Py_DECREF(((PyObject *)__pyx_v_snes->data));

      /* "libpetsc4py.pyx":1911
 *         delRef(snes)
 *         Py_DECREF(<PyObject*>snes.data)
 *         snes.data = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
      __pyx_v_snes->data = NULL;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __pyx_t_1 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename;
      {

        /* "libpetsc4py.pyx":1909
 *         SNESPythonSetContext(snes, NULL)
 *     finally:
 *         delRef(snes)             # <<<<<<<<<<<<<<
 *         Py_DECREF(<PyObject*>snes.data)
 *         snes.data = NULL
 */
        __pyx_f_11libpetsc4py_delRef(__pyx_v_snes);

        /* "libpetsc4py.pyx":1910
 *     finally:
 *         delRef(snes)
 *         Py_DECREF(<PyObject*>snes.data)             # <<<<<<<<<<<<<<
 *         snes.data = NULL
 *     return FunctionEnd()
 */
        Py_DECREF(((PyObject *)__pyx_v_snes->data));

        /* "libpetsc4py.pyx":1911
 *         delRef(snes)
 *         Py_DECREF(<PyObject*>snes.data)
 *         snes.data = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
        __pyx_v_snes->data = NULL;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      __pyx_lineno = __pyx_t_1; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "libpetsc4py.pyx":1912
 *         Py_DECREF(<PyObject*>snes.data)
 *         snes.data = NULL
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESSetUp_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1895
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESDestroy_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.SNESDestroy_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1914
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESSetUp_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESSetUp_Python(SNES __pyx_v_snes) {
  char __pyx_v_name[0x800];
  PetscBool __pyx_v_found;
  PyObject *__pyx_v_setUp = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PetscErrorCode __pyx_t_5;
  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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESSetUp_Python", 0);

  /* "libpetsc4py.pyx":1918
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESSetUp_Python")             # <<<<<<<<<<<<<<
 *     #
 *     #SNESGetKSP(snes,&snes.ksp)
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESSetUp_Python"));

  /* "libpetsc4py.pyx":1923
 *     #
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE             # <<<<<<<<<<<<<<
 *     if PySNES(snes).self is None:
 *         CHKERR( PetscOptionsGetString(NULL,
 */
  __pyx_v_found = PETSC_FALSE;

  /* "libpetsc4py.pyx":1924
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE
 *     if PySNES(snes).self is None:             # <<<<<<<<<<<<<<
 *         CHKERR( PetscOptionsGetString(NULL,
 *                 getPrefix(snes),b"-snes_python_type",
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (((struct __pyx_obj_11libpetsc4py__PySNES *)__pyx_t_1)->__pyx_base.self == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":1925
 *     cdef PetscBool found = PETSC_FALSE
 *     if PySNES(snes).self is None:
 *         CHKERR( PetscOptionsGetString(NULL,             # <<<<<<<<<<<<<<
 *                 getPrefix(snes),b"-snes_python_type",
 *                 name,sizeof(name),&found) )
 */
    __pyx_t_4 = __pyx_f_11libpetsc4py_CHKERR(PetscOptionsGetString(NULL, __pyx_f_11libpetsc4py_getPrefix(__pyx_v_snes), ((char *)"-snes_python_type"), __pyx_v_name, (sizeof(__pyx_v_name)), (&__pyx_v_found))); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1925, __pyx_L1_error)

    /* "libpetsc4py.pyx":1928
 *                 getPrefix(snes),b"-snes_python_type",
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:             # <<<<<<<<<<<<<<
 *             CHKERR( SNESPythonSetType_PYTHON(snes,name) )
 *     if PySNES(snes).self is None:
 */
    if (__pyx_v_found) {
    } else {
      __pyx_t_3 = __pyx_v_found;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_name[0]) != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_3) {

      /* "libpetsc4py.pyx":1929
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:
 *             CHKERR( SNESPythonSetType_PYTHON(snes,name) )             # <<<<<<<<<<<<<<
 *     if PySNES(snes).self is None:
 *         return PetscSETERR(PETSC_ERR_USER,
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_SNESPythonSetType_PYTHON(__pyx_v_snes, __pyx_v_name); if (unlikely(__pyx_t_5 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1929, __pyx_L1_error)
      __pyx_t_4 = __pyx_f_11libpetsc4py_CHKERR(__pyx_t_5); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1929, __pyx_L1_error)

      /* "libpetsc4py.pyx":1928
 *                 getPrefix(snes),b"-snes_python_type",
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:             # <<<<<<<<<<<<<<
 *             CHKERR( SNESPythonSetType_PYTHON(snes,name) )
 *     if PySNES(snes).self is None:
 */
    }

    /* "libpetsc4py.pyx":1924
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE
 *     if PySNES(snes).self is None:             # <<<<<<<<<<<<<<
 *         CHKERR( PetscOptionsGetString(NULL,
 *                 getPrefix(snes),b"-snes_python_type",
 */
  }

  /* "libpetsc4py.pyx":1930
 *         if found and name[0]:
 *             CHKERR( SNESPythonSetType_PYTHON(snes,name) )
 *     if PySNES(snes).self is None:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER,
 *             "Python context not set, call one of \n"
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = (((struct __pyx_obj_11libpetsc4py__PySNES *)__pyx_t_1)->__pyx_base.self == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "libpetsc4py.pyx":1931
 *             CHKERR( SNESPythonSetType_PYTHON(snes,name) )
 *     if PySNES(snes).self is None:
 *         return PetscSETERR(PETSC_ERR_USER,             # <<<<<<<<<<<<<<
 *             "Python context not set, call one of \n"
 *             " * SNESPythonSetType(snes,\"[package.]module.class\")\n"
 */
    __pyx_r = __pyx_f_11libpetsc4py_PetscSETERR(PETSC_ERR_USER, ((char *)"Python context not set, call one of \n * SNESPythonSetType(snes,\"[package.]module.class\")\n * SNESSetFromOptions(snes) and pass option -snes_python_type [package.]module.class"));
    goto __pyx_L0;

    /* "libpetsc4py.pyx":1930
 *         if found and name[0]:
 *             CHKERR( SNESPythonSetType_PYTHON(snes,name) )
 *     if PySNES(snes).self is None:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER,
 *             "Python context not set, call one of \n"
 */
  }

  /* "libpetsc4py.pyx":1937
 *             "-snes_python_type [package.]module.class")
 *     #
 *     cdef setUp = PySNES(snes).setUp             # <<<<<<<<<<<<<<
 *     if setUp is not None:
 *         setUp(SNES_(snes))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_setUp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_setUp = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "libpetsc4py.pyx":1938
 *     #
 *     cdef setUp = PySNES(snes).setUp
 *     if setUp is not None:             # <<<<<<<<<<<<<<
 *         setUp(SNES_(snes))
 *     return FunctionEnd()
 */
  __pyx_t_2 = (__pyx_v_setUp != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":1939
 *     cdef setUp = PySNES(snes).setUp
 *     if setUp is not None:
 *         setUp(SNES_(snes))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_SNES_(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1939, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_setUp);
    __pyx_t_7 = __pyx_v_setUp; __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_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1939, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "libpetsc4py.pyx":1938
 *     #
 *     cdef setUp = PySNES(snes).setUp
 *     if setUp is not None:             # <<<<<<<<<<<<<<
 *         setUp(SNES_(snes))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1940
 *     if setUp is not None:
 *         setUp(SNES_(snes))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESReset_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1914
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESSetUp_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

  /* 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_AddTraceback("libpetsc4py.SNESSetUp_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setUp);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1942
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESReset_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESReset_Python(SNES __pyx_v_snes) {
  PyObject *__pyx_v_reset = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESReset_Python", 0);

  /* "libpetsc4py.pyx":1946
 *     ) \
 *     except IERR with gil:
 *     if getRef(snes) == 0: return 0             # <<<<<<<<<<<<<<
 *     FunctionBegin(b"SNESReset_Python")
 *     cdef reset = PySNES(snes).reset
 */
  __pyx_t_1 = ((__pyx_f_11libpetsc4py_getRef(__pyx_v_snes) == 0) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":1947
 *     except IERR with gil:
 *     if getRef(snes) == 0: return 0
 *     FunctionBegin(b"SNESReset_Python")             # <<<<<<<<<<<<<<
 *     cdef reset = PySNES(snes).reset
 *     if reset is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESReset_Python"));

  /* "libpetsc4py.pyx":1948
 *     if getRef(snes) == 0: return 0
 *     FunctionBegin(b"SNESReset_Python")
 *     cdef reset = PySNES(snes).reset             # <<<<<<<<<<<<<<
 *     if reset is not None:
 *         reset(SNES_(snes))
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1948, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_reset); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1948, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_reset = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":1949
 *     FunctionBegin(b"SNESReset_Python")
 *     cdef reset = PySNES(snes).reset
 *     if reset is not None:             # <<<<<<<<<<<<<<
 *         reset(SNES_(snes))
 *     return FunctionEnd()
 */
  __pyx_t_1 = (__pyx_v_reset != Py_None);
  __pyx_t_4 = (__pyx_t_1 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1950
 *     cdef reset = PySNES(snes).reset
 *     if reset is not None:
 *         reset(SNES_(snes))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_SNES_(__pyx_v_snes)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1950, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_reset);
    __pyx_t_5 = __pyx_v_reset; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1950, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libpetsc4py.pyx":1949
 *     FunctionBegin(b"SNESReset_Python")
 *     cdef reset = PySNES(snes).reset
 *     if reset is not None:             # <<<<<<<<<<<<<<
 *         reset(SNES_(snes))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1951
 *     if reset is not None:
 *         reset(SNES_(snes))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESSetFromOptions_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1942
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESReset_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.SNESReset_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_reset);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1953
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESSetFromOptions_Python(             # <<<<<<<<<<<<<<
 *     PetscOptionItems *PetscOptionsObject,
 *     PetscSNES snes,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESSetFromOptions_Python(PetscOptionItems *__pyx_v_PetscOptionsObject, SNES __pyx_v_snes) {
  char __pyx_v_name[0x800];
  char *__pyx_v_defval;
  PetscBool __pyx_v_found;
  PetscOptionItems *PetscOptionsObject;
  PyObject *__pyx_v_setFromOptions = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PetscErrorCode __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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESSetFromOptions_Python", 0);

  /* "libpetsc4py.pyx":1958
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESSetFromOptions_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef char name[2048], *defval = PySNES(snes).getname()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESSetFromOptions_Python"));

  /* "libpetsc4py.pyx":1960
 *     FunctionBegin(b"SNESSetFromOptions_Python")
 *     #
 *     cdef char name[2048], *defval = PySNES(snes).getname()             # <<<<<<<<<<<<<<
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_11libpetsc4py__PySNES *)((struct __pyx_obj_11libpetsc4py__PySNES *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.getname(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1)); if (unlikely(__pyx_t_2 == ((char *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 1960, __pyx_L1_error)
  __pyx_v_defval = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":1961
 *     #
 *     cdef char name[2048], *defval = PySNES(snes).getname()
 *     cdef PetscBool found = PETSC_FALSE             # <<<<<<<<<<<<<<
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 *     CHKERR( PetscOptionsString(
 */
  __pyx_v_found = PETSC_FALSE;

  /* "libpetsc4py.pyx":1962
 *     cdef char name[2048], *defval = PySNES(snes).getname()
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject             # <<<<<<<<<<<<<<
 *     CHKERR( PetscOptionsString(
 *             b"-snes_python_type",b"Python [package.]module[.{class|function}]",
 */
  PetscOptionsObject = __pyx_v_PetscOptionsObject;

  /* "libpetsc4py.pyx":1963
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 *     CHKERR( PetscOptionsString(             # <<<<<<<<<<<<<<
 *             b"-snes_python_type",b"Python [package.]module[.{class|function}]",
 *             b"SNESPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 */
  __pyx_t_3 = __pyx_f_11libpetsc4py_CHKERR(PetscOptionsString(((char *)"-snes_python_type"), ((char *)"Python [package.]module[.{class|function}]"), ((char *)"SNESPythonSetType"), __pyx_v_defval, __pyx_v_name, (sizeof(__pyx_v_name)), (&__pyx_v_found))); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1963, __pyx_L1_error)

  /* "libpetsc4py.pyx":1965
 *     CHKERR( PetscOptionsString(
 *             b"-snes_python_type",b"Python [package.]module[.{class|function}]",
 *             b"SNESPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;             # <<<<<<<<<<<<<<
 *     if found and name[0]:
 *         CHKERR( SNESPythonSetType_PYTHON(snes,name) )
 */
  ((void)PetscOptionsObject);

  /* "libpetsc4py.pyx":1966
 *             b"-snes_python_type",b"Python [package.]module[.{class|function}]",
 *             b"SNESPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:             # <<<<<<<<<<<<<<
 *         CHKERR( SNESPythonSetType_PYTHON(snes,name) )
 *     #
 */
  if (__pyx_v_found) {
  } else {
    __pyx_t_4 = __pyx_v_found;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_name[0]) != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":1967
 *             b"SNESPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:
 *         CHKERR( SNESPythonSetType_PYTHON(snes,name) )             # <<<<<<<<<<<<<<
 *     #
 *     cdef setFromOptions = PySNES(snes).setFromOptions
 */
    __pyx_t_6 = __pyx_f_11libpetsc4py_SNESPythonSetType_PYTHON(__pyx_v_snes, __pyx_v_name); if (unlikely(__pyx_t_6 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 1967, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_11libpetsc4py_CHKERR(__pyx_t_6); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1967, __pyx_L1_error)

    /* "libpetsc4py.pyx":1966
 *             b"-snes_python_type",b"Python [package.]module[.{class|function}]",
 *             b"SNESPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:             # <<<<<<<<<<<<<<
 *         CHKERR( SNESPythonSetType_PYTHON(snes,name) )
 *     #
 */
  }

  /* "libpetsc4py.pyx":1969
 *         CHKERR( SNESPythonSetType_PYTHON(snes,name) )
 *     #
 *     cdef setFromOptions = PySNES(snes).setFromOptions             # <<<<<<<<<<<<<<
 *     if setFromOptions is not None:
 *         setFromOptions(SNES_(snes))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_setFromOptions); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_setFromOptions = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "libpetsc4py.pyx":1970
 *     #
 *     cdef setFromOptions = PySNES(snes).setFromOptions
 *     if setFromOptions is not None:             # <<<<<<<<<<<<<<
 *         setFromOptions(SNES_(snes))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_setFromOptions != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":1971
 *     cdef setFromOptions = PySNES(snes).setFromOptions
 *     if setFromOptions is not None:
 *         setFromOptions(SNES_(snes))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_SNES_(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_setFromOptions);
    __pyx_t_8 = __pyx_v_setFromOptions; __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_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __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, 1971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "libpetsc4py.pyx":1970
 *     #
 *     cdef setFromOptions = PySNES(snes).setFromOptions
 *     if setFromOptions is not None:             # <<<<<<<<<<<<<<
 *         setFromOptions(SNES_(snes))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1972
 *     if setFromOptions is not None:
 *         setFromOptions(SNES_(snes))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESView_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1953
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESSetFromOptions_Python(             # <<<<<<<<<<<<<<
 *     PetscOptionItems *PetscOptionsObject,
 *     PetscSNES snes,
 */

  /* function exit code */
  __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("libpetsc4py.SNESSetFromOptions_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setFromOptions);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1974
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESView_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES   snes,
 *     PetscViewer vwr,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESView_Python(SNES __pyx_v_snes, PetscViewer __pyx_v_vwr) {
  PyObject *__pyx_v_view = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESView_Python", 0);

  /* "libpetsc4py.pyx":1979
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESView_Python")             # <<<<<<<<<<<<<<
 *     viewcontext(PySNES(snes), vwr)
 *     cdef view = PySNES(snes).view
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESView_Python"));

  /* "libpetsc4py.pyx":1980
 *     except IERR with gil:
 *     FunctionBegin(b"SNESView_Python")
 *     viewcontext(PySNES(snes), vwr)             # <<<<<<<<<<<<<<
 *     cdef view = PySNES(snes).view
 *     if view is not None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1980, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_11libpetsc4py_viewcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_vwr); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1980, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":1981
 *     FunctionBegin(b"SNESView_Python")
 *     viewcontext(PySNES(snes), vwr)
 *     cdef view = PySNES(snes).view             # <<<<<<<<<<<<<<
 *     if view is not None:
 *         view(SNES_(snes), Viewer_(vwr))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1981, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_view); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1981, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_view = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":1982
 *     viewcontext(PySNES(snes), vwr)
 *     cdef view = PySNES(snes).view
 *     if view is not None:             # <<<<<<<<<<<<<<
 *         view(SNES_(snes), Viewer_(vwr))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_view != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":1983
 *     cdef view = PySNES(snes).view
 *     if view is not None:
 *         view(SNES_(snes), Viewer_(vwr))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_SNES_(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1983, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Viewer_(__pyx_v_vwr)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1983, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_view);
    __pyx_t_7 = __pyx_v_view; __pyx_t_8 = NULL;
    __pyx_t_2 = 0;
    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_2 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1983, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1983, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1983, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_2, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_2, __pyx_t_6);
      __pyx_t_1 = 0;
      __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1983, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libpetsc4py.pyx":1982
 *     viewcontext(PySNES(snes), vwr)
 *     cdef view = PySNES(snes).view
 *     if view is not None:             # <<<<<<<<<<<<<<
 *         view(SNES_(snes), Viewer_(vwr))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":1984
 *     if view is not None:
 *         view(SNES_(snes), Viewer_(vwr))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESSolve_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1974
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESView_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES   snes,
 *     PetscViewer vwr,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.SNESView_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_view);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":1986
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESSolve_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESSolve_Python(SNES __pyx_v_snes) {
  Vec __pyx_v_b;
  Vec __pyx_v_x;
  PyObject *__pyx_v_solve = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PetscErrorCode __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESSolve_Python", 0);

  /* "libpetsc4py.pyx":1990
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESSolve_Python")             # <<<<<<<<<<<<<<
 *     cdef PetscVec b = NULL, x = NULL
 *     CHKERR( SNESGetRhs(snes,&b)      )
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESSolve_Python"));

  /* "libpetsc4py.pyx":1991
 *     except IERR with gil:
 *     FunctionBegin(b"SNESSolve_Python")
 *     cdef PetscVec b = NULL, x = NULL             # <<<<<<<<<<<<<<
 *     CHKERR( SNESGetRhs(snes,&b)      )
 *     CHKERR( SNESGetSolution(snes,&x) )
 */
  __pyx_v_b = NULL;
  __pyx_v_x = NULL;

  /* "libpetsc4py.pyx":1992
 *     FunctionBegin(b"SNESSolve_Python")
 *     cdef PetscVec b = NULL, x = NULL
 *     CHKERR( SNESGetRhs(snes,&b)      )             # <<<<<<<<<<<<<<
 *     CHKERR( SNESGetSolution(snes,&x) )
 *     #
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESGetRhs(__pyx_v_snes, (&__pyx_v_b))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1992, __pyx_L1_error)

  /* "libpetsc4py.pyx":1993
 *     cdef PetscVec b = NULL, x = NULL
 *     CHKERR( SNESGetRhs(snes,&b)      )
 *     CHKERR( SNESGetSolution(snes,&x) )             # <<<<<<<<<<<<<<
 *     #
 *     snes.iter = 0
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESGetSolution(__pyx_v_snes, (&__pyx_v_x))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1993, __pyx_L1_error)

  /* "libpetsc4py.pyx":1995
 *     CHKERR( SNESGetSolution(snes,&x) )
 *     #
 *     snes.iter = 0             # <<<<<<<<<<<<<<
 *     snes.reason = SNES_CONVERGED_ITERATING
 *     #
 */
  __pyx_v_snes->iter = 0;

  /* "libpetsc4py.pyx":1996
 *     #
 *     snes.iter = 0
 *     snes.reason = SNES_CONVERGED_ITERATING             # <<<<<<<<<<<<<<
 *     #
 *     cdef solve = PySNES(snes).solve
 */
  __pyx_v_snes->reason = SNES_CONVERGED_ITERATING;

  /* "libpetsc4py.pyx":1998
 *     snes.reason = SNES_CONVERGED_ITERATING
 *     #
 *     cdef solve = PySNES(snes).solve             # <<<<<<<<<<<<<<
 *     if solve is not None:
 *         solve(SNES_(snes), Vec_(b) if b != NULL else None, Vec_(x))
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1998, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_solve); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1998, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_solve = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":1999
 *     #
 *     cdef solve = PySNES(snes).solve
 *     if solve is not None:             # <<<<<<<<<<<<<<
 *         solve(SNES_(snes), Vec_(b) if b != NULL else None, Vec_(x))
 *     else:
 */
  __pyx_t_4 = (__pyx_v_solve != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":2000
 *     cdef solve = PySNES(snes).solve
 *     if solve is not None:
 *         solve(SNES_(snes), Vec_(b) if b != NULL else None, Vec_(x))             # <<<<<<<<<<<<<<
 *     else:
 *         SNESSolve_Python_default(snes)
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_SNES_(__pyx_v_snes)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2000, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (((__pyx_v_b != NULL) != 0)) {
      __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_b)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2000, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __pyx_t_7;
      __pyx_t_7 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_6 = Py_None;
    }
    __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2000, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_solve);
    __pyx_t_8 = __pyx_v_solve; __pyx_t_9 = NULL;
    __pyx_t_1 = 0;
    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 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_2, __pyx_t_6, __pyx_t_7};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_1, 3+__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2000, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_2, __pyx_t_6, __pyx_t_7};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_1, 3+__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2000, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2000, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_1, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_1, __pyx_t_7);
      __pyx_t_2 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2000, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libpetsc4py.pyx":1999
 *     #
 *     cdef solve = PySNES(snes).solve
 *     if solve is not None:             # <<<<<<<<<<<<<<
 *         solve(SNES_(snes), Vec_(b) if b != NULL else None, Vec_(x))
 *     else:
 */
    goto __pyx_L3;
  }

  /* "libpetsc4py.pyx":2002
 *         solve(SNES_(snes), Vec_(b) if b != NULL else None, Vec_(x))
 *     else:
 *         SNESSolve_Python_default(snes)             # <<<<<<<<<<<<<<
 *     #
 *     return FunctionEnd()
 */
  /*else*/ {
    __pyx_t_11 = __pyx_f_11libpetsc4py_SNESSolve_Python_default(__pyx_v_snes); if (unlikely(__pyx_t_11 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2002, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "libpetsc4py.pyx":2004
 *         SNESSolve_Python_default(snes)
 *     #
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESSolve_Python_default(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":1986
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESSolve_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __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_AddTraceback("libpetsc4py.SNESSolve_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_solve);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2006
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESSolve_Python_default(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESSolve_Python_default(SNES __pyx_v_snes) {
  Vec __pyx_v_X;
  Vec __pyx_v_F;
  Vec __pyx_v_Y;
  SNESLineSearch __pyx_v_ls;
  CYTHON_UNUSED PetscInt __pyx_v_its;
  PetscInt __pyx_v_lits;
  PetscReal __pyx_v_xnorm;
  PetscReal __pyx_v_fnorm;
  PetscReal __pyx_v_ynorm;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PetscInt __pyx_t_2;
  PetscErrorCode __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESSolve_Python_default", 0);

  /* "libpetsc4py.pyx":2010
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESSolve_Python_default")             # <<<<<<<<<<<<<<
 *     #
 *     cdef PetscVec X=NULL, F=NULL, Y=NULL
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESSolve_Python_default"));

  /* "libpetsc4py.pyx":2012
 *     FunctionBegin(b"SNESSolve_Python_default")
 *     #
 *     cdef PetscVec X=NULL, F=NULL, Y=NULL             # <<<<<<<<<<<<<<
 *     cdef PetscSNESLineSearch ls
 *     CHKERR( SNESGetSolution(snes,&X)           )
 */
  __pyx_v_X = NULL;
  __pyx_v_F = NULL;
  __pyx_v_Y = NULL;

  /* "libpetsc4py.pyx":2014
 *     cdef PetscVec X=NULL, F=NULL, Y=NULL
 *     cdef PetscSNESLineSearch ls
 *     CHKERR( SNESGetSolution(snes,&X)           )             # <<<<<<<<<<<<<<
 *     CHKERR( SNESGetFunction(snes,&F,NULL,NULL) )
 *     CHKERR( SNESGetSolutionUpdate(snes,&Y)     )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESGetSolution(__pyx_v_snes, (&__pyx_v_X))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2014, __pyx_L1_error)

  /* "libpetsc4py.pyx":2015
 *     cdef PetscSNESLineSearch ls
 *     CHKERR( SNESGetSolution(snes,&X)           )
 *     CHKERR( SNESGetFunction(snes,&F,NULL,NULL) )             # <<<<<<<<<<<<<<
 *     CHKERR( SNESGetSolutionUpdate(snes,&Y)     )
 *     CHKERR( SNESGetLineSearch(snes, &ls)       )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESGetFunction(__pyx_v_snes, (&__pyx_v_F), NULL, NULL)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2015, __pyx_L1_error)

  /* "libpetsc4py.pyx":2016
 *     CHKERR( SNESGetSolution(snes,&X)           )
 *     CHKERR( SNESGetFunction(snes,&F,NULL,NULL) )
 *     CHKERR( SNESGetSolutionUpdate(snes,&Y)     )             # <<<<<<<<<<<<<<
 *     CHKERR( SNESGetLineSearch(snes, &ls)       )
 *     cdef PetscInt  its=0, lits=0
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESGetSolutionUpdate(__pyx_v_snes, (&__pyx_v_Y))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2016, __pyx_L1_error)

  /* "libpetsc4py.pyx":2017
 *     CHKERR( SNESGetFunction(snes,&F,NULL,NULL) )
 *     CHKERR( SNESGetSolutionUpdate(snes,&Y)     )
 *     CHKERR( SNESGetLineSearch(snes, &ls)       )             # <<<<<<<<<<<<<<
 *     cdef PetscInt  its=0, lits=0
 *     cdef PetscReal xnorm = 0.0
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESGetLineSearch(__pyx_v_snes, (&__pyx_v_ls))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2017, __pyx_L1_error)

  /* "libpetsc4py.pyx":2018
 *     CHKERR( SNESGetSolutionUpdate(snes,&Y)     )
 *     CHKERR( SNESGetLineSearch(snes, &ls)       )
 *     cdef PetscInt  its=0, lits=0             # <<<<<<<<<<<<<<
 *     cdef PetscReal xnorm = 0.0
 *     cdef PetscReal fnorm = 0.0
 */
  __pyx_v_its = 0;
  __pyx_v_lits = 0;

  /* "libpetsc4py.pyx":2019
 *     CHKERR( SNESGetLineSearch(snes, &ls)       )
 *     cdef PetscInt  its=0, lits=0
 *     cdef PetscReal xnorm = 0.0             # <<<<<<<<<<<<<<
 *     cdef PetscReal fnorm = 0.0
 *     cdef PetscReal ynorm = 0.0
 */
  __pyx_v_xnorm = 0.0;

  /* "libpetsc4py.pyx":2020
 *     cdef PetscInt  its=0, lits=0
 *     cdef PetscReal xnorm = 0.0
 *     cdef PetscReal fnorm = 0.0             # <<<<<<<<<<<<<<
 *     cdef PetscReal ynorm = 0.0
 *     #
 */
  __pyx_v_fnorm = 0.0;

  /* "libpetsc4py.pyx":2021
 *     cdef PetscReal xnorm = 0.0
 *     cdef PetscReal fnorm = 0.0
 *     cdef PetscReal ynorm = 0.0             # <<<<<<<<<<<<<<
 *     #
 *     CHKERR( VecSet(Y,0.0)                 )
 */
  __pyx_v_ynorm = 0.0;

  /* "libpetsc4py.pyx":2023
 *     cdef PetscReal ynorm = 0.0
 *     #
 *     CHKERR( VecSet(Y,0.0)                 )             # <<<<<<<<<<<<<<
 *     CHKERR( SNESComputeFunction(snes,X,F) )
 *     CHKERR( VecNorm(X,NORM_2,&xnorm)      )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecSet(__pyx_v_Y, 0.0)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2023, __pyx_L1_error)

  /* "libpetsc4py.pyx":2024
 *     #
 *     CHKERR( VecSet(Y,0.0)                 )
 *     CHKERR( SNESComputeFunction(snes,X,F) )             # <<<<<<<<<<<<<<
 *     CHKERR( VecNorm(X,NORM_2,&xnorm)      )
 *     CHKERR( VecNorm(F,NORM_2,&fnorm)      )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESComputeFunction(__pyx_v_snes, __pyx_v_X, __pyx_v_F)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2024, __pyx_L1_error)

  /* "libpetsc4py.pyx":2025
 *     CHKERR( VecSet(Y,0.0)                 )
 *     CHKERR( SNESComputeFunction(snes,X,F) )
 *     CHKERR( VecNorm(X,NORM_2,&xnorm)      )             # <<<<<<<<<<<<<<
 *     CHKERR( VecNorm(F,NORM_2,&fnorm)      )
 *     #
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecNorm(__pyx_v_X, NORM_2, (&__pyx_v_xnorm))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2025, __pyx_L1_error)

  /* "libpetsc4py.pyx":2026
 *     CHKERR( SNESComputeFunction(snes,X,F) )
 *     CHKERR( VecNorm(X,NORM_2,&xnorm)      )
 *     CHKERR( VecNorm(F,NORM_2,&fnorm)      )             # <<<<<<<<<<<<<<
 *     #
 *     CHKERR( SNESConverged(snes,snes.iter,xnorm,ynorm,fnorm,&snes.reason) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecNorm(__pyx_v_F, NORM_2, (&__pyx_v_fnorm))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2026, __pyx_L1_error)

  /* "libpetsc4py.pyx":2028
 *     CHKERR( VecNorm(F,NORM_2,&fnorm)      )
 *     #
 *     CHKERR( SNESConverged(snes,snes.iter,xnorm,ynorm,fnorm,&snes.reason) )             # <<<<<<<<<<<<<<
 *     CHKERR( SNESLogHistory(snes,snes.norm,lits) )
 *     CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESConverged(__pyx_v_snes, __pyx_v_snes->iter, __pyx_v_xnorm, __pyx_v_ynorm, __pyx_v_fnorm, (&__pyx_v_snes->reason))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2028, __pyx_L1_error)

  /* "libpetsc4py.pyx":2029
 *     #
 *     CHKERR( SNESConverged(snes,snes.iter,xnorm,ynorm,fnorm,&snes.reason) )
 *     CHKERR( SNESLogHistory(snes,snes.norm,lits) )             # <<<<<<<<<<<<<<
 *     CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )
 *     for its from 0 <= its < snes.max_its:
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESLogHistory(__pyx_v_snes, __pyx_v_snes->norm, __pyx_v_lits)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2029, __pyx_L1_error)

  /* "libpetsc4py.pyx":2030
 *     CHKERR( SNESConverged(snes,snes.iter,xnorm,ynorm,fnorm,&snes.reason) )
 *     CHKERR( SNESLogHistory(snes,snes.norm,lits) )
 *     CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )             # <<<<<<<<<<<<<<
 *     for its from 0 <= its < snes.max_its:
 *         if snes.reason: break
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESMonitor(__pyx_v_snes, __pyx_v_snes->iter, __pyx_v_snes->norm)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2030, __pyx_L1_error)

  /* "libpetsc4py.pyx":2031
 *     CHKERR( SNESLogHistory(snes,snes.norm,lits) )
 *     CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )
 *     for its from 0 <= its < snes.max_its:             # <<<<<<<<<<<<<<
 *         if snes.reason: break
 *         SNESPreStep_Python(snes)
 */
  __pyx_t_2 = __pyx_v_snes->max_its;
  for (__pyx_v_its = 0; __pyx_v_its < __pyx_t_2; __pyx_v_its++) {

    /* "libpetsc4py.pyx":2032
 *     CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )
 *     for its from 0 <= its < snes.max_its:
 *         if snes.reason: break             # <<<<<<<<<<<<<<
 *         SNESPreStep_Python(snes)
 *         #
 */
    if (__pyx_v_snes->reason) {
      goto __pyx_L4_break;
    }

    /* "libpetsc4py.pyx":2033
 *     for its from 0 <= its < snes.max_its:
 *         if snes.reason: break
 *         SNESPreStep_Python(snes)             # <<<<<<<<<<<<<<
 *         #
 *         lits = -snes.linear_its
 */
    __pyx_t_3 = __pyx_f_11libpetsc4py_SNESPreStep_Python(__pyx_v_snes); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2033, __pyx_L1_error)

    /* "libpetsc4py.pyx":2035
 *         SNESPreStep_Python(snes)
 *         #
 *         lits = -snes.linear_its             # <<<<<<<<<<<<<<
 *         SNESStep_Python(snes,X,F,Y)
 *         lits += snes.linear_its
 */
    __pyx_v_lits = (-__pyx_v_snes->linear_its);

    /* "libpetsc4py.pyx":2036
 *         #
 *         lits = -snes.linear_its
 *         SNESStep_Python(snes,X,F,Y)             # <<<<<<<<<<<<<<
 *         lits += snes.linear_its
 *         #
 */
    __pyx_t_3 = __pyx_f_11libpetsc4py_SNESStep_Python(__pyx_v_snes, __pyx_v_X, __pyx_v_F, __pyx_v_Y); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2036, __pyx_L1_error)

    /* "libpetsc4py.pyx":2037
 *         lits = -snes.linear_its
 *         SNESStep_Python(snes,X,F,Y)
 *         lits += snes.linear_its             # <<<<<<<<<<<<<<
 *         #
 *         CHKERR( SNESLineSearchApply(ls,X,F,&fnorm,Y) )
 */
    __pyx_v_lits = (__pyx_v_lits + __pyx_v_snes->linear_its);

    /* "libpetsc4py.pyx":2039
 *         lits += snes.linear_its
 *         #
 *         CHKERR( SNESLineSearchApply(ls,X,F,&fnorm,Y) )             # <<<<<<<<<<<<<<
 *         CHKERR( VecNorm(X,NORM_2,&xnorm)      )
 *         CHKERR( VecNorm(Y,NORM_2,&ynorm)      )
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESLineSearchApply(__pyx_v_ls, __pyx_v_X, __pyx_v_F, (&__pyx_v_fnorm), __pyx_v_Y)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2039, __pyx_L1_error)

    /* "libpetsc4py.pyx":2040
 *         #
 *         CHKERR( SNESLineSearchApply(ls,X,F,&fnorm,Y) )
 *         CHKERR( VecNorm(X,NORM_2,&xnorm)      )             # <<<<<<<<<<<<<<
 *         CHKERR( VecNorm(Y,NORM_2,&ynorm)      )
 *         snes.iter += 1
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecNorm(__pyx_v_X, NORM_2, (&__pyx_v_xnorm))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2040, __pyx_L1_error)

    /* "libpetsc4py.pyx":2041
 *         CHKERR( SNESLineSearchApply(ls,X,F,&fnorm,Y) )
 *         CHKERR( VecNorm(X,NORM_2,&xnorm)      )
 *         CHKERR( VecNorm(Y,NORM_2,&ynorm)      )             # <<<<<<<<<<<<<<
 *         snes.iter += 1
 *         #
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecNorm(__pyx_v_Y, NORM_2, (&__pyx_v_ynorm))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2041, __pyx_L1_error)

    /* "libpetsc4py.pyx":2042
 *         CHKERR( VecNorm(X,NORM_2,&xnorm)      )
 *         CHKERR( VecNorm(Y,NORM_2,&ynorm)      )
 *         snes.iter += 1             # <<<<<<<<<<<<<<
 *         #
 *         SNESPostStep_Python(snes)
 */
    __pyx_v_snes->iter = (__pyx_v_snes->iter + 1);

    /* "libpetsc4py.pyx":2044
 *         snes.iter += 1
 *         #
 *         SNESPostStep_Python(snes)             # <<<<<<<<<<<<<<
 *         CHKERR( SNESConverged(snes,snes.iter,xnorm,ynorm,fnorm,&snes.reason) )
 *         CHKERR( SNESLogHistory(snes,snes.norm,lits) )
 */
    __pyx_t_3 = __pyx_f_11libpetsc4py_SNESPostStep_Python(__pyx_v_snes); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2044, __pyx_L1_error)

    /* "libpetsc4py.pyx":2045
 *         #
 *         SNESPostStep_Python(snes)
 *         CHKERR( SNESConverged(snes,snes.iter,xnorm,ynorm,fnorm,&snes.reason) )             # <<<<<<<<<<<<<<
 *         CHKERR( SNESLogHistory(snes,snes.norm,lits) )
 *         CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESConverged(__pyx_v_snes, __pyx_v_snes->iter, __pyx_v_xnorm, __pyx_v_ynorm, __pyx_v_fnorm, (&__pyx_v_snes->reason))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2045, __pyx_L1_error)

    /* "libpetsc4py.pyx":2046
 *         SNESPostStep_Python(snes)
 *         CHKERR( SNESConverged(snes,snes.iter,xnorm,ynorm,fnorm,&snes.reason) )
 *         CHKERR( SNESLogHistory(snes,snes.norm,lits) )             # <<<<<<<<<<<<<<
 *         CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )
 *     if snes.iter == snes.max_its:
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESLogHistory(__pyx_v_snes, __pyx_v_snes->norm, __pyx_v_lits)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2046, __pyx_L1_error)

    /* "libpetsc4py.pyx":2047
 *         CHKERR( SNESConverged(snes,snes.iter,xnorm,ynorm,fnorm,&snes.reason) )
 *         CHKERR( SNESLogHistory(snes,snes.norm,lits) )
 *         CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )             # <<<<<<<<<<<<<<
 *     if snes.iter == snes.max_its:
 *         if snes.reason == SNES_CONVERGED_ITERATING:
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESMonitor(__pyx_v_snes, __pyx_v_snes->iter, __pyx_v_snes->norm)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2047, __pyx_L1_error)
  }
  __pyx_L4_break:;

  /* "libpetsc4py.pyx":2048
 *         CHKERR( SNESLogHistory(snes,snes.norm,lits) )
 *         CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )
 *     if snes.iter == snes.max_its:             # <<<<<<<<<<<<<<
 *         if snes.reason == SNES_CONVERGED_ITERATING:
 *             snes.reason = SNES_DIVERGED_MAX_IT
 */
  __pyx_t_4 = ((__pyx_v_snes->iter == __pyx_v_snes->max_its) != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2049
 *         CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )
 *     if snes.iter == snes.max_its:
 *         if snes.reason == SNES_CONVERGED_ITERATING:             # <<<<<<<<<<<<<<
 *             snes.reason = SNES_DIVERGED_MAX_IT
 *     #
 */
    __pyx_t_4 = ((__pyx_v_snes->reason == SNES_CONVERGED_ITERATING) != 0);
    if (__pyx_t_4) {

      /* "libpetsc4py.pyx":2050
 *     if snes.iter == snes.max_its:
 *         if snes.reason == SNES_CONVERGED_ITERATING:
 *             snes.reason = SNES_DIVERGED_MAX_IT             # <<<<<<<<<<<<<<
 *     #
 *     return FunctionEnd()
 */
      __pyx_v_snes->reason = SNES_DIVERGED_MAX_IT;

      /* "libpetsc4py.pyx":2049
 *         CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )
 *     if snes.iter == snes.max_its:
 *         if snes.reason == SNES_CONVERGED_ITERATING:             # <<<<<<<<<<<<<<
 *             snes.reason = SNES_DIVERGED_MAX_IT
 *     #
 */
    }

    /* "libpetsc4py.pyx":2048
 *         CHKERR( SNESLogHistory(snes,snes.norm,lits) )
 *         CHKERR( SNESMonitor(snes,snes.iter,snes.norm) )
 *     if snes.iter == snes.max_its:             # <<<<<<<<<<<<<<
 *         if snes.reason == SNES_CONVERGED_ITERATING:
 *             snes.reason = SNES_DIVERGED_MAX_IT
 */
  }

  /* "libpetsc4py.pyx":2052
 *             snes.reason = SNES_DIVERGED_MAX_IT
 *     #
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESPreStep_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2006
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESSolve_Python_default(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.SNESSolve_Python_default", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2054
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESPreStep_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESPreStep_Python(SNES __pyx_v_snes) {
  PyObject *__pyx_v_preStep = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESPreStep_Python", 0);

  /* "libpetsc4py.pyx":2058
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESPreStep_Python")             # <<<<<<<<<<<<<<
 *     cdef preStep = PySNES(snes).preStep
 *     if preStep is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESPreStep_Python"));

  /* "libpetsc4py.pyx":2059
 *     except IERR with gil:
 *     FunctionBegin(b"SNESPreStep_Python")
 *     cdef preStep = PySNES(snes).preStep             # <<<<<<<<<<<<<<
 *     if preStep is not None:
 *         preStep(SNES_(snes))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2059, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_preStep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2059, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_preStep = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2060
 *     FunctionBegin(b"SNESPreStep_Python")
 *     cdef preStep = PySNES(snes).preStep
 *     if preStep is not None:             # <<<<<<<<<<<<<<
 *         preStep(SNES_(snes))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_preStep != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2061
 *     cdef preStep = PySNES(snes).preStep
 *     if preStep is not None:
 *         preStep(SNES_(snes))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_SNES_(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_preStep);
    __pyx_t_5 = __pyx_v_preStep; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":2060
 *     FunctionBegin(b"SNESPreStep_Python")
 *     cdef preStep = PySNES(snes).preStep
 *     if preStep is not None:             # <<<<<<<<<<<<<<
 *         preStep(SNES_(snes))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":2062
 *     if preStep is not None:
 *         preStep(SNES_(snes))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESPostStep_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2054
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESPreStep_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.SNESPreStep_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_preStep);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2064
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESPostStep_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESPostStep_Python(SNES __pyx_v_snes) {
  PyObject *__pyx_v_postStep = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESPostStep_Python", 0);

  /* "libpetsc4py.pyx":2068
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESPostStep_Python")             # <<<<<<<<<<<<<<
 *     cdef postStep = PySNES(snes).postStep
 *     if postStep is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESPostStep_Python"));

  /* "libpetsc4py.pyx":2069
 *     except IERR with gil:
 *     FunctionBegin(b"SNESPostStep_Python")
 *     cdef postStep = PySNES(snes).postStep             # <<<<<<<<<<<<<<
 *     if postStep is not None:
 *         postStep(SNES_(snes))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2069, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_postStep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2069, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_postStep = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2070
 *     FunctionBegin(b"SNESPostStep_Python")
 *     cdef postStep = PySNES(snes).postStep
 *     if postStep is not None:             # <<<<<<<<<<<<<<
 *         postStep(SNES_(snes))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_postStep != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2071
 *     cdef postStep = PySNES(snes).postStep
 *     if postStep is not None:
 *         postStep(SNES_(snes))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_SNES_(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2071, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_postStep);
    __pyx_t_5 = __pyx_v_postStep; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2071, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":2070
 *     FunctionBegin(b"SNESPostStep_Python")
 *     cdef postStep = PySNES(snes).postStep
 *     if postStep is not None:             # <<<<<<<<<<<<<<
 *         postStep(SNES_(snes))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":2072
 *     if postStep is not None:
 *         postStep(SNES_(snes))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESStep_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2064
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESPostStep_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.SNESPostStep_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_postStep);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2074
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESStep_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     PetscVec  X,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESStep_Python(SNES __pyx_v_snes, Vec __pyx_v_X, Vec __pyx_v_F, Vec __pyx_v_Y) {
  PyObject *__pyx_v_step = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PetscErrorCode __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESStep_Python", 0);

  /* "libpetsc4py.pyx":2081
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESStep_Python")             # <<<<<<<<<<<<<<
 *     cdef step = PySNES(snes).step
 *     if step is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESStep_Python"));

  /* "libpetsc4py.pyx":2082
 *     except IERR with gil:
 *     FunctionBegin(b"SNESStep_Python")
 *     cdef step = PySNES(snes).step             # <<<<<<<<<<<<<<
 *     if step is not None:
 *         step(SNES_(snes),Vec_(X),Vec_(F),Vec_(Y))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PySNES(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2082, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_step); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2082, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_step = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2083
 *     FunctionBegin(b"SNESStep_Python")
 *     cdef step = PySNES(snes).step
 *     if step is not None:             # <<<<<<<<<<<<<<
 *         step(SNES_(snes),Vec_(X),Vec_(F),Vec_(Y))
 *     else:
 */
  __pyx_t_3 = (__pyx_v_step != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2084
 *     cdef step = PySNES(snes).step
 *     if step is not None:
 *         step(SNES_(snes),Vec_(X),Vec_(F),Vec_(Y))             # <<<<<<<<<<<<<<
 *     else:
 *         SNESStep_Python_default(snes,X,F,Y)
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_SNES_(__pyx_v_snes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2084, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_X)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2084, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_F)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2084, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_Y)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2084, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_step);
    __pyx_t_8 = __pyx_v_step; __pyx_t_9 = NULL;
    __pyx_t_10 = 0;
    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_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_1, __pyx_t_5, __pyx_t_6, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2084, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_1, __pyx_t_5, __pyx_t_6, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2084, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2084, __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_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_7);
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2084, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":2083
 *     FunctionBegin(b"SNESStep_Python")
 *     cdef step = PySNES(snes).step
 *     if step is not None:             # <<<<<<<<<<<<<<
 *         step(SNES_(snes),Vec_(X),Vec_(F),Vec_(Y))
 *     else:
 */
    goto __pyx_L3;
  }

  /* "libpetsc4py.pyx":2086
 *         step(SNES_(snes),Vec_(X),Vec_(F),Vec_(Y))
 *     else:
 *         SNESStep_Python_default(snes,X,F,Y)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  /*else*/ {
    __pyx_t_12 = __pyx_f_11libpetsc4py_SNESStep_Python_default(__pyx_v_snes, __pyx_v_X, __pyx_v_F, __pyx_v_Y); if (unlikely(__pyx_t_12 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2086, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "libpetsc4py.pyx":2087
 *     else:
 *         SNESStep_Python_default(snes,X,F,Y)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESStep_Python_default(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2074
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESStep_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     PetscVec  X,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("libpetsc4py.SNESStep_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_step);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2089
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESStep_Python_default(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     PetscVec  X,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESStep_Python_default(SNES __pyx_v_snes, Vec __pyx_v_X, Vec __pyx_v_F, Vec __pyx_v_Y) {
  Mat __pyx_v_J;
  Mat __pyx_v_P;
  PetscInt __pyx_v_lits;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESStep_Python_default", 0);

  /* "libpetsc4py.pyx":2096
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"SNESStep_Python_default")             # <<<<<<<<<<<<<<
 *     cdef PetscMat J = NULL, P = NULL
 *     cdef PetscInt lits = 0
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"SNESStep_Python_default"));

  /* "libpetsc4py.pyx":2097
 *     except IERR with gil:
 *     FunctionBegin(b"SNESStep_Python_default")
 *     cdef PetscMat J = NULL, P = NULL             # <<<<<<<<<<<<<<
 *     cdef PetscInt lits = 0
 *     CHKERR( SNESGetJacobian(snes,&J,&P,NULL,NULL)   )
 */
  __pyx_v_J = NULL;
  __pyx_v_P = NULL;

  /* "libpetsc4py.pyx":2098
 *     FunctionBegin(b"SNESStep_Python_default")
 *     cdef PetscMat J = NULL, P = NULL
 *     cdef PetscInt lits = 0             # <<<<<<<<<<<<<<
 *     CHKERR( SNESGetJacobian(snes,&J,&P,NULL,NULL)   )
 *     CHKERR( SNESComputeJacobian(snes,X,J,P)         )
 */
  __pyx_v_lits = 0;

  /* "libpetsc4py.pyx":2099
 *     cdef PetscMat J = NULL, P = NULL
 *     cdef PetscInt lits = 0
 *     CHKERR( SNESGetJacobian(snes,&J,&P,NULL,NULL)   )             # <<<<<<<<<<<<<<
 *     CHKERR( SNESComputeJacobian(snes,X,J,P)         )
 *     CHKERR( KSPSetOperators(snes.ksp,J,P)           )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESGetJacobian(__pyx_v_snes, (&__pyx_v_J), (&__pyx_v_P), NULL, NULL)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2099, __pyx_L1_error)

  /* "libpetsc4py.pyx":2100
 *     cdef PetscInt lits = 0
 *     CHKERR( SNESGetJacobian(snes,&J,&P,NULL,NULL)   )
 *     CHKERR( SNESComputeJacobian(snes,X,J,P)         )             # <<<<<<<<<<<<<<
 *     CHKERR( KSPSetOperators(snes.ksp,J,P)           )
 *     CHKERR( KSPSolve(snes.ksp,F,Y)                  )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESComputeJacobian(__pyx_v_snes, __pyx_v_X, __pyx_v_J, __pyx_v_P)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2100, __pyx_L1_error)

  /* "libpetsc4py.pyx":2101
 *     CHKERR( SNESGetJacobian(snes,&J,&P,NULL,NULL)   )
 *     CHKERR( SNESComputeJacobian(snes,X,J,P)         )
 *     CHKERR( KSPSetOperators(snes.ksp,J,P)           )             # <<<<<<<<<<<<<<
 *     CHKERR( KSPSolve(snes.ksp,F,Y)                  )
 *     CHKERR( KSPGetIterationNumber(snes.ksp,&lits)   )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPSetOperators(__pyx_v_snes->ksp, __pyx_v_J, __pyx_v_P)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2101, __pyx_L1_error)

  /* "libpetsc4py.pyx":2102
 *     CHKERR( SNESComputeJacobian(snes,X,J,P)         )
 *     CHKERR( KSPSetOperators(snes.ksp,J,P)           )
 *     CHKERR( KSPSolve(snes.ksp,F,Y)                  )             # <<<<<<<<<<<<<<
 *     CHKERR( KSPGetIterationNumber(snes.ksp,&lits)   )
 *     snes.linear_its += lits
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPSolve(__pyx_v_snes->ksp, __pyx_v_F, __pyx_v_Y)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2102, __pyx_L1_error)

  /* "libpetsc4py.pyx":2103
 *     CHKERR( KSPSetOperators(snes.ksp,J,P)           )
 *     CHKERR( KSPSolve(snes.ksp,F,Y)                  )
 *     CHKERR( KSPGetIterationNumber(snes.ksp,&lits)   )             # <<<<<<<<<<<<<<
 *     snes.linear_its += lits
 *     return FunctionEnd()
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPGetIterationNumber(__pyx_v_snes->ksp, (&__pyx_v_lits))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2103, __pyx_L1_error)

  /* "libpetsc4py.pyx":2104
 *     CHKERR( KSPSolve(snes.ksp,F,Y)                  )
 *     CHKERR( KSPGetIterationNumber(snes.ksp,&lits)   )
 *     snes.linear_its += lits             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_v_snes->linear_its = (__pyx_v_snes->linear_its + __pyx_v_lits);

  /* "libpetsc4py.pyx":2105
 *     CHKERR( KSPGetIterationNumber(snes.ksp,&lits)   )
 *     snes.linear_its += lits
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2089
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESStep_Python_default(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     PetscVec  X,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.SNESStep_Python_default", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2186
 * @cython.internal
 * cdef class _PyTS(_PyObj): pass
 * cdef inline _PyTS PyTS(PetscTS ts):             # <<<<<<<<<<<<<<
 *     if ts != NULL and ts.data != NULL:
 *         return <_PyTS>ts.data
 */

static CYTHON_INLINE struct __pyx_obj_11libpetsc4py__PyTS *__pyx_f_11libpetsc4py_PyTS(TS __pyx_v_ts) {
  struct __pyx_obj_11libpetsc4py__PyTS *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyTS", 0);

  /* "libpetsc4py.pyx":2187
 * cdef class _PyTS(_PyObj): pass
 * cdef inline _PyTS PyTS(PetscTS ts):
 *     if ts != NULL and ts.data != NULL:             # <<<<<<<<<<<<<<
 *         return <_PyTS>ts.data
 *     else:
 */
  __pyx_t_2 = ((__pyx_v_ts != NULL) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_ts->data != NULL) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "libpetsc4py.pyx":2188
 * cdef inline _PyTS PyTS(PetscTS ts):
 *     if ts != NULL and ts.data != NULL:
 *         return <_PyTS>ts.data             # <<<<<<<<<<<<<<
 *     else:
 *         return _PyTS.__new__(_PyTS)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_11libpetsc4py__PyTS *)__pyx_v_ts->data)));
    __pyx_r = ((struct __pyx_obj_11libpetsc4py__PyTS *)__pyx_v_ts->data);
    goto __pyx_L0;

    /* "libpetsc4py.pyx":2187
 * cdef class _PyTS(_PyObj): pass
 * cdef inline _PyTS PyTS(PetscTS ts):
 *     if ts != NULL and ts.data != NULL:             # <<<<<<<<<<<<<<
 *         return <_PyTS>ts.data
 *     else:
 */
  }

  /* "libpetsc4py.pyx":2190
 *         return <_PyTS>ts.data
 *     else:
 *         return _PyTS.__new__(_PyTS)             # <<<<<<<<<<<<<<
 * 
 * cdef public PetscErrorCode TSPythonGetContext(PetscTS ts, void **ctx) \
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_3 = ((PyObject *)__pyx_tp_new_11libpetsc4py__PyTS(((PyTypeObject *)__pyx_ptype_11libpetsc4py__PyTS), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2190, __pyx_L1_error)
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_r = ((struct __pyx_obj_11libpetsc4py__PyTS *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":2186
 * @cython.internal
 * cdef class _PyTS(_PyObj): pass
 * cdef inline _PyTS PyTS(PetscTS ts):             # <<<<<<<<<<<<<<
 *     if ts != NULL and ts.data != NULL:
 *         return <_PyTS>ts.data
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libpetsc4py.PyTS", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":2192
 *         return _PyTS.__new__(_PyTS)
 * 
 * cdef public PetscErrorCode TSPythonGetContext(PetscTS ts, void **ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"TSPythonGetContext")
 */

PetscErrorCode TSPythonGetContext(TS __pyx_v_ts, void **__pyx_v_ctx) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("TSPythonGetContext", 0);

  /* "libpetsc4py.pyx":2194
 * cdef public PetscErrorCode TSPythonGetContext(PetscTS ts, void **ctx) \
 *     except IERR:
 *     FunctionBegin(b"TSPythonGetContext")             # <<<<<<<<<<<<<<
 *     PyTS(ts).getcontext(ctx)
 *     return FunctionEnd()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSPythonGetContext"));

  /* "libpetsc4py.pyx":2195
 *     except IERR:
 *     FunctionBegin(b"TSPythonGetContext")
 *     PyTS(ts).getcontext(ctx)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_11libpetsc4py__PyTS *)((struct __pyx_obj_11libpetsc4py__PyTS *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.getcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_ctx); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 2195, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":2196
 *     FunctionBegin(b"TSPythonGetContext")
 *     PyTS(ts).getcontext(ctx)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef public PetscErrorCode TSPythonSetContext(PetscTS ts, void *ctx) \
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2192
 *         return _PyTS.__new__(_PyTS)
 * 
 * cdef public PetscErrorCode TSPythonGetContext(PetscTS ts, void **ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"TSPythonGetContext")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libpetsc4py.TSPythonGetContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":2198
 *     return FunctionEnd()
 * 
 * cdef public PetscErrorCode TSPythonSetContext(PetscTS ts, void *ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"TSPythonSetContext")
 */

PetscErrorCode TSPythonSetContext(TS __pyx_v_ts, void *__pyx_v_ctx) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("TSPythonSetContext", 0);

  /* "libpetsc4py.pyx":2200
 * cdef public PetscErrorCode TSPythonSetContext(PetscTS ts, void *ctx) \
 *     except IERR:
 *     FunctionBegin(b"TSPythonSetContext")             # <<<<<<<<<<<<<<
 *     PyTS(ts).setcontext(ctx, TS_(ts))
 *     return FunctionEnd()
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSPythonSetContext"));

  /* "libpetsc4py.pyx":2201
 *     except IERR:
 *     FunctionBegin(b"TSPythonSetContext")
 *     PyTS(ts).setcontext(ctx, TS_(ts))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((struct __pyx_vtabstruct_11libpetsc4py__PyTS *)((struct __pyx_obj_11libpetsc4py__PyTS *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.setcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_ctx, ((struct PyPetscObjectObject *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 2201, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2202
 *     FunctionBegin(b"TSPythonSetContext")
 *     PyTS(ts).setcontext(ctx, TS_(ts))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSPythonSetType_PYTHON(PetscTS ts, char name[]) \
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2198
 *     return FunctionEnd()
 * 
 * cdef public PetscErrorCode TSPythonSetContext(PetscTS ts, void *ctx) \             # <<<<<<<<<<<<<<
 *     except IERR:
 *     FunctionBegin(b"TSPythonSetContext")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.TSPythonSetContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libpetsc4py.pyx":2204
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSPythonSetType_PYTHON(PetscTS ts, char name[]) \             # <<<<<<<<<<<<<<
 *     except IERR with gil:
 *     FunctionBegin(b"TSPythonSetType_PYTHON")
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSPythonSetType_PYTHON(TS __pyx_v_ts, char *__pyx_v_name) {
  PyObject *__pyx_v_ctx = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PetscErrorCode __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSPythonSetType_PYTHON", 0);

  /* "libpetsc4py.pyx":2206
 * cdef PetscErrorCode TSPythonSetType_PYTHON(PetscTS ts, char name[]) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSPythonSetType_PYTHON")             # <<<<<<<<<<<<<<
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSPythonSetType_PYTHON"));

  /* "libpetsc4py.pyx":2207
 *     except IERR with gil:
 *     FunctionBegin(b"TSPythonSetType_PYTHON")
 *     if name == NULL: return FunctionEnd() # XXX             # <<<<<<<<<<<<<<
 *     cdef object ctx = createcontext(name)
 *     TSPythonSetContext(ts, <void*>ctx)
 */
  __pyx_t_1 = ((__pyx_v_name == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":2208
 *     FunctionBegin(b"TSPythonSetType_PYTHON")
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)             # <<<<<<<<<<<<<<
 *     TSPythonSetContext(ts, <void*>ctx)
 *     PyTS(ts).setname(name)
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_createcontext(__pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_ctx = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2209
 *     if name == NULL: return FunctionEnd() # XXX
 *     cdef object ctx = createcontext(name)
 *     TSPythonSetContext(ts, <void*>ctx)             # <<<<<<<<<<<<<<
 *     PyTS(ts).setname(name)
 *     return  0
 */
  __pyx_t_3 = TSPythonSetContext(__pyx_v_ts, ((void *)__pyx_v_ctx)); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2209, __pyx_L1_error)

  /* "libpetsc4py.pyx":2210
 *     cdef object ctx = createcontext(name)
 *     TSPythonSetContext(ts, <void*>ctx)
 *     PyTS(ts).setname(name)             # <<<<<<<<<<<<<<
 *     return  0
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = ((struct __pyx_vtabstruct_11libpetsc4py__PyTS *)((struct __pyx_obj_11libpetsc4py__PyTS *)__pyx_t_2)->__pyx_base.__pyx_vtab)->__pyx_base.setname(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_2), __pyx_v_name); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 2210, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2211
 *     TSPythonSetContext(ts, <void*>ctx)
 *     PyTS(ts).setname(name)
 *     return  0             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSCreate_Python(
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2204
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSPythonSetType_PYTHON(PetscTS ts, char name[]) \             # <<<<<<<<<<<<<<
 *     except IERR with gil:
 *     FunctionBegin(b"TSPythonSetType_PYTHON")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libpetsc4py.TSPythonSetType_PYTHON", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ctx);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2213
 *     return  0
 * 
 * cdef PetscErrorCode TSCreate_Python(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSCreate_Python(TS __pyx_v_ts) {
  TSOps __pyx_v_ops;
  PyObject *__pyx_v_ctx = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  TSOps __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSCreate_Python", 0);

  /* "libpetsc4py.pyx":2217
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSCreate_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef TSOps ops     = ts.ops
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSCreate_Python"));

  /* "libpetsc4py.pyx":2219
 *     FunctionBegin(b"TSCreate_Python")
 *     #
 *     cdef TSOps ops     = ts.ops             # <<<<<<<<<<<<<<
 *     ops.reset          = TSReset_Python
 *     ops.destroy        = TSDestroy_Python
 */
  __pyx_t_1 = __pyx_v_ts->ops;
  __pyx_v_ops = __pyx_t_1;

  /* "libpetsc4py.pyx":2220
 *     #
 *     cdef TSOps ops     = ts.ops
 *     ops.reset          = TSReset_Python             # <<<<<<<<<<<<<<
 *     ops.destroy        = TSDestroy_Python
 *     ops.setup          = TSSetUp_Python
 */
  __pyx_v_ops->reset = __pyx_f_11libpetsc4py_TSReset_Python;

  /* "libpetsc4py.pyx":2221
 *     cdef TSOps ops     = ts.ops
 *     ops.reset          = TSReset_Python
 *     ops.destroy        = TSDestroy_Python             # <<<<<<<<<<<<<<
 *     ops.setup          = TSSetUp_Python
 *     ops.setfromoptions = TSSetFromOptions_Python
 */
  __pyx_v_ops->destroy = __pyx_f_11libpetsc4py_TSDestroy_Python;

  /* "libpetsc4py.pyx":2222
 *     ops.reset          = TSReset_Python
 *     ops.destroy        = TSDestroy_Python
 *     ops.setup          = TSSetUp_Python             # <<<<<<<<<<<<<<
 *     ops.setfromoptions = TSSetFromOptions_Python
 *     ops.view           = TSView_Python
 */
  __pyx_v_ops->setup = __pyx_f_11libpetsc4py_TSSetUp_Python;

  /* "libpetsc4py.pyx":2223
 *     ops.destroy        = TSDestroy_Python
 *     ops.setup          = TSSetUp_Python
 *     ops.setfromoptions = TSSetFromOptions_Python             # <<<<<<<<<<<<<<
 *     ops.view           = TSView_Python
 *     ops.step           = TSStep_Python
 */
  __pyx_v_ops->setfromoptions = __pyx_f_11libpetsc4py_TSSetFromOptions_Python;

  /* "libpetsc4py.pyx":2224
 *     ops.setup          = TSSetUp_Python
 *     ops.setfromoptions = TSSetFromOptions_Python
 *     ops.view           = TSView_Python             # <<<<<<<<<<<<<<
 *     ops.step           = TSStep_Python
 *     ops.rollback       = TSRollBack_Python
 */
  __pyx_v_ops->view = __pyx_f_11libpetsc4py_TSView_Python;

  /* "libpetsc4py.pyx":2225
 *     ops.setfromoptions = TSSetFromOptions_Python
 *     ops.view           = TSView_Python
 *     ops.step           = TSStep_Python             # <<<<<<<<<<<<<<
 *     ops.rollback       = TSRollBack_Python
 *     ops.interpolate    = TSInterpolate_Python
 */
  __pyx_v_ops->step = __pyx_f_11libpetsc4py_TSStep_Python;

  /* "libpetsc4py.pyx":2226
 *     ops.view           = TSView_Python
 *     ops.step           = TSStep_Python
 *     ops.rollback       = TSRollBack_Python             # <<<<<<<<<<<<<<
 *     ops.interpolate    = TSInterpolate_Python
 *     ops.evaluatestep   = TSEvaluateStep_Python
 */
  __pyx_v_ops->rollback = __pyx_f_11libpetsc4py_TSRollBack_Python;

  /* "libpetsc4py.pyx":2227
 *     ops.step           = TSStep_Python
 *     ops.rollback       = TSRollBack_Python
 *     ops.interpolate    = TSInterpolate_Python             # <<<<<<<<<<<<<<
 *     ops.evaluatestep   = TSEvaluateStep_Python
 *     ops.snesfunction   = SNESTSFormFunction_Python
 */
  __pyx_v_ops->interpolate = __pyx_f_11libpetsc4py_TSInterpolate_Python;

  /* "libpetsc4py.pyx":2228
 *     ops.rollback       = TSRollBack_Python
 *     ops.interpolate    = TSInterpolate_Python
 *     ops.evaluatestep   = TSEvaluateStep_Python             # <<<<<<<<<<<<<<
 *     ops.snesfunction   = SNESTSFormFunction_Python
 *     ops.snesjacobian   = SNESTSFormJacobian_Python
 */
  __pyx_v_ops->evaluatestep = __pyx_f_11libpetsc4py_TSEvaluateStep_Python;

  /* "libpetsc4py.pyx":2229
 *     ops.interpolate    = TSInterpolate_Python
 *     ops.evaluatestep   = TSEvaluateStep_Python
 *     ops.snesfunction   = SNESTSFormFunction_Python             # <<<<<<<<<<<<<<
 *     ops.snesjacobian   = SNESTSFormJacobian_Python
 *     #
 */
  __pyx_v_ops->snesfunction = __pyx_f_11libpetsc4py_SNESTSFormFunction_Python;

  /* "libpetsc4py.pyx":2230
 *     ops.evaluatestep   = TSEvaluateStep_Python
 *     ops.snesfunction   = SNESTSFormFunction_Python
 *     ops.snesjacobian   = SNESTSFormJacobian_Python             # <<<<<<<<<<<<<<
 *     #
 *     CHKERR( PetscObjectComposeFunction(
 */
  __pyx_v_ops->snesjacobian = __pyx_f_11libpetsc4py_SNESTSFormJacobian_Python;

  /* "libpetsc4py.pyx":2232
 *     ops.snesjacobian   = SNESTSFormJacobian_Python
 *     #
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>ts, b"TSPythonSetType_C",
 *             <PetscVoidFunction>TSPythonSetType_PYTHON) )
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_ts), ((char *)"TSPythonSetType_C"), ((PetscVoidFunction)__pyx_f_11libpetsc4py_TSPythonSetType_PYTHON))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 2232, __pyx_L1_error)

  /* "libpetsc4py.pyx":2236
 *             <PetscVoidFunction>TSPythonSetType_PYTHON) )
 *     #
 *     ts.usessnes = PETSC_TRUE             # <<<<<<<<<<<<<<
 *     #
 *     cdef ctx = PyTS(NULL)
 */
  __pyx_v_ts->usessnes = PETSC_TRUE;

  /* "libpetsc4py.pyx":2238
 *     ts.usessnes = PETSC_TRUE
 *     #
 *     cdef ctx = PyTS(NULL)             # <<<<<<<<<<<<<<
 *     ts.data = <void*> ctx
 *     Py_INCREF(<PyObject*>ts.data)
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ctx = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":2239
 *     #
 *     cdef ctx = PyTS(NULL)
 *     ts.data = <void*> ctx             # <<<<<<<<<<<<<<
 *     Py_INCREF(<PyObject*>ts.data)
 *     return FunctionEnd()
 */
  __pyx_v_ts->data = ((void *)__pyx_v_ctx);

  /* "libpetsc4py.pyx":2240
 *     cdef ctx = PyTS(NULL)
 *     ts.data = <void*> ctx
 *     Py_INCREF(<PyObject*>ts.data)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_ts->data));

  /* "libpetsc4py.pyx":2241
 *     ts.data = <void*> ctx
 *     Py_INCREF(<PyObject*>ts.data)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSDestroy_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2213
 *     return  0
 * 
 * cdef PetscErrorCode TSCreate_Python(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libpetsc4py.TSCreate_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ctx);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2243
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSDestroy_Python(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSDestroy_Python(TS __pyx_v_ts) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PetscErrorCode __pyx_t_3;
  int __pyx_t_4;
  char const *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSDestroy_Python", 0);

  /* "libpetsc4py.pyx":2247
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSDestroy_Python")             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectComposeFunction(
 *             <PetscObject>ts, b"TSPythonSetType_C",
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSDestroy_Python"));

  /* "libpetsc4py.pyx":2248
 *     except IERR with gil:
 *     FunctionBegin(b"TSDestroy_Python")
 *     CHKERR( PetscObjectComposeFunction(             # <<<<<<<<<<<<<<
 *             <PetscObject>ts, b"TSPythonSetType_C",
 *             <PetscVoidFunction>NULL) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectComposeFunction(((PetscObject)__pyx_v_ts), ((char *)"TSPythonSetType_C"), ((PetscVoidFunction)NULL))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2248, __pyx_L1_error)

  /* "libpetsc4py.pyx":2252
 *             <PetscVoidFunction>NULL) )
 *     #
 *     if not Py_IsInitialized(): return FunctionEnd()             # <<<<<<<<<<<<<<
 *     try:
 *         addRef(ts)
 */
  __pyx_t_2 = ((!(Py_IsInitialized() != 0)) != 0);
  if (__pyx_t_2) {
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":2253
 *     #
 *     if not Py_IsInitialized(): return FunctionEnd()
 *     try:             # <<<<<<<<<<<<<<
 *         addRef(ts)
 *         TSPythonSetContext(ts, NULL)
 */
  /*try:*/ {

    /* "libpetsc4py.pyx":2254
 *     if not Py_IsInitialized(): return FunctionEnd()
 *     try:
 *         addRef(ts)             # <<<<<<<<<<<<<<
 *         TSPythonSetContext(ts, NULL)
 *     finally:
 */
    __pyx_f_11libpetsc4py_addRef(__pyx_v_ts);

    /* "libpetsc4py.pyx":2255
 *     try:
 *         addRef(ts)
 *         TSPythonSetContext(ts, NULL)             # <<<<<<<<<<<<<<
 *     finally:
 *         delRef(ts)
 */
    __pyx_t_3 = TSPythonSetContext(__pyx_v_ts, NULL); if (unlikely(__pyx_t_3 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2255, __pyx_L5_error)
  }

  /* "libpetsc4py.pyx":2257
 *         TSPythonSetContext(ts, NULL)
 *     finally:
 *         delRef(ts)             # <<<<<<<<<<<<<<
 *         Py_DECREF(<PyObject*>ts.data)
 *         ts.data = NULL
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_f_11libpetsc4py_delRef(__pyx_v_ts);

      /* "libpetsc4py.pyx":2258
 *     finally:
 *         delRef(ts)
 *         Py_DECREF(<PyObject*>ts.data)             # <<<<<<<<<<<<<<
 *         ts.data = NULL
 *     return FunctionEnd()
 */
      Py_DECREF(((PyObject *)__pyx_v_ts->data));

      /* "libpetsc4py.pyx":2259
 *         delRef(ts)
 *         Py_DECREF(<PyObject*>ts.data)
 *         ts.data = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
      __pyx_v_ts->data = NULL;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __pyx_t_1 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename;
      {

        /* "libpetsc4py.pyx":2257
 *         TSPythonSetContext(ts, NULL)
 *     finally:
 *         delRef(ts)             # <<<<<<<<<<<<<<
 *         Py_DECREF(<PyObject*>ts.data)
 *         ts.data = NULL
 */
        __pyx_f_11libpetsc4py_delRef(__pyx_v_ts);

        /* "libpetsc4py.pyx":2258
 *     finally:
 *         delRef(ts)
 *         Py_DECREF(<PyObject*>ts.data)             # <<<<<<<<<<<<<<
 *         ts.data = NULL
 *     return FunctionEnd()
 */
        Py_DECREF(((PyObject *)__pyx_v_ts->data));

        /* "libpetsc4py.pyx":2259
 *         delRef(ts)
 *         Py_DECREF(<PyObject*>ts.data)
 *         ts.data = NULL             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
        __pyx_v_ts->data = NULL;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
      __pyx_lineno = __pyx_t_1; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "libpetsc4py.pyx":2260
 *         Py_DECREF(<PyObject*>ts.data)
 *         ts.data = NULL
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSSetUp_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2243
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSDestroy_Python(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.TSDestroy_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2262
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSSetUp_Python(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSSetUp_Python(TS __pyx_v_ts) {
  Vec __pyx_v_vec_update;
  Vec __pyx_v_vec_dot;
  char __pyx_v_name[0x800];
  PetscBool __pyx_v_found;
  PyObject *__pyx_v_setUp = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PetscErrorCode __pyx_t_5;
  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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSSetUp_Python", 0);

  /* "libpetsc4py.pyx":2266
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSSetUp_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef PetscVec vec_update = NULL
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSSetUp_Python"));

  /* "libpetsc4py.pyx":2268
 *     FunctionBegin(b"TSSetUp_Python")
 *     #
 *     cdef PetscVec vec_update = NULL             # <<<<<<<<<<<<<<
 *     CHKERR( VecDuplicate(ts.vec_sol,&vec_update) )
 *     CHKERR( PetscObjectCompose(<PetscObject>ts,
 */
  __pyx_v_vec_update = NULL;

  /* "libpetsc4py.pyx":2269
 *     #
 *     cdef PetscVec vec_update = NULL
 *     CHKERR( VecDuplicate(ts.vec_sol,&vec_update) )             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectCompose(<PetscObject>ts,
 *                                 b"@ts.vec_update",
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecDuplicate(__pyx_v_ts->vec_sol, (&__pyx_v_vec_update))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2269, __pyx_L1_error)

  /* "libpetsc4py.pyx":2270
 *     cdef PetscVec vec_update = NULL
 *     CHKERR( VecDuplicate(ts.vec_sol,&vec_update) )
 *     CHKERR( PetscObjectCompose(<PetscObject>ts,             # <<<<<<<<<<<<<<
 *                                 b"@ts.vec_update",
 *                                 <PetscObject>vec_update) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectCompose(((PetscObject)__pyx_v_ts), ((char *)"@ts.vec_update"), ((PetscObject)__pyx_v_vec_update))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2270, __pyx_L1_error)

  /* "libpetsc4py.pyx":2273
 *                                 b"@ts.vec_update",
 *                                 <PetscObject>vec_update) )
 *     CHKERR( VecDestroy(&vec_update) )             # <<<<<<<<<<<<<<
 *     cdef PetscVec vec_dot = NULL
 *     CHKERR( VecDuplicate(ts.vec_sol,&vec_dot) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecDestroy((&__pyx_v_vec_update))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2273, __pyx_L1_error)

  /* "libpetsc4py.pyx":2274
 *                                 <PetscObject>vec_update) )
 *     CHKERR( VecDestroy(&vec_update) )
 *     cdef PetscVec vec_dot = NULL             # <<<<<<<<<<<<<<
 *     CHKERR( VecDuplicate(ts.vec_sol,&vec_dot) )
 *     CHKERR( PetscObjectCompose(<PetscObject>ts,
 */
  __pyx_v_vec_dot = NULL;

  /* "libpetsc4py.pyx":2275
 *     CHKERR( VecDestroy(&vec_update) )
 *     cdef PetscVec vec_dot = NULL
 *     CHKERR( VecDuplicate(ts.vec_sol,&vec_dot) )             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectCompose(<PetscObject>ts,
 *                                 b"@ts.vec_dot",
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecDuplicate(__pyx_v_ts->vec_sol, (&__pyx_v_vec_dot))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2275, __pyx_L1_error)

  /* "libpetsc4py.pyx":2276
 *     cdef PetscVec vec_dot = NULL
 *     CHKERR( VecDuplicate(ts.vec_sol,&vec_dot) )
 *     CHKERR( PetscObjectCompose(<PetscObject>ts,             # <<<<<<<<<<<<<<
 *                                 b"@ts.vec_dot",
 *                                 <PetscObject>vec_dot) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectCompose(((PetscObject)__pyx_v_ts), ((char *)"@ts.vec_dot"), ((PetscObject)__pyx_v_vec_dot))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2276, __pyx_L1_error)

  /* "libpetsc4py.pyx":2279
 *                                 b"@ts.vec_dot",
 *                                 <PetscObject>vec_dot) )
 *     CHKERR( VecDestroy(&vec_dot) )             # <<<<<<<<<<<<<<
 *     #
 *     cdef char name[2048]
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecDestroy((&__pyx_v_vec_dot))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2279, __pyx_L1_error)

  /* "libpetsc4py.pyx":2282
 *     #
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE             # <<<<<<<<<<<<<<
 *     if PyTS(ts).self is None:
 *         CHKERR( PetscOptionsGetString(NULL,
 */
  __pyx_v_found = PETSC_FALSE;

  /* "libpetsc4py.pyx":2283
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyTS(ts).self is None:             # <<<<<<<<<<<<<<
 *         CHKERR( PetscOptionsGetString(NULL,
 *                 getPrefix(ts),b"-ts_python_type",
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (((struct __pyx_obj_11libpetsc4py__PyTS *)__pyx_t_2)->__pyx_base.self == Py_None);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2284
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyTS(ts).self is None:
 *         CHKERR( PetscOptionsGetString(NULL,             # <<<<<<<<<<<<<<
 *                 getPrefix(ts),b"-ts_python_type",
 *                 name,sizeof(name),&found) )
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscOptionsGetString(NULL, __pyx_f_11libpetsc4py_getPrefix(__pyx_v_ts), ((char *)"-ts_python_type"), __pyx_v_name, (sizeof(__pyx_v_name)), (&__pyx_v_found))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2284, __pyx_L1_error)

    /* "libpetsc4py.pyx":2287
 *                 getPrefix(ts),b"-ts_python_type",
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:             # <<<<<<<<<<<<<<
 *             CHKERR( TSPythonSetType_PYTHON(ts,name) )
 *     if PyTS(ts).self is None:
 */
    if (__pyx_v_found) {
    } else {
      __pyx_t_4 = __pyx_v_found;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_name[0]) != 0);
    __pyx_t_4 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_4) {

      /* "libpetsc4py.pyx":2288
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:
 *             CHKERR( TSPythonSetType_PYTHON(ts,name) )             # <<<<<<<<<<<<<<
 *     if PyTS(ts).self is None:
 *         return PetscSETERR(PETSC_ERR_USER,
 */
      __pyx_t_5 = __pyx_f_11libpetsc4py_TSPythonSetType_PYTHON(__pyx_v_ts, __pyx_v_name); if (unlikely(__pyx_t_5 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2288, __pyx_L1_error)
      __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(__pyx_t_5); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2288, __pyx_L1_error)

      /* "libpetsc4py.pyx":2287
 *                 getPrefix(ts),b"-ts_python_type",
 *                 name,sizeof(name),&found) )
 *         if found and name[0]:             # <<<<<<<<<<<<<<
 *             CHKERR( TSPythonSetType_PYTHON(ts,name) )
 *     if PyTS(ts).self is None:
 */
    }

    /* "libpetsc4py.pyx":2283
 *     cdef char name[2048]
 *     cdef PetscBool found = PETSC_FALSE
 *     if PyTS(ts).self is None:             # <<<<<<<<<<<<<<
 *         CHKERR( PetscOptionsGetString(NULL,
 *                 getPrefix(ts),b"-ts_python_type",
 */
  }

  /* "libpetsc4py.pyx":2289
 *         if found and name[0]:
 *             CHKERR( TSPythonSetType_PYTHON(ts,name) )
 *     if PyTS(ts).self is None:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER,
 *             "Python context not set, call one of \n"
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = (((struct __pyx_obj_11libpetsc4py__PyTS *)__pyx_t_2)->__pyx_base.self == Py_None);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":2290
 *             CHKERR( TSPythonSetType_PYTHON(ts,name) )
 *     if PyTS(ts).self is None:
 *         return PetscSETERR(PETSC_ERR_USER,             # <<<<<<<<<<<<<<
 *             "Python context not set, call one of \n"
 *             " * TSPythonSetType(ts,\"[package.]module.class\")\n"
 */
    __pyx_r = __pyx_f_11libpetsc4py_PetscSETERR(PETSC_ERR_USER, ((char *)"Python context not set, call one of \n * TSPythonSetType(ts,\"[package.]module.class\")\n * TSSetFromOptions(ts) and pass option -ts_python_type [package.]module.class"));
    goto __pyx_L0;

    /* "libpetsc4py.pyx":2289
 *         if found and name[0]:
 *             CHKERR( TSPythonSetType_PYTHON(ts,name) )
 *     if PyTS(ts).self is None:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER,
 *             "Python context not set, call one of \n"
 */
  }

  /* "libpetsc4py.pyx":2296
 *             "-ts_python_type [package.]module.class")
 *     #
 *     cdef setUp = PyTS(ts).setUp             # <<<<<<<<<<<<<<
 *     if setUp is not None:
 *         setUp(TS_(ts))
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_setUp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_setUp = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "libpetsc4py.pyx":2297
 *     #
 *     cdef setUp = PyTS(ts).setUp
 *     if setUp is not None:             # <<<<<<<<<<<<<<
 *         setUp(TS_(ts))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_setUp != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2298
 *     cdef setUp = PyTS(ts).setUp
 *     if setUp is not None:
 *         setUp(TS_(ts))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_setUp);
    __pyx_t_7 = __pyx_v_setUp; __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_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "libpetsc4py.pyx":2297
 *     #
 *     cdef setUp = PyTS(ts).setUp
 *     if setUp is not None:             # <<<<<<<<<<<<<<
 *         setUp(TS_(ts))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":2299
 *     if setUp is not None:
 *         setUp(TS_(ts))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSReset_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2262
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSSetUp_Python(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("libpetsc4py.TSSetUp_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setUp);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2301
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSReset_Python(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSReset_Python(TS __pyx_v_ts) {
  PyObject *__pyx_v_reset = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSReset_Python", 0);

  /* "libpetsc4py.pyx":2305
 *     ) \
 *     except IERR with gil:
 *     if getRef(ts) == 0: return 0             # <<<<<<<<<<<<<<
 *     FunctionBegin(b"TSReset_Python")
 *     #
 */
  __pyx_t_1 = ((__pyx_f_11libpetsc4py_getRef(__pyx_v_ts) == 0) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":2306
 *     except IERR with gil:
 *     if getRef(ts) == 0: return 0
 *     FunctionBegin(b"TSReset_Python")             # <<<<<<<<<<<<<<
 *     #
 *     CHKERR( PetscObjectCompose(<PetscObject>ts, b"@ts.vec_update", NULL) )
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSReset_Python"));

  /* "libpetsc4py.pyx":2308
 *     FunctionBegin(b"TSReset_Python")
 *     #
 *     CHKERR( PetscObjectCompose(<PetscObject>ts, b"@ts.vec_update", NULL) )             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectCompose(<PetscObject>ts, b"@ts.vec_dot",    NULL) )
 *     #
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectCompose(((PetscObject)__pyx_v_ts), ((char *)"@ts.vec_update"), NULL)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 2308, __pyx_L1_error)

  /* "libpetsc4py.pyx":2309
 *     #
 *     CHKERR( PetscObjectCompose(<PetscObject>ts, b"@ts.vec_update", NULL) )
 *     CHKERR( PetscObjectCompose(<PetscObject>ts, b"@ts.vec_dot",    NULL) )             # <<<<<<<<<<<<<<
 *     #
 *     cdef reset = PyTS(ts).reset
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectCompose(((PetscObject)__pyx_v_ts), ((char *)"@ts.vec_dot"), NULL)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 2309, __pyx_L1_error)

  /* "libpetsc4py.pyx":2311
 *     CHKERR( PetscObjectCompose(<PetscObject>ts, b"@ts.vec_dot",    NULL) )
 *     #
 *     cdef reset = PyTS(ts).reset             # <<<<<<<<<<<<<<
 *     if reset is not None:
 *         reset(TS_(ts))
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_reset); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_reset = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "libpetsc4py.pyx":2312
 *     #
 *     cdef reset = PyTS(ts).reset
 *     if reset is not None:             # <<<<<<<<<<<<<<
 *         reset(TS_(ts))
 *     return FunctionEnd()
 */
  __pyx_t_1 = (__pyx_v_reset != Py_None);
  __pyx_t_5 = (__pyx_t_1 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":2313
 *     cdef reset = PyTS(ts).reset
 *     if reset is not None:
 *         reset(TS_(ts))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_3 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2313, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_reset);
    __pyx_t_6 = __pyx_v_reset; __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2313, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "libpetsc4py.pyx":2312
 *     #
 *     cdef reset = PyTS(ts).reset
 *     if reset is not None:             # <<<<<<<<<<<<<<
 *         reset(TS_(ts))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":2314
 *     if reset is not None:
 *         reset(TS_(ts))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSSetFromOptions_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2301
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSReset_Python(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libpetsc4py.TSReset_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_reset);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2316
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSSetFromOptions_Python(             # <<<<<<<<<<<<<<
 *     PetscOptionItems *PetscOptionsObject,
 *     PetscTS ts,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSSetFromOptions_Python(PetscOptionItems *__pyx_v_PetscOptionsObject, TS __pyx_v_ts) {
  char __pyx_v_name[0x800];
  char *__pyx_v_defval;
  PetscBool __pyx_v_found;
  PetscOptionItems *PetscOptionsObject;
  PyObject *__pyx_v_setFromOptions = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PetscErrorCode __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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSSetFromOptions_Python", 0);

  /* "libpetsc4py.pyx":2321
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSSetFromOptions_Python")             # <<<<<<<<<<<<<<
 *     cdef char name[2048], *defval = PyTS(ts).getname()
 *     cdef PetscBool found = PETSC_FALSE
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSSetFromOptions_Python"));

  /* "libpetsc4py.pyx":2322
 *     except IERR with gil:
 *     FunctionBegin(b"TSSetFromOptions_Python")
 *     cdef char name[2048], *defval = PyTS(ts).getname()             # <<<<<<<<<<<<<<
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_11libpetsc4py__PyTS *)((struct __pyx_obj_11libpetsc4py__PyTS *)__pyx_t_1)->__pyx_base.__pyx_vtab)->__pyx_base.getname(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1)); if (unlikely(__pyx_t_2 == ((char *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 2322, __pyx_L1_error)
  __pyx_v_defval = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":2323
 *     FunctionBegin(b"TSSetFromOptions_Python")
 *     cdef char name[2048], *defval = PyTS(ts).getname()
 *     cdef PetscBool found = PETSC_FALSE             # <<<<<<<<<<<<<<
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 *     CHKERR( PetscOptionsString(
 */
  __pyx_v_found = PETSC_FALSE;

  /* "libpetsc4py.pyx":2324
 *     cdef char name[2048], *defval = PyTS(ts).getname()
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject             # <<<<<<<<<<<<<<
 *     CHKERR( PetscOptionsString(
 *             b"-ts_python_type",b"Python [package.]module[.{class|function}]",
 */
  PetscOptionsObject = __pyx_v_PetscOptionsObject;

  /* "libpetsc4py.pyx":2325
 *     cdef PetscBool found = PETSC_FALSE
 *     cdef PetscOptionItems *opts "PetscOptionsObject" = PetscOptionsObject
 *     CHKERR( PetscOptionsString(             # <<<<<<<<<<<<<<
 *             b"-ts_python_type",b"Python [package.]module[.{class|function}]",
 *             b"TSPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 */
  __pyx_t_3 = __pyx_f_11libpetsc4py_CHKERR(PetscOptionsString(((char *)"-ts_python_type"), ((char *)"Python [package.]module[.{class|function}]"), ((char *)"TSPythonSetType"), __pyx_v_defval, __pyx_v_name, (sizeof(__pyx_v_name)), (&__pyx_v_found))); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 2325, __pyx_L1_error)

  /* "libpetsc4py.pyx":2327
 *     CHKERR( PetscOptionsString(
 *             b"-ts_python_type",b"Python [package.]module[.{class|function}]",
 *             b"TSPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;             # <<<<<<<<<<<<<<
 *     if found and name[0]:
 *         CHKERR( TSPythonSetType_PYTHON(ts,name) )
 */
  ((void)PetscOptionsObject);

  /* "libpetsc4py.pyx":2328
 *             b"-ts_python_type",b"Python [package.]module[.{class|function}]",
 *             b"TSPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:             # <<<<<<<<<<<<<<
 *         CHKERR( TSPythonSetType_PYTHON(ts,name) )
 *     #
 */
  if (__pyx_v_found) {
  } else {
    __pyx_t_4 = __pyx_v_found;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_name[0]) != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2329
 *             b"TSPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:
 *         CHKERR( TSPythonSetType_PYTHON(ts,name) )             # <<<<<<<<<<<<<<
 *     #
 *     cdef setFromOptions = PyTS(ts).setFromOptions
 */
    __pyx_t_6 = __pyx_f_11libpetsc4py_TSPythonSetType_PYTHON(__pyx_v_ts, __pyx_v_name); if (unlikely(__pyx_t_6 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2329, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_11libpetsc4py_CHKERR(__pyx_t_6); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 2329, __pyx_L1_error)

    /* "libpetsc4py.pyx":2328
 *             b"-ts_python_type",b"Python [package.]module[.{class|function}]",
 *             b"TSPythonSetType",defval,name,sizeof(name),&found) ); <void>opts;
 *     if found and name[0]:             # <<<<<<<<<<<<<<
 *         CHKERR( TSPythonSetType_PYTHON(ts,name) )
 *     #
 */
  }

  /* "libpetsc4py.pyx":2331
 *         CHKERR( TSPythonSetType_PYTHON(ts,name) )
 *     #
 *     cdef setFromOptions = PyTS(ts).setFromOptions             # <<<<<<<<<<<<<<
 *     if setFromOptions is not None:
 *         setFromOptions(TS_(ts))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_setFromOptions); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_setFromOptions = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "libpetsc4py.pyx":2332
 *     #
 *     cdef setFromOptions = PyTS(ts).setFromOptions
 *     if setFromOptions is not None:             # <<<<<<<<<<<<<<
 *         setFromOptions(TS_(ts))
 *     CHKERR( SNESSetFromOptions(ts.snes) )
 */
  __pyx_t_4 = (__pyx_v_setFromOptions != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":2333
 *     cdef setFromOptions = PyTS(ts).setFromOptions
 *     if setFromOptions is not None:
 *         setFromOptions(TS_(ts))             # <<<<<<<<<<<<<<
 *     CHKERR( SNESSetFromOptions(ts.snes) )
 *     return FunctionEnd()
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_setFromOptions);
    __pyx_t_8 = __pyx_v_setFromOptions; __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_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __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, 2333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "libpetsc4py.pyx":2332
 *     #
 *     cdef setFromOptions = PyTS(ts).setFromOptions
 *     if setFromOptions is not None:             # <<<<<<<<<<<<<<
 *         setFromOptions(TS_(ts))
 *     CHKERR( SNESSetFromOptions(ts.snes) )
 */
  }

  /* "libpetsc4py.pyx":2334
 *     if setFromOptions is not None:
 *         setFromOptions(TS_(ts))
 *     CHKERR( SNESSetFromOptions(ts.snes) )             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_3 = __pyx_f_11libpetsc4py_CHKERR(SNESSetFromOptions(__pyx_v_ts->snes)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 2334, __pyx_L1_error)

  /* "libpetsc4py.pyx":2335
 *         setFromOptions(TS_(ts))
 *     CHKERR( SNESSetFromOptions(ts.snes) )
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSView_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2316
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSSetFromOptions_Python(             # <<<<<<<<<<<<<<
 *     PetscOptionItems *PetscOptionsObject,
 *     PetscTS ts,
 */

  /* function exit code */
  __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("libpetsc4py.TSSetFromOptions_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_setFromOptions);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2337
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSView_Python(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     PetscViewer vwr,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSView_Python(TS __pyx_v_ts, PetscViewer __pyx_v_vwr) {
  PyObject *__pyx_v_view = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSView_Python", 0);

  /* "libpetsc4py.pyx":2342
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSView_Python")             # <<<<<<<<<<<<<<
 *     viewcontext(PyTS(ts), vwr)
 *     cdef view = PyTS(ts).view
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSView_Python"));

  /* "libpetsc4py.pyx":2343
 *     except IERR with gil:
 *     FunctionBegin(b"TSView_Python")
 *     viewcontext(PyTS(ts), vwr)             # <<<<<<<<<<<<<<
 *     cdef view = PyTS(ts).view
 *     if view is not None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_11libpetsc4py_viewcontext(((struct __pyx_obj_11libpetsc4py__PyObj *)__pyx_t_1), __pyx_v_vwr); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 2343, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libpetsc4py.pyx":2344
 *     FunctionBegin(b"TSView_Python")
 *     viewcontext(PyTS(ts), vwr)
 *     cdef view = PyTS(ts).view             # <<<<<<<<<<<<<<
 *     if view is not None:
 *         view(TS_(ts), Viewer_(vwr))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_view); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_view = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":2345
 *     viewcontext(PyTS(ts), vwr)
 *     cdef view = PyTS(ts).view
 *     if view is not None:             # <<<<<<<<<<<<<<
 *         view(TS_(ts), Viewer_(vwr))
 *     return FunctionEnd()
 */
  __pyx_t_4 = (__pyx_v_view != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":2346
 *     cdef view = PyTS(ts).view
 *     if view is not None:
 *         view(TS_(ts), Viewer_(vwr))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2346, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Viewer_(__pyx_v_vwr)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2346, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_view);
    __pyx_t_7 = __pyx_v_view; __pyx_t_8 = NULL;
    __pyx_t_2 = 0;
    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_2 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2346, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2346, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2346, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_2, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_2, __pyx_t_6);
      __pyx_t_1 = 0;
      __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2346, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libpetsc4py.pyx":2345
 *     viewcontext(PyTS(ts), vwr)
 *     cdef view = PyTS(ts).view
 *     if view is not None:             # <<<<<<<<<<<<<<
 *         view(TS_(ts), Viewer_(vwr))
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":2347
 *     if view is not None:
 *         view(TS_(ts), Viewer_(vwr))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSStep_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2337
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSView_Python(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     PetscViewer vwr,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libpetsc4py.TSView_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_view);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2349
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSStep_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSStep_Python(TS __pyx_v_ts) {
  PyObject *__pyx_v_step = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PetscErrorCode __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSStep_Python", 0);

  /* "libpetsc4py.pyx":2353
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSStep_Python")             # <<<<<<<<<<<<<<
 *     cdef step = PyTS(ts).step
 *     if step is not None:
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSStep_Python"));

  /* "libpetsc4py.pyx":2354
 *     except IERR with gil:
 *     FunctionBegin(b"TSStep_Python")
 *     cdef step = PyTS(ts).step             # <<<<<<<<<<<<<<
 *     if step is not None:
 *         step(TS_(ts))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_step); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_step = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2355
 *     FunctionBegin(b"TSStep_Python")
 *     cdef step = PyTS(ts).step
 *     if step is not None:             # <<<<<<<<<<<<<<
 *         step(TS_(ts))
 *     else:
 */
  __pyx_t_3 = (__pyx_v_step != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2356
 *     cdef step = PyTS(ts).step
 *     if step is not None:
 *         step(TS_(ts))             # <<<<<<<<<<<<<<
 *     else:
 *         TSStep_Python_default(ts)
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_step);
    __pyx_t_5 = __pyx_v_step; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":2355
 *     FunctionBegin(b"TSStep_Python")
 *     cdef step = PyTS(ts).step
 *     if step is not None:             # <<<<<<<<<<<<<<
 *         step(TS_(ts))
 *     else:
 */
    goto __pyx_L3;
  }

  /* "libpetsc4py.pyx":2358
 *         step(TS_(ts))
 *     else:
 *         TSStep_Python_default(ts)             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  /*else*/ {
    __pyx_t_7 = __pyx_f_11libpetsc4py_TSStep_Python_default(__pyx_v_ts); if (unlikely(__pyx_t_7 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2358, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "libpetsc4py.pyx":2359
 *     else:
 *         TSStep_Python_default(ts)
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSRollBack_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2349
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSStep_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.TSStep_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_step);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2361
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSRollBack_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSRollBack_Python(TS __pyx_v_ts) {
  PyObject *__pyx_v_rollback = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSRollBack_Python", 0);

  /* "libpetsc4py.pyx":2365
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSRollBack_Python")             # <<<<<<<<<<<<<<
 *     cdef rollback = PyTS(ts).rollback
 *     if rollback is None: return UNSUPPORTED(b"rollback")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSRollBack_Python"));

  /* "libpetsc4py.pyx":2366
 *     except IERR with gil:
 *     FunctionBegin(b"TSRollBack_Python")
 *     cdef rollback = PyTS(ts).rollback             # <<<<<<<<<<<<<<
 *     if rollback is None: return UNSUPPORTED(b"rollback")
 *     rollback(TS_(ts))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2366, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_rollback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2366, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_rollback = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2367
 *     FunctionBegin(b"TSRollBack_Python")
 *     cdef rollback = PyTS(ts).rollback
 *     if rollback is None: return UNSUPPORTED(b"rollback")             # <<<<<<<<<<<<<<
 *     rollback(TS_(ts))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_rollback == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"rollback"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":2368
 *     cdef rollback = PyTS(ts).rollback
 *     if rollback is None: return UNSUPPORTED(b"rollback")
 *     rollback(TS_(ts))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2368, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_rollback);
  __pyx_t_5 = __pyx_v_rollback; __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2368, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2369
 *     if rollback is None: return UNSUPPORTED(b"rollback")
 *     rollback(TS_(ts))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSInterpolate_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2361
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSRollBack_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libpetsc4py.TSRollBack_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rollback);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2371
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSInterpolate_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     PetscReal t,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSInterpolate_Python(TS __pyx_v_ts, PetscReal __pyx_v_t, Vec __pyx_v_x) {
  PyObject *__pyx_v_interpolate = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSInterpolate_Python", 0);

  /* "libpetsc4py.pyx":2377
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSInterpolate _Python")             # <<<<<<<<<<<<<<
 *     cdef interpolate = PyTS(ts).interpolate
 *     if interpolate is None: return UNSUPPORTED(b"interpolate")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSInterpolate _Python"));

  /* "libpetsc4py.pyx":2378
 *     except IERR with gil:
 *     FunctionBegin(b"TSInterpolate _Python")
 *     cdef interpolate = PyTS(ts).interpolate             # <<<<<<<<<<<<<<
 *     if interpolate is None: return UNSUPPORTED(b"interpolate")
 *     interpolate(TS_(ts),toReal(t),Vec_(x))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_interpolate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_interpolate = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2379
 *     FunctionBegin(b"TSInterpolate _Python")
 *     cdef interpolate = PyTS(ts).interpolate
 *     if interpolate is None: return UNSUPPORTED(b"interpolate")             # <<<<<<<<<<<<<<
 *     interpolate(TS_(ts),toReal(t),Vec_(x))
 *     return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_interpolate == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"interpolate"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":2380
 *     cdef interpolate = PyTS(ts).interpolate
 *     if interpolate is None: return UNSUPPORTED(b"interpolate")
 *     interpolate(TS_(ts),toReal(t),Vec_(x))             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __pyx_f_11libpetsc4py_toReal(__pyx_v_t); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_interpolate);
  __pyx_t_7 = __pyx_v_interpolate; __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  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_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2380, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2380, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2380, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2380, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2381
 *     if interpolate is None: return UNSUPPORTED(b"interpolate")
 *     interpolate(TS_(ts),toReal(t),Vec_(x))
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSEvaluateStep_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2371
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSInterpolate_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     PetscReal t,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.TSInterpolate_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_interpolate);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2383
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSEvaluateStep_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     PetscInt  o,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSEvaluateStep_Python(TS __pyx_v_ts, PetscInt __pyx_v_o, Vec __pyx_v_x, PetscBool *__pyx_v_flag) {
  PyObject *__pyx_v_evaluatestep = 0;
  PyObject *__pyx_v_done = 0;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  PetscBool __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSEvaluateStep_Python", 0);

  /* "libpetsc4py.pyx":2390
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSEvaluateStep _Python")             # <<<<<<<<<<<<<<
 *     cdef evaluatestep = PyTS(ts).evaluatestep
 *     if evaluatestep is None: return UNSUPPORTED(b"evaluatestep")
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSEvaluateStep _Python"));

  /* "libpetsc4py.pyx":2391
 *     except IERR with gil:
 *     FunctionBegin(b"TSEvaluateStep _Python")
 *     cdef evaluatestep = PyTS(ts).evaluatestep             # <<<<<<<<<<<<<<
 *     if evaluatestep is None: return UNSUPPORTED(b"evaluatestep")
 *     cdef done = evaluatestep(TS_(ts),toInt(o),Vec_(x))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_evaluatestep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_evaluatestep = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2392
 *     FunctionBegin(b"TSEvaluateStep _Python")
 *     cdef evaluatestep = PyTS(ts).evaluatestep
 *     if evaluatestep is None: return UNSUPPORTED(b"evaluatestep")             # <<<<<<<<<<<<<<
 *     cdef done = evaluatestep(TS_(ts),toInt(o),Vec_(x))
 *     if flag != NULL:
 */
  __pyx_t_3 = (__pyx_v_evaluatestep == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
    __pyx_r = __pyx_f_11libpetsc4py_UNSUPPORTED(((char *)"evaluatestep"));
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":2393
 *     cdef evaluatestep = PyTS(ts).evaluatestep
 *     if evaluatestep is None: return UNSUPPORTED(b"evaluatestep")
 *     cdef done = evaluatestep(TS_(ts),toInt(o),Vec_(x))             # <<<<<<<<<<<<<<
 *     if flag != NULL:
 *         flag[0] = PETSC_TRUE if done else PETSC_FALSE
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __pyx_f_11libpetsc4py_toInt(__pyx_v_o); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_evaluatestep);
  __pyx_t_7 = __pyx_v_evaluatestep; __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  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_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2393, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2393, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_done = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2394
 *     if evaluatestep is None: return UNSUPPORTED(b"evaluatestep")
 *     cdef done = evaluatestep(TS_(ts),toInt(o),Vec_(x))
 *     if flag != NULL:             # <<<<<<<<<<<<<<
 *         flag[0] = PETSC_TRUE if done else PETSC_FALSE
 *     elif not done:
 */
  __pyx_t_4 = ((__pyx_v_flag != NULL) != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2395
 *     cdef done = evaluatestep(TS_(ts),toInt(o),Vec_(x))
 *     if flag != NULL:
 *         flag[0] = PETSC_TRUE if done else PETSC_FALSE             # <<<<<<<<<<<<<<
 *     elif not done:
 *         return PetscSETERR(PETSC_ERR_USER, "Cannot evaluate step")
 */
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_done); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2395, __pyx_L1_error)
    if (__pyx_t_4) {
      __pyx_t_11 = PETSC_TRUE;
    } else {
      __pyx_t_11 = PETSC_FALSE;
    }
    (__pyx_v_flag[0]) = __pyx_t_11;

    /* "libpetsc4py.pyx":2394
 *     if evaluatestep is None: return UNSUPPORTED(b"evaluatestep")
 *     cdef done = evaluatestep(TS_(ts),toInt(o),Vec_(x))
 *     if flag != NULL:             # <<<<<<<<<<<<<<
 *         flag[0] = PETSC_TRUE if done else PETSC_FALSE
 *     elif not done:
 */
    goto __pyx_L4;
  }

  /* "libpetsc4py.pyx":2396
 *     if flag != NULL:
 *         flag[0] = PETSC_TRUE if done else PETSC_FALSE
 *     elif not done:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER, "Cannot evaluate step")
 *     return FunctionEnd()
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_done); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2396, __pyx_L1_error)
  __pyx_t_3 = ((!__pyx_t_4) != 0);
  if (__pyx_t_3) {

    /* "libpetsc4py.pyx":2397
 *         flag[0] = PETSC_TRUE if done else PETSC_FALSE
 *     elif not done:
 *         return PetscSETERR(PETSC_ERR_USER, "Cannot evaluate step")             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_r = __pyx_f_11libpetsc4py_PetscSETERR(PETSC_ERR_USER, ((char *)"Cannot evaluate step"));
    goto __pyx_L0;

    /* "libpetsc4py.pyx":2396
 *     if flag != NULL:
 *         flag[0] = PETSC_TRUE if done else PETSC_FALSE
 *     elif not done:             # <<<<<<<<<<<<<<
 *         return PetscSETERR(PETSC_ERR_USER, "Cannot evaluate step")
 *     return FunctionEnd()
 */
  }
  __pyx_L4:;

  /* "libpetsc4py.pyx":2398
 *     elif not done:
 *         return PetscSETERR(PETSC_ERR_USER, "Cannot evaluate step")
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESTSFormFunction_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2383
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSEvaluateStep_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     PetscInt  o,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.TSEvaluateStep_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_evaluatestep);
  __Pyx_XDECREF(__pyx_v_done);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2400
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESTSFormFunction_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     PetscVec  x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESTSFormFunction_Python(SNES __pyx_v_snes, Vec __pyx_v_x, Vec __pyx_v_f, TS __pyx_v_ts) {
  PyObject *__pyx_v_formSNESFunction = 0;
  PyObject *__pyx_v_args = NULL;
  Vec __pyx_v_dx;
  PetscReal __pyx_v_t;
  PetscReal __pyx_v_a;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESTSFormFunction_Python", 0);

  /* "libpetsc4py.pyx":2408
 *     except IERR with gil:
 *     #
 *     cdef formSNESFunction = PyTS(ts).formSNESFunction             # <<<<<<<<<<<<<<
 *     if formSNESFunction is not None:
 *         args = (SNES_(snes),Vec_(x),Vec_(f),TS_(ts))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_formSNESFunction); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_formSNESFunction = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2409
 *     #
 *     cdef formSNESFunction = PyTS(ts).formSNESFunction
 *     if formSNESFunction is not None:             # <<<<<<<<<<<<<<
 *         args = (SNES_(snes),Vec_(x),Vec_(f),TS_(ts))
 *         formSNESFunction(args)
 */
  __pyx_t_3 = (__pyx_v_formSNESFunction != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2410
 *     cdef formSNESFunction = PyTS(ts).formSNESFunction
 *     if formSNESFunction is not None:
 *         args = (SNES_(snes),Vec_(x),Vec_(f),TS_(ts))             # <<<<<<<<<<<<<<
 *         formSNESFunction(args)
 *         return FunctionEnd()
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_SNES_(__pyx_v_snes)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_f)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_6);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_v_args = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "libpetsc4py.pyx":2411
 *     if formSNESFunction is not None:
 *         args = (SNES_(snes),Vec_(x),Vec_(f),TS_(ts))
 *         formSNESFunction(args)             # <<<<<<<<<<<<<<
 *         return FunctionEnd()
 *     #
 */
    __Pyx_INCREF(__pyx_v_formSNESFunction);
    __pyx_t_6 = __pyx_v_formSNESFunction; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_7 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_v_args) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_args);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "libpetsc4py.pyx":2412
 *         args = (SNES_(snes),Vec_(x),Vec_(f),TS_(ts))
 *         formSNESFunction(args)
 *         return FunctionEnd()             # <<<<<<<<<<<<<<
 *     #
 *     cdef PetscVec dx = NULL
 */
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;

    /* "libpetsc4py.pyx":2409
 *     #
 *     cdef formSNESFunction = PyTS(ts).formSNESFunction
 *     if formSNESFunction is not None:             # <<<<<<<<<<<<<<
 *         args = (SNES_(snes),Vec_(x),Vec_(f),TS_(ts))
 *         formSNESFunction(args)
 */
  }

  /* "libpetsc4py.pyx":2414
 *         return FunctionEnd()
 *     #
 *     cdef PetscVec dx = NULL             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectQuery(
 *             <PetscObject>ts,
 */
  __pyx_v_dx = NULL;

  /* "libpetsc4py.pyx":2415
 *     #
 *     cdef PetscVec dx = NULL
 *     CHKERR( PetscObjectQuery(             # <<<<<<<<<<<<<<
 *             <PetscObject>ts,
 *              b"@ts.vec_dot",
 */
  __pyx_t_8 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectQuery(((PetscObject)__pyx_v_ts), ((char *)"@ts.vec_dot"), ((PetscObject *)(&__pyx_v_dx)))); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 2415, __pyx_L1_error)

  /* "libpetsc4py.pyx":2420
 *              <PetscObject*>&dx) )
 *     #
 *     cdef PetscReal t = ts.ptime + ts.time_step             # <<<<<<<<<<<<<<
 *     cdef PetscReal a = 1.0/ts.time_step
 *     CHKERR( VecCopy(ts.vec_sol,dx)          )
 */
  __pyx_v_t = (__pyx_v_ts->ptime + __pyx_v_ts->time_step);

  /* "libpetsc4py.pyx":2421
 *     #
 *     cdef PetscReal t = ts.ptime + ts.time_step
 *     cdef PetscReal a = 1.0/ts.time_step             # <<<<<<<<<<<<<<
 *     CHKERR( VecCopy(ts.vec_sol,dx)          )
 *     CHKERR( VecAXPBY(dx,+a,-a,x)            )
 */
  __pyx_v_a = (((PetscReal)1.0) / __pyx_v_ts->time_step);

  /* "libpetsc4py.pyx":2422
 *     cdef PetscReal t = ts.ptime + ts.time_step
 *     cdef PetscReal a = 1.0/ts.time_step
 *     CHKERR( VecCopy(ts.vec_sol,dx)          )             # <<<<<<<<<<<<<<
 *     CHKERR( VecAXPBY(dx,+a,-a,x)            )
 *     CHKERR( TSComputeIFunction(ts,t,x,dx,f,PETSC_FALSE) )
 */
  __pyx_t_8 = __pyx_f_11libpetsc4py_CHKERR(VecCopy(__pyx_v_ts->vec_sol, __pyx_v_dx)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 2422, __pyx_L1_error)

  /* "libpetsc4py.pyx":2423
 *     cdef PetscReal a = 1.0/ts.time_step
 *     CHKERR( VecCopy(ts.vec_sol,dx)          )
 *     CHKERR( VecAXPBY(dx,+a,-a,x)            )             # <<<<<<<<<<<<<<
 *     CHKERR( TSComputeIFunction(ts,t,x,dx,f,PETSC_FALSE) )
 *     return FunctionEnd()
 */
  __pyx_t_8 = __pyx_f_11libpetsc4py_CHKERR(VecAXPBY(__pyx_v_dx, __pyx_v_a, (-__pyx_v_a), __pyx_v_x)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 2423, __pyx_L1_error)

  /* "libpetsc4py.pyx":2424
 *     CHKERR( VecCopy(ts.vec_sol,dx)          )
 *     CHKERR( VecAXPBY(dx,+a,-a,x)            )
 *     CHKERR( TSComputeIFunction(ts,t,x,dx,f,PETSC_FALSE) )             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_8 = __pyx_f_11libpetsc4py_CHKERR(TSComputeIFunction(__pyx_v_ts, __pyx_v_t, __pyx_v_x, __pyx_v_dx, __pyx_v_f, PETSC_FALSE)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 2424, __pyx_L1_error)

  /* "libpetsc4py.pyx":2425
 *     CHKERR( VecAXPBY(dx,+a,-a,x)            )
 *     CHKERR( TSComputeIFunction(ts,t,x,dx,f,PETSC_FALSE) )
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode SNESTSFormJacobian_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2400
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESTSFormFunction_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     PetscVec  x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libpetsc4py.SNESTSFormFunction_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_formSNESFunction);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2427
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESTSFormJacobian_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     PetscVec  x,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_SNESTSFormJacobian_Python(SNES __pyx_v_snes, Vec __pyx_v_x, Mat __pyx_v_A, Mat __pyx_v_B, TS __pyx_v_ts) {
  PyObject *__pyx_v_formSNESJacobian = 0;
  PyObject *__pyx_v_args = NULL;
  Vec __pyx_v_dx;
  PetscReal __pyx_v_t;
  PetscReal __pyx_v_a;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("SNESTSFormJacobian_Python", 0);

  /* "libpetsc4py.pyx":2436
 *     except IERR with gil:
 *     #
 *     cdef formSNESJacobian = PyTS(ts).formSNESJacobian             # <<<<<<<<<<<<<<
 *     if formSNESJacobian is not None:
 *         args = (SNES_(snes),Vec_(x),Mat_(A),Mat_(B),TS_(ts))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_formSNESJacobian); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_formSNESJacobian = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2437
 *     #
 *     cdef formSNESJacobian = PyTS(ts).formSNESJacobian
 *     if formSNESJacobian is not None:             # <<<<<<<<<<<<<<
 *         args = (SNES_(snes),Vec_(x),Mat_(A),Mat_(B),TS_(ts))
 *         formSNESJacobian(*args)
 */
  __pyx_t_3 = (__pyx_v_formSNESJacobian != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2438
 *     cdef formSNESJacobian = PyTS(ts).formSNESJacobian
 *     if formSNESJacobian is not None:
 *         args = (SNES_(snes),Vec_(x),Mat_(A),Mat_(B),TS_(ts))             # <<<<<<<<<<<<<<
 *         formSNESJacobian(*args)
 *         return FunctionEnd()
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_SNES_(__pyx_v_snes)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_A)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Mat_(__pyx_v_B)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyTuple_New(5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_t_7);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_v_args = ((PyObject*)__pyx_t_8);
    __pyx_t_8 = 0;

    /* "libpetsc4py.pyx":2439
 *     if formSNESJacobian is not None:
 *         args = (SNES_(snes),Vec_(x),Mat_(A),Mat_(B),TS_(ts))
 *         formSNESJacobian(*args)             # <<<<<<<<<<<<<<
 *         return FunctionEnd()
 *     #
 */
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_v_formSNESJacobian, __pyx_v_args, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "libpetsc4py.pyx":2440
 *         args = (SNES_(snes),Vec_(x),Mat_(A),Mat_(B),TS_(ts))
 *         formSNESJacobian(*args)
 *         return FunctionEnd()             # <<<<<<<<<<<<<<
 *     #
 *     cdef PetscVec dx = NULL
 */
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;

    /* "libpetsc4py.pyx":2437
 *     #
 *     cdef formSNESJacobian = PyTS(ts).formSNESJacobian
 *     if formSNESJacobian is not None:             # <<<<<<<<<<<<<<
 *         args = (SNES_(snes),Vec_(x),Mat_(A),Mat_(B),TS_(ts))
 *         formSNESJacobian(*args)
 */
  }

  /* "libpetsc4py.pyx":2442
 *         return FunctionEnd()
 *     #
 *     cdef PetscVec dx = NULL             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectQuery(
 *             <PetscObject>ts,
 */
  __pyx_v_dx = NULL;

  /* "libpetsc4py.pyx":2443
 *     #
 *     cdef PetscVec dx = NULL
 *     CHKERR( PetscObjectQuery(             # <<<<<<<<<<<<<<
 *             <PetscObject>ts,
 *              b"@ts.vec_dot",
 */
  __pyx_t_9 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectQuery(((PetscObject)__pyx_v_ts), ((char *)"@ts.vec_dot"), ((PetscObject *)(&__pyx_v_dx)))); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 2443, __pyx_L1_error)

  /* "libpetsc4py.pyx":2448
 *              <PetscObject*>&dx) )
 *     #
 *     cdef PetscReal t = ts.ptime + ts.time_step             # <<<<<<<<<<<<<<
 *     cdef PetscReal a = 1.0/ts.time_step
 *     CHKERR( VecCopy(ts.vec_sol,dx)                )
 */
  __pyx_v_t = (__pyx_v_ts->ptime + __pyx_v_ts->time_step);

  /* "libpetsc4py.pyx":2449
 *     #
 *     cdef PetscReal t = ts.ptime + ts.time_step
 *     cdef PetscReal a = 1.0/ts.time_step             # <<<<<<<<<<<<<<
 *     CHKERR( VecCopy(ts.vec_sol,dx)                )
 *     CHKERR( VecAXPBY(dx,+a,-a,x)                  )
 */
  __pyx_v_a = (((PetscReal)1.0) / __pyx_v_ts->time_step);

  /* "libpetsc4py.pyx":2450
 *     cdef PetscReal t = ts.ptime + ts.time_step
 *     cdef PetscReal a = 1.0/ts.time_step
 *     CHKERR( VecCopy(ts.vec_sol,dx)                )             # <<<<<<<<<<<<<<
 *     CHKERR( VecAXPBY(dx,+a,-a,x)                  )
 *     CHKERR( TSComputeIJacobian(ts,t,x,dx,a,A,B,PETSC_FALSE) )
 */
  __pyx_t_9 = __pyx_f_11libpetsc4py_CHKERR(VecCopy(__pyx_v_ts->vec_sol, __pyx_v_dx)); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 2450, __pyx_L1_error)

  /* "libpetsc4py.pyx":2451
 *     cdef PetscReal a = 1.0/ts.time_step
 *     CHKERR( VecCopy(ts.vec_sol,dx)                )
 *     CHKERR( VecAXPBY(dx,+a,-a,x)                  )             # <<<<<<<<<<<<<<
 *     CHKERR( TSComputeIJacobian(ts,t,x,dx,a,A,B,PETSC_FALSE) )
 *     return FunctionEnd()
 */
  __pyx_t_9 = __pyx_f_11libpetsc4py_CHKERR(VecAXPBY(__pyx_v_dx, __pyx_v_a, (-__pyx_v_a), __pyx_v_x)); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 2451, __pyx_L1_error)

  /* "libpetsc4py.pyx":2452
 *     CHKERR( VecCopy(ts.vec_sol,dx)                )
 *     CHKERR( VecAXPBY(dx,+a,-a,x)                  )
 *     CHKERR( TSComputeIJacobian(ts,t,x,dx,a,A,B,PETSC_FALSE) )             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_t_9 = __pyx_f_11libpetsc4py_CHKERR(TSComputeIJacobian(__pyx_v_ts, __pyx_v_t, __pyx_v_x, __pyx_v_dx, __pyx_v_a, __pyx_v_A, __pyx_v_B, PETSC_FALSE)); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 2452, __pyx_L1_error)

  /* "libpetsc4py.pyx":2453
 *     CHKERR( VecAXPBY(dx,+a,-a,x)                  )
 *     CHKERR( TSComputeIJacobian(ts,t,x,dx,a,A,B,PETSC_FALSE) )
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSSolveStep_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2427
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode SNESTSFormJacobian_Python(             # <<<<<<<<<<<<<<
 *     PetscSNES snes,
 *     PetscVec  x,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("libpetsc4py.SNESTSFormJacobian_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_formSNESJacobian);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2455
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSSolveStep_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     PetscReal t,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSSolveStep_Python(TS __pyx_v_ts, PetscReal __pyx_v_t, Vec __pyx_v_x) {
  PyObject *__pyx_v_solveStep = 0;
  PetscInt __pyx_v_nits;
  PetscInt __pyx_v_lits;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  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_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSSolveStep_Python", 0);

  /* "libpetsc4py.pyx":2461
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSSolveStep_Python")             # <<<<<<<<<<<<<<
 *     #
 *     cdef solveStep = PyTS(ts).solveStep
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSSolveStep_Python"));

  /* "libpetsc4py.pyx":2463
 *     FunctionBegin(b"TSSolveStep_Python")
 *     #
 *     cdef solveStep = PyTS(ts).solveStep             # <<<<<<<<<<<<<<
 *     if solveStep is not None:
 *         solveStep(TS_(ts), <double>t, Vec_(x))
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_solveStep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_solveStep = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2464
 *     #
 *     cdef solveStep = PyTS(ts).solveStep
 *     if solveStep is not None:             # <<<<<<<<<<<<<<
 *         solveStep(TS_(ts), <double>t, Vec_(x))
 *         return FunctionEnd()
 */
  __pyx_t_3 = (__pyx_v_solveStep != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2465
 *     cdef solveStep = PyTS(ts).solveStep
 *     if solveStep is not None:
 *         solveStep(TS_(ts), <double>t, Vec_(x))             # <<<<<<<<<<<<<<
 *         return FunctionEnd()
 *     #
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyFloat_FromDouble(((double)__pyx_v_t)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_solveStep);
    __pyx_t_7 = __pyx_v_solveStep; __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    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_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2465, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, __pyx_t_5, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2465, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2465, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2465, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libpetsc4py.pyx":2466
 *     if solveStep is not None:
 *         solveStep(TS_(ts), <double>t, Vec_(x))
 *         return FunctionEnd()             # <<<<<<<<<<<<<<
 *     #
 *     cdef PetscInt nits = 0, lits = 0
 */
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;

    /* "libpetsc4py.pyx":2464
 *     #
 *     cdef solveStep = PyTS(ts).solveStep
 *     if solveStep is not None:             # <<<<<<<<<<<<<<
 *         solveStep(TS_(ts), <double>t, Vec_(x))
 *         return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":2468
 *         return FunctionEnd()
 *     #
 *     cdef PetscInt nits = 0, lits = 0             # <<<<<<<<<<<<<<
 *     CHKERR( SNESSolve(ts.snes, NULL, x) )
 *     CHKERR( SNESGetIterationNumber(ts.snes,&nits) )
 */
  __pyx_v_nits = 0;
  __pyx_v_lits = 0;

  /* "libpetsc4py.pyx":2469
 *     #
 *     cdef PetscInt nits = 0, lits = 0
 *     CHKERR( SNESSolve(ts.snes, NULL, x) )             # <<<<<<<<<<<<<<
 *     CHKERR( SNESGetIterationNumber(ts.snes,&nits) )
 *     CHKERR( SNESGetLinearSolveIterations(ts.snes,&lits) )
 */
  __pyx_t_9 = __pyx_f_11libpetsc4py_CHKERR(SNESSolve(__pyx_v_ts->snes, NULL, __pyx_v_x)); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 2469, __pyx_L1_error)

  /* "libpetsc4py.pyx":2470
 *     cdef PetscInt nits = 0, lits = 0
 *     CHKERR( SNESSolve(ts.snes, NULL, x) )
 *     CHKERR( SNESGetIterationNumber(ts.snes,&nits) )             # <<<<<<<<<<<<<<
 *     CHKERR( SNESGetLinearSolveIterations(ts.snes,&lits) )
 *     ts.snes_its += nits
 */
  __pyx_t_9 = __pyx_f_11libpetsc4py_CHKERR(SNESGetIterationNumber(__pyx_v_ts->snes, (&__pyx_v_nits))); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 2470, __pyx_L1_error)

  /* "libpetsc4py.pyx":2471
 *     CHKERR( SNESSolve(ts.snes, NULL, x) )
 *     CHKERR( SNESGetIterationNumber(ts.snes,&nits) )
 *     CHKERR( SNESGetLinearSolveIterations(ts.snes,&lits) )             # <<<<<<<<<<<<<<
 *     ts.snes_its += nits
 *     ts.ksp_its  += lits
 */
  __pyx_t_9 = __pyx_f_11libpetsc4py_CHKERR(SNESGetLinearSolveIterations(__pyx_v_ts->snes, (&__pyx_v_lits))); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 2471, __pyx_L1_error)

  /* "libpetsc4py.pyx":2472
 *     CHKERR( SNESGetIterationNumber(ts.snes,&nits) )
 *     CHKERR( SNESGetLinearSolveIterations(ts.snes,&lits) )
 *     ts.snes_its += nits             # <<<<<<<<<<<<<<
 *     ts.ksp_its  += lits
 *     return FunctionEnd()
 */
  __pyx_v_ts->snes_its = (__pyx_v_ts->snes_its + __pyx_v_nits);

  /* "libpetsc4py.pyx":2473
 *     CHKERR( SNESGetLinearSolveIterations(ts.snes,&lits) )
 *     ts.snes_its += nits
 *     ts.ksp_its  += lits             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
  __pyx_v_ts->ksp_its = (__pyx_v_ts->ksp_its + __pyx_v_lits);

  /* "libpetsc4py.pyx":2474
 *     ts.snes_its += nits
 *     ts.ksp_its  += lits
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSAdaptStep_Python(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2455
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSSolveStep_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     PetscReal t,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libpetsc4py.TSSolveStep_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_solveStep);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2476
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSAdaptStep_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     PetscReal t,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSAdaptStep_Python(TS __pyx_v_ts, PetscReal __pyx_v_t, Vec __pyx_v_x, PetscReal *__pyx_v_nextdt, PetscBool *__pyx_v_stepok) {
  PyObject *__pyx_v_adaptStep = 0;
  PyObject *__pyx_v_retval = 0;
  double __pyx_v_dt;
  int __pyx_v_ok;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  PetscReal __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  double __pyx_t_12;
  PetscBool __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSAdaptStep_Python", 0);

  /* "libpetsc4py.pyx":2484
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSAdaptStep_Python")             # <<<<<<<<<<<<<<
 *     nextdt[0] = ts.time_step
 *     stepok[0] = PETSC_TRUE
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSAdaptStep_Python"));

  /* "libpetsc4py.pyx":2485
 *     except IERR with gil:
 *     FunctionBegin(b"TSAdaptStep_Python")
 *     nextdt[0] = ts.time_step             # <<<<<<<<<<<<<<
 *     stepok[0] = PETSC_TRUE
 *     #
 */
  __pyx_t_1 = __pyx_v_ts->time_step;
  (__pyx_v_nextdt[0]) = __pyx_t_1;

  /* "libpetsc4py.pyx":2486
 *     FunctionBegin(b"TSAdaptStep_Python")
 *     nextdt[0] = ts.time_step
 *     stepok[0] = PETSC_TRUE             # <<<<<<<<<<<<<<
 *     #
 *     cdef adaptStep = PyTS(ts).adaptStep
 */
  (__pyx_v_stepok[0]) = PETSC_TRUE;

  /* "libpetsc4py.pyx":2488
 *     stepok[0] = PETSC_TRUE
 *     #
 *     cdef adaptStep = PyTS(ts).adaptStep             # <<<<<<<<<<<<<<
 *     if adaptStep is None: return FunctionEnd()
 *     cdef object retval
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_PyTS(__pyx_v_ts)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_adaptStep); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_adaptStep = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":2489
 *     #
 *     cdef adaptStep = PyTS(ts).adaptStep
 *     if adaptStep is None: return FunctionEnd()             # <<<<<<<<<<<<<<
 *     cdef object retval
 *     cdef double dt
 */
  __pyx_t_4 = (__pyx_v_adaptStep == Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {
    __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
    goto __pyx_L0;
  }

  /* "libpetsc4py.pyx":2493
 *     cdef double dt
 *     cdef bint   ok
 *     retval = adaptStep(TS_(ts), <double>t, Vec_(x))             # <<<<<<<<<<<<<<
 *     if retval is None: pass
 *     elif isinstance(retval, float):
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_11libpetsc4py_TS_(__pyx_v_ts)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyFloat_FromDouble(((double)__pyx_v_t)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((PyObject *)__pyx_f_11libpetsc4py_Vec_(__pyx_v_x)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_adaptStep);
  __pyx_t_8 = __pyx_v_adaptStep; __pyx_t_9 = NULL;
  __pyx_t_10 = 0;
  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_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_2, __pyx_t_6, __pyx_t_7};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2493, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_2, __pyx_t_6, __pyx_t_7};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2493, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2493, __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_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_7);
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_retval = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":2494
 *     cdef bint   ok
 *     retval = adaptStep(TS_(ts), <double>t, Vec_(x))
 *     if retval is None: pass             # <<<<<<<<<<<<<<
 *     elif isinstance(retval, float):
 *         dt = retval
 */
  __pyx_t_5 = (__pyx_v_retval == Py_None);
  __pyx_t_4 = (__pyx_t_5 != 0);
  if (__pyx_t_4) {
    goto __pyx_L4;
  }

  /* "libpetsc4py.pyx":2495
 *     retval = adaptStep(TS_(ts), <double>t, Vec_(x))
 *     if retval is None: pass
 *     elif isinstance(retval, float):             # <<<<<<<<<<<<<<
 *         dt = retval
 *         nextdt[0] = <PetscReal>dt
 */
  __pyx_t_4 = PyFloat_Check(__pyx_v_retval); 
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":2496
 *     if retval is None: pass
 *     elif isinstance(retval, float):
 *         dt = retval             # <<<<<<<<<<<<<<
 *         nextdt[0] = <PetscReal>dt
 *         stepok[0] = PETSC_TRUE
 */
    __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_retval); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2496, __pyx_L1_error)
    __pyx_v_dt = __pyx_t_12;

    /* "libpetsc4py.pyx":2497
 *     elif isinstance(retval, float):
 *         dt = retval
 *         nextdt[0] = <PetscReal>dt             # <<<<<<<<<<<<<<
 *         stepok[0] = PETSC_TRUE
 *     elif isinstance(retval, bool):
 */
    (__pyx_v_nextdt[0]) = ((PetscReal)__pyx_v_dt);

    /* "libpetsc4py.pyx":2498
 *         dt = retval
 *         nextdt[0] = <PetscReal>dt
 *         stepok[0] = PETSC_TRUE             # <<<<<<<<<<<<<<
 *     elif isinstance(retval, bool):
 *         ok = retval
 */
    (__pyx_v_stepok[0]) = PETSC_TRUE;

    /* "libpetsc4py.pyx":2495
 *     retval = adaptStep(TS_(ts), <double>t, Vec_(x))
 *     if retval is None: pass
 *     elif isinstance(retval, float):             # <<<<<<<<<<<<<<
 *         dt = retval
 *         nextdt[0] = <PetscReal>dt
 */
    goto __pyx_L4;
  }

  /* "libpetsc4py.pyx":2499
 *         nextdt[0] = <PetscReal>dt
 *         stepok[0] = PETSC_TRUE
 *     elif isinstance(retval, bool):             # <<<<<<<<<<<<<<
 *         ok = retval
 *         nextdt[0] = ts.time_step
 */
  __pyx_t_3 = ((PyObject*)&PyBool_Type);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = PyObject_IsInstance(__pyx_v_retval, __pyx_t_3); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 2499, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = (__pyx_t_5 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2500
 *         stepok[0] = PETSC_TRUE
 *     elif isinstance(retval, bool):
 *         ok = retval             # <<<<<<<<<<<<<<
 *         nextdt[0] = ts.time_step
 *         stepok[0] = PETSC_TRUE if ok else PETSC_FALSE
 */
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_retval); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2500, __pyx_L1_error)
    __pyx_v_ok = __pyx_t_4;

    /* "libpetsc4py.pyx":2501
 *     elif isinstance(retval, bool):
 *         ok = retval
 *         nextdt[0] = ts.time_step             # <<<<<<<<<<<<<<
 *         stepok[0] = PETSC_TRUE if ok else PETSC_FALSE
 *     else:
 */
    __pyx_t_1 = __pyx_v_ts->time_step;
    (__pyx_v_nextdt[0]) = __pyx_t_1;

    /* "libpetsc4py.pyx":2502
 *         ok = retval
 *         nextdt[0] = ts.time_step
 *         stepok[0] = PETSC_TRUE if ok else PETSC_FALSE             # <<<<<<<<<<<<<<
 *     else:
 *         dt, ok = retval
 */
    if ((__pyx_v_ok != 0)) {
      __pyx_t_13 = PETSC_TRUE;
    } else {
      __pyx_t_13 = PETSC_FALSE;
    }
    (__pyx_v_stepok[0]) = __pyx_t_13;

    /* "libpetsc4py.pyx":2499
 *         nextdt[0] = <PetscReal>dt
 *         stepok[0] = PETSC_TRUE
 *     elif isinstance(retval, bool):             # <<<<<<<<<<<<<<
 *         ok = retval
 *         nextdt[0] = ts.time_step
 */
    goto __pyx_L4;
  }

  /* "libpetsc4py.pyx":2504
 *         stepok[0] = PETSC_TRUE if ok else PETSC_FALSE
 *     else:
 *         dt, ok = retval             # <<<<<<<<<<<<<<
 *         nextdt[0] = <PetscReal>dt
 *         stepok[0] = PETSC_TRUE if ok else PETSC_FALSE
 */
  /*else*/ {
    if ((likely(PyTuple_CheckExact(__pyx_v_retval))) || (PyList_CheckExact(__pyx_v_retval))) {
      PyObject* sequence = __pyx_v_retval;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 2504, __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_8 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_8);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2504, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2504, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      #endif
    } else {
      Py_ssize_t index = -1;
      __pyx_t_11 = PyObject_GetIter(__pyx_v_retval); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2504, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_14 = Py_TYPE(__pyx_t_11)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_14(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_8 = __pyx_t_14(__pyx_t_11); if (unlikely(!__pyx_t_8)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_11), 2) < 0) __PYX_ERR(0, 2504, __pyx_L1_error)
      __pyx_t_14 = NULL;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_14 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 2504, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2504, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2504, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_v_dt = __pyx_t_12;
    __pyx_v_ok = __pyx_t_4;

    /* "libpetsc4py.pyx":2505
 *     else:
 *         dt, ok = retval
 *         nextdt[0] = <PetscReal>dt             # <<<<<<<<<<<<<<
 *         stepok[0] = PETSC_TRUE if ok else PETSC_FALSE
 *     return FunctionEnd()
 */
    (__pyx_v_nextdt[0]) = ((PetscReal)__pyx_v_dt);

    /* "libpetsc4py.pyx":2506
 *         dt, ok = retval
 *         nextdt[0] = <PetscReal>dt
 *         stepok[0] = PETSC_TRUE if ok else PETSC_FALSE             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    if ((__pyx_v_ok != 0)) {
      __pyx_t_13 = PETSC_TRUE;
    } else {
      __pyx_t_13 = PETSC_FALSE;
    }
    (__pyx_v_stepok[0]) = __pyx_t_13;
  }
  __pyx_L4:;

  /* "libpetsc4py.pyx":2507
 *         nextdt[0] = <PetscReal>dt
 *         stepok[0] = PETSC_TRUE if ok else PETSC_FALSE
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * cdef PetscErrorCode TSStep_Python_default(
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2476
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSAdaptStep_Python(             # <<<<<<<<<<<<<<
 *     PetscTS   ts,
 *     PetscReal t,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("libpetsc4py.TSAdaptStep_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_adaptStep);
  __Pyx_XDECREF(__pyx_v_retval);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2509
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSStep_Python_default(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     ) \
 */

static PetscErrorCode __pyx_f_11libpetsc4py_TSStep_Python_default(TS __pyx_v_ts) {
  Vec __pyx_v_vec_update;
  CYTHON_UNUSED PetscInt __pyx_v_r;
  PetscReal __pyx_v_tt;
  PetscReal __pyx_v_dt;
  PetscBool __pyx_v_accept;
  PetscBool __pyx_v_stageok;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PetscReal __pyx_t_2;
  PetscInt __pyx_t_3;
  PetscErrorCode __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("TSStep_Python_default", 0);

  /* "libpetsc4py.pyx":2513
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"TSStep_Python_default")             # <<<<<<<<<<<<<<
 *     cdef PetscVec vec_update = NULL
 *     CHKERR( PetscObjectQuery(
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"TSStep_Python_default"));

  /* "libpetsc4py.pyx":2514
 *     except IERR with gil:
 *     FunctionBegin(b"TSStep_Python_default")
 *     cdef PetscVec vec_update = NULL             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectQuery(
 *             <PetscObject>ts,
 */
  __pyx_v_vec_update = NULL;

  /* "libpetsc4py.pyx":2515
 *     FunctionBegin(b"TSStep_Python_default")
 *     cdef PetscVec vec_update = NULL
 *     CHKERR( PetscObjectQuery(             # <<<<<<<<<<<<<<
 *             <PetscObject>ts,
 *              b"@ts.vec_update",
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectQuery(((PetscObject)__pyx_v_ts), ((char *)"@ts.vec_update"), ((PetscObject *)(&__pyx_v_vec_update)))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2515, __pyx_L1_error)

  /* "libpetsc4py.pyx":2520
 *              <PetscObject*>&vec_update) )
 *     #
 *     cdef PetscInt  r = 0             # <<<<<<<<<<<<<<
 *     cdef PetscReal tt = ts.ptime
 *     cdef PetscReal dt = ts.time_step
 */
  __pyx_v_r = 0;

  /* "libpetsc4py.pyx":2521
 *     #
 *     cdef PetscInt  r = 0
 *     cdef PetscReal tt = ts.ptime             # <<<<<<<<<<<<<<
 *     cdef PetscReal dt = ts.time_step
 *     cdef PetscBool accept  = PETSC_TRUE
 */
  __pyx_t_2 = __pyx_v_ts->ptime;
  __pyx_v_tt = __pyx_t_2;

  /* "libpetsc4py.pyx":2522
 *     cdef PetscInt  r = 0
 *     cdef PetscReal tt = ts.ptime
 *     cdef PetscReal dt = ts.time_step             # <<<<<<<<<<<<<<
 *     cdef PetscBool accept  = PETSC_TRUE
 *     cdef PetscBool stageok = PETSC_TRUE
 */
  __pyx_t_2 = __pyx_v_ts->time_step;
  __pyx_v_dt = __pyx_t_2;

  /* "libpetsc4py.pyx":2523
 *     cdef PetscReal tt = ts.ptime
 *     cdef PetscReal dt = ts.time_step
 *     cdef PetscBool accept  = PETSC_TRUE             # <<<<<<<<<<<<<<
 *     cdef PetscBool stageok = PETSC_TRUE
 *     for r from 0 <= r < ts.max_reject:
 */
  __pyx_v_accept = PETSC_TRUE;

  /* "libpetsc4py.pyx":2524
 *     cdef PetscReal dt = ts.time_step
 *     cdef PetscBool accept  = PETSC_TRUE
 *     cdef PetscBool stageok = PETSC_TRUE             # <<<<<<<<<<<<<<
 *     for r from 0 <= r < ts.max_reject:
 *         tt = ts.ptime + ts.time_step
 */
  __pyx_v_stageok = PETSC_TRUE;

  /* "libpetsc4py.pyx":2525
 *     cdef PetscBool accept  = PETSC_TRUE
 *     cdef PetscBool stageok = PETSC_TRUE
 *     for r from 0 <= r < ts.max_reject:             # <<<<<<<<<<<<<<
 *         tt = ts.ptime + ts.time_step
 *         CHKERR( VecCopy(ts.vec_sol,vec_update) )
 */
  __pyx_t_3 = __pyx_v_ts->max_reject;
  for (__pyx_v_r = 0; __pyx_v_r < __pyx_t_3; __pyx_v_r++) {

    /* "libpetsc4py.pyx":2526
 *     cdef PetscBool stageok = PETSC_TRUE
 *     for r from 0 <= r < ts.max_reject:
 *         tt = ts.ptime + ts.time_step             # <<<<<<<<<<<<<<
 *         CHKERR( VecCopy(ts.vec_sol,vec_update) )
 *         CHKERR( TSPreStage(ts,tt+dt) )
 */
    __pyx_v_tt = (__pyx_v_ts->ptime + __pyx_v_ts->time_step);

    /* "libpetsc4py.pyx":2527
 *     for r from 0 <= r < ts.max_reject:
 *         tt = ts.ptime + ts.time_step
 *         CHKERR( VecCopy(ts.vec_sol,vec_update) )             # <<<<<<<<<<<<<<
 *         CHKERR( TSPreStage(ts,tt+dt) )
 *         TSSolveStep_Python(ts,tt,vec_update)
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecCopy(__pyx_v_ts->vec_sol, __pyx_v_vec_update)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2527, __pyx_L1_error)

    /* "libpetsc4py.pyx":2528
 *         tt = ts.ptime + ts.time_step
 *         CHKERR( VecCopy(ts.vec_sol,vec_update) )
 *         CHKERR( TSPreStage(ts,tt+dt) )             # <<<<<<<<<<<<<<
 *         TSSolveStep_Python(ts,tt,vec_update)
 *         CHKERR( TSPostStage(ts,tt+dt,0,&vec_update) );
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(TSPreStage(__pyx_v_ts, (__pyx_v_tt + __pyx_v_dt))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2528, __pyx_L1_error)

    /* "libpetsc4py.pyx":2529
 *         CHKERR( VecCopy(ts.vec_sol,vec_update) )
 *         CHKERR( TSPreStage(ts,tt+dt) )
 *         TSSolveStep_Python(ts,tt,vec_update)             # <<<<<<<<<<<<<<
 *         CHKERR( TSPostStage(ts,tt+dt,0,&vec_update) );
 *         CHKERR( TSAdaptCheckStage(ts.adapt,ts,tt+dt,vec_update,&stageok) );
 */
    __pyx_t_4 = __pyx_f_11libpetsc4py_TSSolveStep_Python(__pyx_v_ts, __pyx_v_tt, __pyx_v_vec_update); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2529, __pyx_L1_error)

    /* "libpetsc4py.pyx":2530
 *         CHKERR( TSPreStage(ts,tt+dt) )
 *         TSSolveStep_Python(ts,tt,vec_update)
 *         CHKERR( TSPostStage(ts,tt+dt,0,&vec_update) );             # <<<<<<<<<<<<<<
 *         CHKERR( TSAdaptCheckStage(ts.adapt,ts,tt+dt,vec_update,&stageok) );
 *         if not stageok:
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(TSPostStage(__pyx_v_ts, (__pyx_v_tt + __pyx_v_dt), 0, (&__pyx_v_vec_update))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2530, __pyx_L1_error)

    /* "libpetsc4py.pyx":2531
 *         TSSolveStep_Python(ts,tt,vec_update)
 *         CHKERR( TSPostStage(ts,tt+dt,0,&vec_update) );
 *         CHKERR( TSAdaptCheckStage(ts.adapt,ts,tt+dt,vec_update,&stageok) );             # <<<<<<<<<<<<<<
 *         if not stageok:
 *             ts.reject += 1
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(TSAdaptCheckStage(__pyx_v_ts->adapt, __pyx_v_ts, (__pyx_v_tt + __pyx_v_dt), __pyx_v_vec_update, (&__pyx_v_stageok))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2531, __pyx_L1_error)

    /* "libpetsc4py.pyx":2532
 *         CHKERR( TSPostStage(ts,tt+dt,0,&vec_update) );
 *         CHKERR( TSAdaptCheckStage(ts.adapt,ts,tt+dt,vec_update,&stageok) );
 *         if not stageok:             # <<<<<<<<<<<<<<
 *             ts.reject += 1
 *             continue
 */
    __pyx_t_5 = ((!__pyx_v_stageok) != 0);
    if (__pyx_t_5) {

      /* "libpetsc4py.pyx":2533
 *         CHKERR( TSAdaptCheckStage(ts.adapt,ts,tt+dt,vec_update,&stageok) );
 *         if not stageok:
 *             ts.reject += 1             # <<<<<<<<<<<<<<
 *             continue
 *         TSAdaptStep_Python(ts,tt,vec_update,&dt,&accept)
 */
      __pyx_v_ts->reject = (__pyx_v_ts->reject + 1);

      /* "libpetsc4py.pyx":2534
 *         if not stageok:
 *             ts.reject += 1
 *             continue             # <<<<<<<<<<<<<<
 *         TSAdaptStep_Python(ts,tt,vec_update,&dt,&accept)
 *         if not accept:
 */
      goto __pyx_L3_continue;

      /* "libpetsc4py.pyx":2532
 *         CHKERR( TSPostStage(ts,tt+dt,0,&vec_update) );
 *         CHKERR( TSAdaptCheckStage(ts.adapt,ts,tt+dt,vec_update,&stageok) );
 *         if not stageok:             # <<<<<<<<<<<<<<
 *             ts.reject += 1
 *             continue
 */
    }

    /* "libpetsc4py.pyx":2535
 *             ts.reject += 1
 *             continue
 *         TSAdaptStep_Python(ts,tt,vec_update,&dt,&accept)             # <<<<<<<<<<<<<<
 *         if not accept:
 *             ts.time_step = dt
 */
    __pyx_t_4 = __pyx_f_11libpetsc4py_TSAdaptStep_Python(__pyx_v_ts, __pyx_v_tt, __pyx_v_vec_update, (&__pyx_v_dt), (&__pyx_v_accept)); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2535, __pyx_L1_error)

    /* "libpetsc4py.pyx":2536
 *             continue
 *         TSAdaptStep_Python(ts,tt,vec_update,&dt,&accept)
 *         if not accept:             # <<<<<<<<<<<<<<
 *             ts.time_step = dt
 *             ts.reject += 1
 */
    __pyx_t_5 = ((!__pyx_v_accept) != 0);
    if (__pyx_t_5) {

      /* "libpetsc4py.pyx":2537
 *         TSAdaptStep_Python(ts,tt,vec_update,&dt,&accept)
 *         if not accept:
 *             ts.time_step = dt             # <<<<<<<<<<<<<<
 *             ts.reject += 1
 *             continue
 */
      __pyx_v_ts->time_step = __pyx_v_dt;

      /* "libpetsc4py.pyx":2538
 *         if not accept:
 *             ts.time_step = dt
 *             ts.reject += 1             # <<<<<<<<<<<<<<
 *             continue
 *         CHKERR( VecCopy(vec_update,ts.vec_sol) )
 */
      __pyx_v_ts->reject = (__pyx_v_ts->reject + 1);

      /* "libpetsc4py.pyx":2539
 *             ts.time_step = dt
 *             ts.reject += 1
 *             continue             # <<<<<<<<<<<<<<
 *         CHKERR( VecCopy(vec_update,ts.vec_sol) )
 *         ts.ptime += ts.time_step
 */
      goto __pyx_L3_continue;

      /* "libpetsc4py.pyx":2536
 *             continue
 *         TSAdaptStep_Python(ts,tt,vec_update,&dt,&accept)
 *         if not accept:             # <<<<<<<<<<<<<<
 *             ts.time_step = dt
 *             ts.reject += 1
 */
    }

    /* "libpetsc4py.pyx":2540
 *             ts.reject += 1
 *             continue
 *         CHKERR( VecCopy(vec_update,ts.vec_sol) )             # <<<<<<<<<<<<<<
 *         ts.ptime += ts.time_step
 *         ts.time_step = dt
 */
    __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(VecCopy(__pyx_v_vec_update, __pyx_v_ts->vec_sol)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2540, __pyx_L1_error)

    /* "libpetsc4py.pyx":2541
 *             continue
 *         CHKERR( VecCopy(vec_update,ts.vec_sol) )
 *         ts.ptime += ts.time_step             # <<<<<<<<<<<<<<
 *         ts.time_step = dt
 *         break
 */
    __pyx_v_ts->ptime = (__pyx_v_ts->ptime + __pyx_v_ts->time_step);

    /* "libpetsc4py.pyx":2542
 *         CHKERR( VecCopy(vec_update,ts.vec_sol) )
 *         ts.ptime += ts.time_step
 *         ts.time_step = dt             # <<<<<<<<<<<<<<
 *         break
 *     if (not stageok or not accept) and ts.reason == 0:
 */
    __pyx_v_ts->time_step = __pyx_v_dt;

    /* "libpetsc4py.pyx":2543
 *         ts.ptime += ts.time_step
 *         ts.time_step = dt
 *         break             # <<<<<<<<<<<<<<
 *     if (not stageok or not accept) and ts.reason == 0:
 *         ts.reason = TS_DIVERGED_STEP_REJECTED
 */
    goto __pyx_L4_break;
    __pyx_L3_continue:;
  }
  __pyx_L4_break:;

  /* "libpetsc4py.pyx":2544
 *         ts.time_step = dt
 *         break
 *     if (not stageok or not accept) and ts.reason == 0:             # <<<<<<<<<<<<<<
 *         ts.reason = TS_DIVERGED_STEP_REJECTED
 *     return FunctionEnd()
 */
  __pyx_t_6 = ((!__pyx_v_stageok) != 0);
  if (!__pyx_t_6) {
  } else {
    goto __pyx_L9_next_and;
  }
  __pyx_t_6 = ((!__pyx_v_accept) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_5 = __pyx_t_6;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_L9_next_and:;
  __pyx_t_6 = ((__pyx_v_ts->reason == 0) != 0);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_5) {

    /* "libpetsc4py.pyx":2545
 *         break
 *     if (not stageok or not accept) and ts.reason == 0:
 *         ts.reason = TS_DIVERGED_STEP_REJECTED             # <<<<<<<<<<<<<<
 *     return FunctionEnd()
 * 
 */
    __pyx_v_ts->reason = TS_DIVERGED_STEP_REJECTED;

    /* "libpetsc4py.pyx":2544
 *         ts.time_step = dt
 *         break
 *     if (not stageok or not accept) and ts.reason == 0:             # <<<<<<<<<<<<<<
 *         ts.reason = TS_DIVERGED_STEP_REJECTED
 *     return FunctionEnd()
 */
  }

  /* "libpetsc4py.pyx":2546
 *     if (not stageok or not accept) and ts.reason == 0:
 *         ts.reason = TS_DIVERGED_STEP_REJECTED
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2509
 *     return FunctionEnd()
 * 
 * cdef PetscErrorCode TSStep_Python_default(             # <<<<<<<<<<<<<<
 *     PetscTS ts,
 *     ) \
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.TSStep_Python_default", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2550
 * # --------------------------------------------------------------------
 * 
 * cdef PetscErrorCode PetscPythonMonitorSet_Python(             # <<<<<<<<<<<<<<
 *     PetscObject obj_p,
 *     const char *url_p,
 */

static PetscErrorCode __pyx_f_11libpetsc4py_PetscPythonMonitorSet_Python(PetscObject __pyx_v_obj_p, char const *__pyx_v_url_p) {
  PetscClassId __pyx_v_classid;
  PyTypeObject *__pyx_v_klass = 0;
  struct PyPetscObjectObject *__pyx_v_ob = 0;
  PyObject *__pyx_v_url = 0;
  PyObject *__pyx_v_path = NULL;
  PyObject *__pyx_v_names = NULL;
  PyObject *__pyx_v_module = NULL;
  PyObject *__pyx_v_attr = NULL;
  PyObject *__pyx_v_monitor = NULL;
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  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)(PyObject *);
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("PetscPythonMonitorSet_Python", 0);

  /* "libpetsc4py.pyx":2555
 *     ) \
 *     except IERR with gil:
 *     FunctionBegin(b"PetscPythonMonitorSet_Python")             # <<<<<<<<<<<<<<
 *     assert obj_p != NULL
 *     assert url_p != NULL
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PetscPythonMonitorSet_Python"));

  /* "libpetsc4py.pyx":2556
 *     except IERR with gil:
 *     FunctionBegin(b"PetscPythonMonitorSet_Python")
 *     assert obj_p != NULL             # <<<<<<<<<<<<<<
 *     assert url_p != NULL
 *     assert url_p[0] != 0
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_obj_p != NULL) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 2556, __pyx_L1_error)
    }
  }
  #endif

  /* "libpetsc4py.pyx":2557
 *     FunctionBegin(b"PetscPythonMonitorSet_Python")
 *     assert obj_p != NULL
 *     assert url_p != NULL             # <<<<<<<<<<<<<<
 *     assert url_p[0] != 0
 *     #
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_url_p != NULL) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 2557, __pyx_L1_error)
    }
  }
  #endif

  /* "libpetsc4py.pyx":2558
 *     assert obj_p != NULL
 *     assert url_p != NULL
 *     assert url_p[0] != 0             # <<<<<<<<<<<<<<
 *     #
 *     cdef PetscClassId classid = 0
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!(((__pyx_v_url_p[0]) != 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 2558, __pyx_L1_error)
    }
  }
  #endif

  /* "libpetsc4py.pyx":2560
 *     assert url_p[0] != 0
 *     #
 *     cdef PetscClassId classid = 0             # <<<<<<<<<<<<<<
 *     CHKERR( PetscObjectGetClassId(obj_p,&classid) )
 *     cdef type klass = PyPetscType_Lookup(classid)
 */
  __pyx_v_classid = 0;

  /* "libpetsc4py.pyx":2561
 *     #
 *     cdef PetscClassId classid = 0
 *     CHKERR( PetscObjectGetClassId(obj_p,&classid) )             # <<<<<<<<<<<<<<
 *     cdef type klass = PyPetscType_Lookup(classid)
 *     cdef Object ob = klass()
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PetscObjectGetClassId(__pyx_v_obj_p, (&__pyx_v_classid))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2561, __pyx_L1_error)

  /* "libpetsc4py.pyx":2562
 *     cdef PetscClassId classid = 0
 *     CHKERR( PetscObjectGetClassId(obj_p,&classid) )
 *     cdef type klass = PyPetscType_Lookup(classid)             # <<<<<<<<<<<<<<
 *     cdef Object ob = klass()
 *     ob.obj[0] = newRef(obj_p)
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_8petsc4py_5PETSc_PyPetscType_Lookup(__pyx_v_classid)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_klass = ((PyTypeObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2563
 *     CHKERR( PetscObjectGetClassId(obj_p,&classid) )
 *     cdef type klass = PyPetscType_Lookup(classid)
 *     cdef Object ob = klass()             # <<<<<<<<<<<<<<
 *     ob.obj[0] = newRef(obj_p)
 *     #
 */
  __pyx_t_2 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_v_klass)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_8petsc4py_5PETSc_Object))))) __PYX_ERR(0, 2563, __pyx_L1_error)
  __pyx_v_ob = ((struct PyPetscObjectObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2564
 *     cdef type klass = PyPetscType_Lookup(classid)
 *     cdef Object ob = klass()
 *     ob.obj[0] = newRef(obj_p)             # <<<<<<<<<<<<<<
 *     #
 *     cdef url = bytes2str(url_p)
 */
  (__pyx_v_ob->obj[0]) = __pyx_f_11libpetsc4py_newRef(__pyx_v_obj_p);

  /* "libpetsc4py.pyx":2566
 *     ob.obj[0] = newRef(obj_p)
 *     #
 *     cdef url = bytes2str(url_p)             # <<<<<<<<<<<<<<
 *     if ':' in url:
 *         path, names = parse_url(url)
 */
  __pyx_t_2 = __pyx_f_11libpetsc4py_bytes2str(__pyx_v_url_p); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_url = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2567
 *     #
 *     cdef url = bytes2str(url_p)
 *     if ':' in url:             # <<<<<<<<<<<<<<
 *         path, names = parse_url(url)
 *     else:
 */
  __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_kp_s_, __pyx_v_url, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2567, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "libpetsc4py.pyx":2568
 *     cdef url = bytes2str(url_p)
 *     if ':' in url:
 *         path, names = parse_url(url)             # <<<<<<<<<<<<<<
 *     else:
 *         path, names = url, 'monitor'
 */
    __pyx_t_2 = __pyx_f_11libpetsc4py_parse_url(__pyx_v_url); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 2568, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 2568, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L5_unpacking_done;
      __pyx_L4_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 2568, __pyx_L1_error)
      __pyx_L5_unpacking_done:;
    }
    __pyx_v_path = __pyx_t_5;
    __pyx_t_5 = 0;
    __pyx_v_names = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "libpetsc4py.pyx":2567
 *     #
 *     cdef url = bytes2str(url_p)
 *     if ':' in url:             # <<<<<<<<<<<<<<
 *         path, names = parse_url(url)
 *     else:
 */
    goto __pyx_L3;
  }

  /* "libpetsc4py.pyx":2570
 *         path, names = parse_url(url)
 *     else:
 *         path, names = url, 'monitor'             # <<<<<<<<<<<<<<
 *     module = load_module(path)
 *     for attr in names.split(','):
 */
  /*else*/ {
    __pyx_t_2 = __pyx_v_url;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = __pyx_n_s_monitor;
    __Pyx_INCREF(__pyx_t_6);
    __pyx_v_path = __pyx_t_2;
    __pyx_t_2 = 0;
    __pyx_v_names = __pyx_t_6;
    __pyx_t_6 = 0;
  }
  __pyx_L3:;

  /* "libpetsc4py.pyx":2571
 *     else:
 *         path, names = url, 'monitor'
 *     module = load_module(path)             # <<<<<<<<<<<<<<
 *     for attr in names.split(','):
 *         monitor = getattr(module, attr)
 */
  __pyx_t_6 = __pyx_f_11libpetsc4py_load_module(__pyx_v_path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_module = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "libpetsc4py.pyx":2572
 *         path, names = url, 'monitor'
 *     module = load_module(path)
 *     for attr in names.split(','):             # <<<<<<<<<<<<<<
 *         monitor = getattr(module, attr)
 *         if isinstance(monitor, type):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_names, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  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 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_kp_s__5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s__5);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
    __pyx_t_2 = __pyx_t_6; __Pyx_INCREF(__pyx_t_2); __pyx_t_9 = 0;
    __pyx_t_10 = NULL;
  } else {
    __pyx_t_9 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_10 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2572, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  for (;;) {
    if (likely(!__pyx_t_10)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 2572, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2572, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 2572, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2572, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_10(__pyx_t_2);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2572, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_attr, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "libpetsc4py.pyx":2573
 *     module = load_module(path)
 *     for attr in names.split(','):
 *         monitor = getattr(module, attr)             # <<<<<<<<<<<<<<
 *         if isinstance(monitor, type):
 *             monitor = monitor(ob)
 */
    __pyx_t_6 = __Pyx_GetAttr(__pyx_v_module, __pyx_v_attr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF_SET(__pyx_v_monitor, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "libpetsc4py.pyx":2574
 *     for attr in names.split(','):
 *         monitor = getattr(module, attr)
 *         if isinstance(monitor, type):             # <<<<<<<<<<<<<<
 *             monitor = monitor(ob)
 *         ob.setMonitor(monitor)
 */
    __pyx_t_4 = PyType_Check(__pyx_v_monitor); 
    __pyx_t_3 = (__pyx_t_4 != 0);
    if (__pyx_t_3) {

      /* "libpetsc4py.pyx":2575
 *         monitor = getattr(module, attr)
 *         if isinstance(monitor, type):
 *             monitor = monitor(ob)             # <<<<<<<<<<<<<<
 *         ob.setMonitor(monitor)
 *     #
 */
      __Pyx_INCREF(__pyx_v_monitor);
      __pyx_t_5 = __pyx_v_monitor; __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_6 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, ((PyObject *)__pyx_v_ob)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_ob));
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF_SET(__pyx_v_monitor, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "libpetsc4py.pyx":2574
 *     for attr in names.split(','):
 *         monitor = getattr(module, attr)
 *         if isinstance(monitor, type):             # <<<<<<<<<<<<<<
 *             monitor = monitor(ob)
 *         ob.setMonitor(monitor)
 */
    }

    /* "libpetsc4py.pyx":2576
 *         if isinstance(monitor, type):
 *             monitor = monitor(ob)
 *         ob.setMonitor(monitor)             # <<<<<<<<<<<<<<
 *     #
 *     return FunctionEnd()
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ob), __pyx_n_s_setMonitor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2576, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_6 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_v_monitor) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_monitor);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2576, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "libpetsc4py.pyx":2572
 *         path, names = url, 'monitor'
 *     module = load_module(path)
 *     for attr in names.split(','):             # <<<<<<<<<<<<<<
 *         monitor = getattr(module, attr)
 *         if isinstance(monitor, type):
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":2578
 *         ob.setMonitor(monitor)
 *     #
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2550
 * # --------------------------------------------------------------------
 * 
 * cdef PetscErrorCode PetscPythonMonitorSet_Python(             # <<<<<<<<<<<<<<
 *     PetscObject obj_p,
 *     const char *url_p,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libpetsc4py.PetscPythonMonitorSet_Python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_klass);
  __Pyx_XDECREF((PyObject *)__pyx_v_ob);
  __Pyx_XDECREF(__pyx_v_url);
  __Pyx_XDECREF(__pyx_v_path);
  __Pyx_XDECREF(__pyx_v_names);
  __Pyx_XDECREF(__pyx_v_module);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF(__pyx_v_monitor);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "libpetsc4py.pyx":2606
 * 
 * 
 * cdef public PetscErrorCode PetscPythonRegisterAll() except IERR:             # <<<<<<<<<<<<<<
 *     FunctionBegin(b"PetscPythonRegisterAll")
 * 
 */

PetscErrorCode PetscPythonRegisterAll(void) {
  PetscErrorCode __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PetscPythonRegisterAll", 0);

  /* "libpetsc4py.pyx":2607
 * 
 * cdef public PetscErrorCode PetscPythonRegisterAll() except IERR:
 *     FunctionBegin(b"PetscPythonRegisterAll")             # <<<<<<<<<<<<<<
 * 
 *     # Python subtypes
 */
  __pyx_f_11libpetsc4py_FunctionBegin(((char *)"PetscPythonRegisterAll"));

  /* "libpetsc4py.pyx":2610
 * 
 *     # Python subtypes
 *     CHKERR( MatRegister ( MATPYTHON,  MatCreate_Python  ) )             # <<<<<<<<<<<<<<
 *     CHKERR( PCRegister  ( PCPYTHON,   PCCreate_Python   ) )
 *     CHKERR( KSPRegister ( KSPPYTHON,  KSPCreate_Python  ) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(MatRegister("python", __pyx_f_11libpetsc4py_MatCreate_Python)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2610, __pyx_L1_error)

  /* "libpetsc4py.pyx":2611
 *     # Python subtypes
 *     CHKERR( MatRegister ( MATPYTHON,  MatCreate_Python  ) )
 *     CHKERR( PCRegister  ( PCPYTHON,   PCCreate_Python   ) )             # <<<<<<<<<<<<<<
 *     CHKERR( KSPRegister ( KSPPYTHON,  KSPCreate_Python  ) )
 *     CHKERR( SNESRegister( SNESPYTHON, SNESCreate_Python ) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(PCRegister("python", __pyx_f_11libpetsc4py_PCCreate_Python)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2611, __pyx_L1_error)

  /* "libpetsc4py.pyx":2612
 *     CHKERR( MatRegister ( MATPYTHON,  MatCreate_Python  ) )
 *     CHKERR( PCRegister  ( PCPYTHON,   PCCreate_Python   ) )
 *     CHKERR( KSPRegister ( KSPPYTHON,  KSPCreate_Python  ) )             # <<<<<<<<<<<<<<
 *     CHKERR( SNESRegister( SNESPYTHON, SNESCreate_Python ) )
 *     CHKERR( TSRegister  ( TSPYTHON,   TSCreate_Python   ) )
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(KSPRegister("python", __pyx_f_11libpetsc4py_KSPCreate_Python)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2612, __pyx_L1_error)

  /* "libpetsc4py.pyx":2613
 *     CHKERR( PCRegister  ( PCPYTHON,   PCCreate_Python   ) )
 *     CHKERR( KSPRegister ( KSPPYTHON,  KSPCreate_Python  ) )
 *     CHKERR( SNESRegister( SNESPYTHON, SNESCreate_Python ) )             # <<<<<<<<<<<<<<
 *     CHKERR( TSRegister  ( TSPYTHON,   TSCreate_Python   ) )
 * 
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(SNESRegister("python", __pyx_f_11libpetsc4py_SNESCreate_Python)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2613, __pyx_L1_error)

  /* "libpetsc4py.pyx":2614
 *     CHKERR( KSPRegister ( KSPPYTHON,  KSPCreate_Python  ) )
 *     CHKERR( SNESRegister( SNESPYTHON, SNESCreate_Python ) )
 *     CHKERR( TSRegister  ( TSPYTHON,   TSCreate_Python   ) )             # <<<<<<<<<<<<<<
 * 
 *     # Python monitors
 */
  __pyx_t_1 = __pyx_f_11libpetsc4py_CHKERR(TSRegister("python", __pyx_f_11libpetsc4py_TSCreate_Python)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2614, __pyx_L1_error)

  /* "libpetsc4py.pyx":2618
 *     # Python monitors
 *     global PetscPythonMonitorSet_C
 *     PetscPythonMonitorSet_C = PetscPythonMonitorSet_Python             # <<<<<<<<<<<<<<
 * 
 *     return FunctionEnd()
 */
  PetscPythonMonitorSet_C = __pyx_f_11libpetsc4py_PetscPythonMonitorSet_Python;

  /* "libpetsc4py.pyx":2620
 *     PetscPythonMonitorSet_C = PetscPythonMonitorSet_Python
 * 
 *     return FunctionEnd()             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __pyx_r = __pyx_f_11libpetsc4py_FunctionEnd();
  goto __pyx_L0;

  /* "libpetsc4py.pyx":2606
 * 
 * 
 * cdef public PetscErrorCode PetscPythonRegisterAll() except IERR:             # <<<<<<<<<<<<<<
 *     FunctionBegin(b"PetscPythonRegisterAll")
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libpetsc4py.PetscPythonRegisterAll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = PETSC_ERR_PYTHON;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_11libpetsc4py__PyObj __pyx_vtable_11libpetsc4py__PyObj;

static PyObject *__pyx_tp_new_11libpetsc4py__PyObj(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_11libpetsc4py__PyObj *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_11libpetsc4py__PyObj *)o);
  p->__pyx_vtab = __pyx_vtabptr_11libpetsc4py__PyObj;
  p->self = Py_None; Py_INCREF(Py_None);
  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_11libpetsc4py__PyObj(PyObject *o) {
  struct __pyx_obj_11libpetsc4py__PyObj *p = (struct __pyx_obj_11libpetsc4py__PyObj *)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->self);
  Py_CLEAR(p->name);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_11libpetsc4py__PyObj(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11libpetsc4py__PyObj *p = (struct __pyx_obj_11libpetsc4py__PyObj *)o;
  if (p->self) {
    e = (*v)(p->self, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11libpetsc4py__PyObj(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11libpetsc4py__PyObj *p = (struct __pyx_obj_11libpetsc4py__PyObj *)o;
  tmp = ((PyObject*)p->self);
  p->self = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_tp_getattro_11libpetsc4py__PyObj(PyObject *o, PyObject *n) {
  PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n);
  if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
    PyErr_Clear();
    v = __pyx_pw_11libpetsc4py_6_PyObj_1__getattr__(o, n);
  }
  return v;
}

static PyMethodDef __pyx_methods_11libpetsc4py__PyObj[] = {
  {"__getattr__", (PyCFunction)__pyx_pw_11libpetsc4py_6_PyObj_1__getattr__, METH_O|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11libpetsc4py__PyObj = {
  PyVarObject_HEAD_INIT(0, 0)
  "libpetsc4py._PyObj", /*tp_name*/
  sizeof(struct __pyx_obj_11libpetsc4py__PyObj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11libpetsc4py__PyObj, /*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*/
  __pyx_tp_getattro_11libpetsc4py__PyObj, /*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_11libpetsc4py__PyObj, /*tp_traverse*/
  __pyx_tp_clear_11libpetsc4py__PyObj, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11libpetsc4py__PyObj, /*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_11libpetsc4py__PyObj, /*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_11libpetsc4py__PyMat __pyx_vtable_11libpetsc4py__PyMat;

static PyObject *__pyx_tp_new_11libpetsc4py__PyMat(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11libpetsc4py__PyMat *p;
  PyObject *o = __pyx_tp_new_11libpetsc4py__PyObj(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11libpetsc4py__PyMat *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11libpetsc4py__PyObj*)__pyx_vtabptr_11libpetsc4py__PyMat;
  return o;
}

static PyTypeObject __pyx_type_11libpetsc4py__PyMat = {
  PyVarObject_HEAD_INIT(0, 0)
  "libpetsc4py._PyMat", /*tp_name*/
  sizeof(struct __pyx_obj_11libpetsc4py__PyMat), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11libpetsc4py__PyObj, /*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_11libpetsc4py__PyObj, /*tp_traverse*/
  __pyx_tp_clear_11libpetsc4py__PyObj, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_11libpetsc4py__PyMat, /*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_11libpetsc4py__PyPC __pyx_vtable_11libpetsc4py__PyPC;

static PyObject *__pyx_tp_new_11libpetsc4py__PyPC(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11libpetsc4py__PyPC *p;
  PyObject *o = __pyx_tp_new_11libpetsc4py__PyObj(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11libpetsc4py__PyPC *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11libpetsc4py__PyObj*)__pyx_vtabptr_11libpetsc4py__PyPC;
  return o;
}

static PyTypeObject __pyx_type_11libpetsc4py__PyPC = {
  PyVarObject_HEAD_INIT(0, 0)
  "libpetsc4py._PyPC", /*tp_name*/
  sizeof(struct __pyx_obj_11libpetsc4py__PyPC), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11libpetsc4py__PyObj, /*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_11libpetsc4py__PyObj, /*tp_traverse*/
  __pyx_tp_clear_11libpetsc4py__PyObj, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_11libpetsc4py__PyPC, /*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_11libpetsc4py__PyKSP __pyx_vtable_11libpetsc4py__PyKSP;

static PyObject *__pyx_tp_new_11libpetsc4py__PyKSP(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11libpetsc4py__PyKSP *p;
  PyObject *o = __pyx_tp_new_11libpetsc4py__PyObj(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11libpetsc4py__PyKSP *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11libpetsc4py__PyObj*)__pyx_vtabptr_11libpetsc4py__PyKSP;
  return o;
}

static PyTypeObject __pyx_type_11libpetsc4py__PyKSP = {
  PyVarObject_HEAD_INIT(0, 0)
  "libpetsc4py._PyKSP", /*tp_name*/
  sizeof(struct __pyx_obj_11libpetsc4py__PyKSP), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11libpetsc4py__PyObj, /*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_11libpetsc4py__PyObj, /*tp_traverse*/
  __pyx_tp_clear_11libpetsc4py__PyObj, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_11libpetsc4py__PyKSP, /*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_11libpetsc4py__PySNES __pyx_vtable_11libpetsc4py__PySNES;

static PyObject *__pyx_tp_new_11libpetsc4py__PySNES(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11libpetsc4py__PySNES *p;
  PyObject *o = __pyx_tp_new_11libpetsc4py__PyObj(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11libpetsc4py__PySNES *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11libpetsc4py__PyObj*)__pyx_vtabptr_11libpetsc4py__PySNES;
  return o;
}

static PyTypeObject __pyx_type_11libpetsc4py__PySNES = {
  PyVarObject_HEAD_INIT(0, 0)
  "libpetsc4py._PySNES", /*tp_name*/
  sizeof(struct __pyx_obj_11libpetsc4py__PySNES), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11libpetsc4py__PyObj, /*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_11libpetsc4py__PyObj, /*tp_traverse*/
  __pyx_tp_clear_11libpetsc4py__PyObj, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_11libpetsc4py__PySNES, /*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_11libpetsc4py__PyTS __pyx_vtable_11libpetsc4py__PyTS;

static PyObject *__pyx_tp_new_11libpetsc4py__PyTS(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11libpetsc4py__PyTS *p;
  PyObject *o = __pyx_tp_new_11libpetsc4py__PyObj(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11libpetsc4py__PyTS *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11libpetsc4py__PyObj*)__pyx_vtabptr_11libpetsc4py__PyTS;
  return o;
}

static PyTypeObject __pyx_type_11libpetsc4py__PyTS = {
  PyVarObject_HEAD_INIT(0, 0)
  "libpetsc4py._PyTS", /*tp_name*/
  sizeof(struct __pyx_obj_11libpetsc4py__PyTS), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11libpetsc4py__PyObj, /*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_11libpetsc4py__PyObj, /*tp_traverse*/
  __pyx_tp_clear_11libpetsc4py__PyObj, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_11libpetsc4py__PyTS, /*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_libpetsc4py(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_libpetsc4py},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "libpetsc4py",
    0, /* 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 */
    (freefunc)__pyx_module_cleanup /* 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_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0},
  {&__pyx_n_s_Error, __pyx_k_Error, sizeof(__pyx_k_Error), 0, 0, 1, 1},
  {&__pyx_n_s_SOR, __pyx_k_SOR, sizeof(__pyx_k_SOR), 0, 0, 1, 1},
  {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
  {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0},
  {&__pyx_n_s_adaptStep, __pyx_k_adaptStep, sizeof(__pyx_k_adaptStep), 0, 0, 1, 1},
  {&__pyx_n_s_apply, __pyx_k_apply, sizeof(__pyx_k_apply), 0, 0, 1, 1},
  {&__pyx_n_s_applySymmetricLeft, __pyx_k_applySymmetricLeft, sizeof(__pyx_k_applySymmetricLeft), 0, 0, 1, 1},
  {&__pyx_n_s_applySymmetricRight, __pyx_k_applySymmetricRight, sizeof(__pyx_k_applySymmetricRight), 0, 0, 1, 1},
  {&__pyx_n_s_applyTranspose, __pyx_k_applyTranspose, sizeof(__pyx_k_applyTranspose), 0, 0, 1, 1},
  {&__pyx_n_s_assembly, __pyx_k_assembly, sizeof(__pyx_k_assembly), 0, 0, 1, 1},
  {&__pyx_n_s_assemblyBegin, __pyx_k_assemblyBegin, sizeof(__pyx_k_assemblyBegin), 0, 0, 1, 1},
  {&__pyx_n_s_assemblyEnd, __pyx_k_assemblyEnd, sizeof(__pyx_k_assemblyEnd), 0, 0, 1, 1},
  {&__pyx_n_s_buildResidual, __pyx_k_buildResidual, sizeof(__pyx_k_buildResidual), 0, 0, 1, 1},
  {&__pyx_n_s_buildSolution, __pyx_k_buildSolution, sizeof(__pyx_k_buildSolution), 0, 0, 1, 1},
  {&__pyx_n_s_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 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_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 0, 0, 1, 1},
  {&__pyx_n_s_conjugate, __pyx_k_conjugate, sizeof(__pyx_k_conjugate), 0, 0, 1, 1},
  {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
  {&__pyx_n_s_create, __pyx_k_create, sizeof(__pyx_k_create), 0, 0, 1, 1},
  {&__pyx_n_s_createSubMatrix, __pyx_k_createSubMatrix, sizeof(__pyx_k_createSubMatrix), 0, 0, 1, 1},
  {&__pyx_n_s_createVecs, __pyx_k_createVecs, sizeof(__pyx_k_createVecs), 0, 0, 1, 1},
  {&__pyx_n_s_destroy, __pyx_k_destroy, sizeof(__pyx_k_destroy), 0, 0, 1, 1},
  {&__pyx_n_s_diagonalScale, __pyx_k_diagonalScale, sizeof(__pyx_k_diagonalScale), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_duplicate, __pyx_k_duplicate, sizeof(__pyx_k_duplicate), 0, 0, 1, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_evaluatestep, __pyx_k_evaluatestep, sizeof(__pyx_k_evaluatestep), 0, 0, 1, 1},
  {&__pyx_n_s_exec, __pyx_k_exec, sizeof(__pyx_k_exec), 0, 0, 1, 1},
  {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
  {&__pyx_n_s_formSNESFunction, __pyx_k_formSNESFunction, sizeof(__pyx_k_formSNESFunction), 0, 0, 1, 1},
  {&__pyx_n_s_formSNESJacobian, __pyx_k_formSNESJacobian, sizeof(__pyx_k_formSNESJacobian), 0, 0, 1, 1},
  {&__pyx_n_s_getDiagonal, __pyx_k_getDiagonal, sizeof(__pyx_k_getDiagonal), 0, 0, 1, 1},
  {&__pyx_n_s_getDiagonalBlock, __pyx_k_getDiagonalBlock, sizeof(__pyx_k_getDiagonalBlock), 0, 0, 1, 1},
  {&__pyx_n_s_imagPart, __pyx_k_imagPart, sizeof(__pyx_k_imagPart), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_interpolate, __pyx_k_interpolate, sizeof(__pyx_k_interpolate), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_missingDiagonal, __pyx_k_missingDiagonal, sizeof(__pyx_k_missingDiagonal), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_monitor, __pyx_k_monitor, sizeof(__pyx_k_monitor), 0, 0, 1, 1},
  {&__pyx_n_s_mult, __pyx_k_mult, sizeof(__pyx_k_mult), 0, 0, 1, 1},
  {&__pyx_n_s_multAdd, __pyx_k_multAdd, sizeof(__pyx_k_multAdd), 0, 0, 1, 1},
  {&__pyx_n_s_multDiagonalBlock, __pyx_k_multDiagonalBlock, sizeof(__pyx_k_multDiagonalBlock), 0, 0, 1, 1},
  {&__pyx_n_s_multHermitian, __pyx_k_multHermitian, sizeof(__pyx_k_multHermitian), 0, 0, 1, 1},
  {&__pyx_n_s_multHermitianAdd, __pyx_k_multHermitianAdd, sizeof(__pyx_k_multHermitianAdd), 0, 0, 1, 1},
  {&__pyx_n_s_multTranspose, __pyx_k_multTranspose, sizeof(__pyx_k_multTranspose), 0, 0, 1, 1},
  {&__pyx_n_s_multTransposeAdd, __pyx_k_multTransposeAdd, sizeof(__pyx_k_multTransposeAdd), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_norm, __pyx_k_norm, sizeof(__pyx_k_norm), 0, 0, 1, 1},
  {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
  {&__pyx_n_s_package, __pyx_k_package, sizeof(__pyx_k_package), 0, 0, 1, 1},
  {&__pyx_n_s_petsc4py_PETSc, __pyx_k_petsc4py_PETSc, sizeof(__pyx_k_petsc4py_PETSc), 0, 0, 1, 1},
  {&__pyx_n_s_postSolve, __pyx_k_postSolve, sizeof(__pyx_k_postSolve), 0, 0, 1, 1},
  {&__pyx_n_s_postStep, __pyx_k_postStep, sizeof(__pyx_k_postStep), 0, 0, 1, 1},
  {&__pyx_n_s_preSolve, __pyx_k_preSolve, sizeof(__pyx_k_preSolve), 0, 0, 1, 1},
  {&__pyx_n_s_preStep, __pyx_k_preStep, sizeof(__pyx_k_preStep), 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_rU, __pyx_k_rU, sizeof(__pyx_k_rU), 0, 0, 1, 1},
  {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
  {&__pyx_n_s_realPart, __pyx_k_realPart, sizeof(__pyx_k_realPart), 0, 0, 1, 1},
  {&__pyx_n_s_reset, __pyx_k_reset, sizeof(__pyx_k_reset), 0, 0, 1, 1},
  {&__pyx_n_s_rollback, __pyx_k_rollback, sizeof(__pyx_k_rollback), 0, 0, 1, 1},
  {&__pyx_n_s_rsplit, __pyx_k_rsplit, sizeof(__pyx_k_rsplit), 0, 0, 1, 1},
  {&__pyx_n_s_scale, __pyx_k_scale, sizeof(__pyx_k_scale), 0, 0, 1, 1},
  {&__pyx_n_s_setDiagonal, __pyx_k_setDiagonal, sizeof(__pyx_k_setDiagonal), 0, 0, 1, 1},
  {&__pyx_n_s_setFromOptions, __pyx_k_setFromOptions, sizeof(__pyx_k_setFromOptions), 0, 0, 1, 1},
  {&__pyx_n_s_setMonitor, __pyx_k_setMonitor, sizeof(__pyx_k_setMonitor), 0, 0, 1, 1},
  {&__pyx_n_s_setOption, __pyx_k_setOption, sizeof(__pyx_k_setOption), 0, 0, 1, 1},
  {&__pyx_n_s_setUp, __pyx_k_setUp, sizeof(__pyx_k_setUp), 0, 0, 1, 1},
  {&__pyx_n_s_shift, __pyx_k_shift, sizeof(__pyx_k_shift), 0, 0, 1, 1},
  {&__pyx_n_s_solve, __pyx_k_solve, sizeof(__pyx_k_solve), 0, 0, 1, 1},
  {&__pyx_n_s_solveAdd, __pyx_k_solveAdd, sizeof(__pyx_k_solveAdd), 0, 0, 1, 1},
  {&__pyx_n_s_solveStep, __pyx_k_solveStep, sizeof(__pyx_k_solveStep), 0, 0, 1, 1},
  {&__pyx_n_s_solveTranspose, __pyx_k_solveTranspose, sizeof(__pyx_k_solveTranspose), 0, 0, 1, 1},
  {&__pyx_n_s_solveTransposeAdd, __pyx_k_solveTransposeAdd, sizeof(__pyx_k_solveTransposeAdd), 0, 0, 1, 1},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
  {&__pyx_n_s_stepTranspose, __pyx_k_stepTranspose, sizeof(__pyx_k_stepTranspose), 0, 0, 1, 1},
  {&__pyx_n_s_view, __pyx_k_view, sizeof(__pyx_k_view), 0, 0, 1, 1},
  {&__pyx_n_s_zeroEntries, __pyx_k_zeroEntries, sizeof(__pyx_k_zeroEntries), 0, 0, 1, 1},
  {&__pyx_n_s_zeroRowsColumns, __pyx_k_zeroRowsColumns, sizeof(__pyx_k_zeroRowsColumns), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s_open); if (!__pyx_builtin_open) __PYX_ERR(0, 282, __pyx_L1_error)
  __pyx_builtin_compile = __Pyx_GetBuiltinName(__pyx_n_s_compile); if (!__pyx_builtin_compile) __PYX_ERR(0, 284, __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);

  /* "libpetsc4py.pyx":269
 * 
 * cdef object parse_url(object url):
 *     path, name = url.rsplit(":", 1)             # <<<<<<<<<<<<<<
 *     return (path, name)
 * 
 */
  __pyx_tuple__2 = PyTuple_Pack(2, __pyx_kp_s_, __pyx_int_1); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "libpetsc4py.pyx":387
 *     # package.module[.{function|class}]
 *     if '.' in name:
 *         modname, clsname = name.rsplit('.', 1)             # <<<<<<<<<<<<<<
 *         mod = PyImport_Import(modname)
 *         if hasattr(mod, clsname):
 */
  __pyx_tuple__4 = PyTuple_Pack(2, __pyx_kp_s__3, __pyx_int_1); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);
  __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_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __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_v_11libpetsc4py_PetscError = Py_None; Py_INCREF(Py_None);
  __pyx_v_11libpetsc4py_module_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __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
  PyObject *__pyx_t_1 = NULL;
  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_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_11libpetsc4py_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_11libpetsc4py_dtype) __PYX_ERR(1, 9, __pyx_L1_error)
  __pyx_ptype_11libpetsc4py_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_11libpetsc4py_ndarray) __PYX_ERR(1, 12, __pyx_L1_error)
  __pyx_vtabptr_11libpetsc4py__PyObj = &__pyx_vtable_11libpetsc4py__PyObj;
  __pyx_vtable_11libpetsc4py__PyObj.setcontext = (int (*)(struct __pyx_obj_11libpetsc4py__PyObj *, void *, struct PyPetscObjectObject *))__pyx_f_11libpetsc4py_6_PyObj_setcontext;
  __pyx_vtable_11libpetsc4py__PyObj.getcontext = (int (*)(struct __pyx_obj_11libpetsc4py__PyObj *, void **))__pyx_f_11libpetsc4py_6_PyObj_getcontext;
  __pyx_vtable_11libpetsc4py__PyObj.setname = (int (*)(struct __pyx_obj_11libpetsc4py__PyObj *, char *))__pyx_f_11libpetsc4py_6_PyObj_setname;
  __pyx_vtable_11libpetsc4py__PyObj.getname = (char *(*)(struct __pyx_obj_11libpetsc4py__PyObj *))__pyx_f_11libpetsc4py_6_PyObj_getname;
  if (PyType_Ready(&__pyx_type_11libpetsc4py__PyObj) < 0) __PYX_ERR(0, 296, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_11libpetsc4py__PyObj.tp_print = 0;
  #endif
  if (__Pyx_SetVtable(__pyx_type_11libpetsc4py__PyObj.tp_dict, __pyx_vtabptr_11libpetsc4py__PyObj) < 0) __PYX_ERR(0, 296, __pyx_L1_error)
  __pyx_ptype_11libpetsc4py__PyObj = &__pyx_type_11libpetsc4py__PyObj;
  __pyx_vtabptr_11libpetsc4py__PyMat = &__pyx_vtable_11libpetsc4py__PyMat;
  __pyx_vtable_11libpetsc4py__PyMat.__pyx_base = *__pyx_vtabptr_11libpetsc4py__PyObj;
  __pyx_type_11libpetsc4py__PyMat.tp_base = __pyx_ptype_11libpetsc4py__PyObj;
  if (PyType_Ready(&__pyx_type_11libpetsc4py__PyMat) < 0) __PYX_ERR(0, 527, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_11libpetsc4py__PyMat.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11libpetsc4py__PyMat.tp_dictoffset && __pyx_type_11libpetsc4py__PyMat.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_11libpetsc4py__PyMat.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_11libpetsc4py__PyMat.tp_dict, __pyx_vtabptr_11libpetsc4py__PyMat) < 0) __PYX_ERR(0, 527, __pyx_L1_error)
  __pyx_ptype_11libpetsc4py__PyMat = &__pyx_type_11libpetsc4py__PyMat;
  __pyx_vtabptr_11libpetsc4py__PyPC = &__pyx_vtable_11libpetsc4py__PyPC;
  __pyx_vtable_11libpetsc4py__PyPC.__pyx_base = *__pyx_vtabptr_11libpetsc4py__PyObj;
  __pyx_type_11libpetsc4py__PyPC.tp_base = __pyx_ptype_11libpetsc4py__PyObj;
  if (PyType_Ready(&__pyx_type_11libpetsc4py__PyPC) < 0) __PYX_ERR(0, 1201, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_11libpetsc4py__PyPC.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11libpetsc4py__PyPC.tp_dictoffset && __pyx_type_11libpetsc4py__PyPC.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_11libpetsc4py__PyPC.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_11libpetsc4py__PyPC.tp_dict, __pyx_vtabptr_11libpetsc4py__PyPC) < 0) __PYX_ERR(0, 1201, __pyx_L1_error)
  __pyx_ptype_11libpetsc4py__PyPC = &__pyx_type_11libpetsc4py__PyPC;
  __pyx_vtabptr_11libpetsc4py__PyKSP = &__pyx_vtable_11libpetsc4py__PyKSP;
  __pyx_vtable_11libpetsc4py__PyKSP.__pyx_base = *__pyx_vtabptr_11libpetsc4py__PyObj;
  __pyx_type_11libpetsc4py__PyKSP.tp_base = __pyx_ptype_11libpetsc4py__PyObj;
  if (PyType_Ready(&__pyx_type_11libpetsc4py__PyKSP) < 0) __PYX_ERR(0, 1477, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_11libpetsc4py__PyKSP.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11libpetsc4py__PyKSP.tp_dictoffset && __pyx_type_11libpetsc4py__PyKSP.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_11libpetsc4py__PyKSP.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_11libpetsc4py__PyKSP.tp_dict, __pyx_vtabptr_11libpetsc4py__PyKSP) < 0) __PYX_ERR(0, 1477, __pyx_L1_error)
  __pyx_ptype_11libpetsc4py__PyKSP = &__pyx_type_11libpetsc4py__PyKSP;
  __pyx_vtabptr_11libpetsc4py__PySNES = &__pyx_vtable_11libpetsc4py__PySNES;
  __pyx_vtable_11libpetsc4py__PySNES.__pyx_base = *__pyx_vtabptr_11libpetsc4py__PyObj;
  __pyx_type_11libpetsc4py__PySNES.tp_base = __pyx_ptype_11libpetsc4py__PyObj;
  if (PyType_Ready(&__pyx_type_11libpetsc4py__PySNES) < 0) __PYX_ERR(0, 1839, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_11libpetsc4py__PySNES.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11libpetsc4py__PySNES.tp_dictoffset && __pyx_type_11libpetsc4py__PySNES.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_11libpetsc4py__PySNES.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_11libpetsc4py__PySNES.tp_dict, __pyx_vtabptr_11libpetsc4py__PySNES) < 0) __PYX_ERR(0, 1839, __pyx_L1_error)
  __pyx_ptype_11libpetsc4py__PySNES = &__pyx_type_11libpetsc4py__PySNES;
  __pyx_vtabptr_11libpetsc4py__PyTS = &__pyx_vtable_11libpetsc4py__PyTS;
  __pyx_vtable_11libpetsc4py__PyTS.__pyx_base = *__pyx_vtabptr_11libpetsc4py__PyObj;
  __pyx_type_11libpetsc4py__PyTS.tp_base = __pyx_ptype_11libpetsc4py__PyObj;
  if (PyType_Ready(&__pyx_type_11libpetsc4py__PyTS) < 0) __PYX_ERR(0, 2185, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_11libpetsc4py__PyTS.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11libpetsc4py__PyTS.tp_dictoffset && __pyx_type_11libpetsc4py__PyTS.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_11libpetsc4py__PyTS.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_11libpetsc4py__PyTS.tp_dict, __pyx_vtabptr_11libpetsc4py__PyTS) < 0) __PYX_ERR(0, 2185, __pyx_L1_error)
  __pyx_ptype_11libpetsc4py__PyTS = &__pyx_type_11libpetsc4py__PyTS;
  __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_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("petsc4py.PETSc"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 91, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_8petsc4py_5PETSc_Comm = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "Comm", sizeof(struct PyPetscCommObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_Comm) __PYX_ERR(2, 91, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_Object = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "Object", sizeof(struct PyPetscObjectObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_Object) __PYX_ERR(2, 99, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_Object = (struct __pyx_vtabstruct_8petsc4py_5PETSc_Object*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_Object->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_Object)) __PYX_ERR(2, 99, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_Viewer = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "Viewer", sizeof(struct PyPetscViewerObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_Viewer) __PYX_ERR(2, 111, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_Viewer = (struct __pyx_vtabstruct_8petsc4py_5PETSc_Viewer*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_Viewer->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_Viewer)) __PYX_ERR(2, 111, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_Random = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "Random", sizeof(struct PyPetscRandomObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_Random) __PYX_ERR(2, 117, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_Random = (struct __pyx_vtabstruct_8petsc4py_5PETSc_Random*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_Random->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_Random)) __PYX_ERR(2, 117, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_IS = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "IS", sizeof(struct PyPetscISObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_IS) __PYX_ERR(2, 123, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_IS = (struct __pyx_vtabstruct_8petsc4py_5PETSc_IS*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_IS->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_IS)) __PYX_ERR(2, 123, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_LGMap = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "LGMap", sizeof(struct PyPetscLGMapObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_LGMap) __PYX_ERR(2, 129, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_LGMap = (struct __pyx_vtabstruct_8petsc4py_5PETSc_LGMap*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_LGMap->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_LGMap)) __PYX_ERR(2, 129, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_SF = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "SF", sizeof(struct PyPetscSFObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_SF) __PYX_ERR(2, 135, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_SF = (struct __pyx_vtabstruct_8petsc4py_5PETSc_SF*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_SF->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_SF)) __PYX_ERR(2, 135, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_Vec = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "Vec", sizeof(struct PyPetscVecObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_Vec) __PYX_ERR(2, 141, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_Vec = (struct __pyx_vtabstruct_8petsc4py_5PETSc_Vec*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_Vec->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_Vec)) __PYX_ERR(2, 141, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_FE = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "FE", sizeof(struct PyPetscFEObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_FE) __PYX_ERR(2, 147, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_FE = (struct __pyx_vtabstruct_8petsc4py_5PETSc_FE*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_FE->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_FE)) __PYX_ERR(2, 147, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_Quad = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "Quad", sizeof(struct PyPetscQuadObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_Quad) __PYX_ERR(2, 153, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_Quad = (struct __pyx_vtabstruct_8petsc4py_5PETSc_Quad*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_Quad->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_Quad)) __PYX_ERR(2, 153, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_Scatter = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "Scatter", sizeof(struct PyPetscScatterObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_Scatter) __PYX_ERR(2, 159, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_Scatter = (struct __pyx_vtabstruct_8petsc4py_5PETSc_Scatter*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_Scatter->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_Scatter)) __PYX_ERR(2, 159, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_Section = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "Section", sizeof(struct PyPetscSectionObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_Section) __PYX_ERR(2, 165, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_Section = (struct __pyx_vtabstruct_8petsc4py_5PETSc_Section*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_Section->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_Section)) __PYX_ERR(2, 165, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_Mat = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "Mat", sizeof(struct PyPetscMatObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_Mat) __PYX_ERR(2, 171, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_Mat = (struct __pyx_vtabstruct_8petsc4py_5PETSc_Mat*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_Mat->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_Mat)) __PYX_ERR(2, 171, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_NullSpace = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "NullSpace", sizeof(struct PyPetscNullSpaceObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_NullSpace) __PYX_ERR(2, 177, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_NullSpace = (struct __pyx_vtabstruct_8petsc4py_5PETSc_NullSpace*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_NullSpace->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_NullSpace)) __PYX_ERR(2, 177, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_PC = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "PC", sizeof(struct PyPetscPCObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_PC) __PYX_ERR(2, 183, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_PC = (struct __pyx_vtabstruct_8petsc4py_5PETSc_PC*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_PC->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_PC)) __PYX_ERR(2, 183, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_KSP = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "KSP", sizeof(struct PyPetscKSPObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_KSP) __PYX_ERR(2, 189, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_KSP = (struct __pyx_vtabstruct_8petsc4py_5PETSc_KSP*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_KSP->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_KSP)) __PYX_ERR(2, 189, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_SNES = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "SNES", sizeof(struct PyPetscSNESObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_SNES) __PYX_ERR(2, 195, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_SNES = (struct __pyx_vtabstruct_8petsc4py_5PETSc_SNES*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_SNES->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_SNES)) __PYX_ERR(2, 195, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_TS = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "TS", sizeof(struct PyPetscTSObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_TS) __PYX_ERR(2, 201, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_TS = (struct __pyx_vtabstruct_8petsc4py_5PETSc_TS*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_TS->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_TS)) __PYX_ERR(2, 201, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_TAO = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "TAO", sizeof(struct PyPetscTAOObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_TAO) __PYX_ERR(2, 207, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_TAO = (struct __pyx_vtabstruct_8petsc4py_5PETSc_TAO*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_TAO->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_TAO)) __PYX_ERR(2, 207, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_AO = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "AO", sizeof(struct PyPetscAOObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_AO) __PYX_ERR(2, 213, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_AO = (struct __pyx_vtabstruct_8petsc4py_5PETSc_AO*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_AO->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_AO)) __PYX_ERR(2, 213, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_DM = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "DM", sizeof(struct PyPetscDMObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_DM) __PYX_ERR(2, 219, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_DM = (struct __pyx_vtabstruct_8petsc4py_5PETSc_DM*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_DM->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_DM)) __PYX_ERR(2, 219, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_DS = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "DS", sizeof(struct PyPetscDSObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_DS) __PYX_ERR(2, 225, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_DS = (struct __pyx_vtabstruct_8petsc4py_5PETSc_DS*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_DS->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_DS)) __PYX_ERR(2, 225, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_Partitioner = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "Partitioner", sizeof(struct PyPetscPartitionerObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_Partitioner) __PYX_ERR(2, 231, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_Partitioner = (struct __pyx_vtabstruct_8petsc4py_5PETSc_Partitioner*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_Partitioner->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_Partitioner)) __PYX_ERR(2, 231, __pyx_L1_error)
  __pyx_ptype_8petsc4py_5PETSc_DMLabel = __Pyx_ImportType(__pyx_t_1, "petsc4py.PETSc", "DMLabel", sizeof(struct PyPetscDMLabelObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_8petsc4py_5PETSc_DMLabel) __PYX_ERR(2, 237, __pyx_L1_error)
  __pyx_vtabptr_8petsc4py_5PETSc_DMLabel = (struct __pyx_vtabstruct_8petsc4py_5PETSc_DMLabel*)__Pyx_GetVtable(__pyx_ptype_8petsc4py_5PETSc_DMLabel->tp_dict); if (unlikely(!__pyx_vtabptr_8petsc4py_5PETSc_DMLabel)) __PYX_ERR(2, 237, __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
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __pyx_t_1 = PyImport_ImportModule("petsc4py.PETSc"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_ImportFunction(__pyx_t_1, "PyPetscType_Lookup", (void (**)(void))&__pyx_f_8petsc4py_5PETSc_PyPetscType_Lookup, "PyTypeObject *(int)") < 0) __PYX_ERR(0, 1, __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;
}


#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 initlibpetsc4py(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initlibpetsc4py(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_libpetsc4py(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_libpetsc4py(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_libpetsc4py(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PetscErrorCode __pyx_t_4;
  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 'libpetsc4py' 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_libpetsc4py(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("libpetsc4py", __pyx_methods, 0, 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_libpetsc4py) {
    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, "libpetsc4py")) {
      if (unlikely(PyDict_SetItemString(modules, "libpetsc4py", __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();
  if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "libpetsc4py.pyx":104
 * include "arraynpy.pxi"
 * 
 * import_array()             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
  __pyx_t_1 = _import_array(); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 104, __pyx_L1_error)

  /* "libpetsc4py.pyx":114
 *     enum: IERR "PETSC_ERR_PYTHON"
 * 
 * cdef char *FUNCT = NULL             # <<<<<<<<<<<<<<
 * cdef char *fstack[1024]
 * cdef int   istack = 0
 */
  __pyx_v_11libpetsc4py_FUNCT = NULL;

  /* "libpetsc4py.pyx":116
 * cdef char *FUNCT = NULL
 * cdef char *fstack[1024]
 * cdef int   istack = 0             # <<<<<<<<<<<<<<
 * 
 * cdef inline void FunctionBegin(char name[]) nogil:
 */
  __pyx_v_11libpetsc4py_istack = 0;

  /* "libpetsc4py.pyx":157
 *     PyObject *PyExc_RuntimeError
 * 
 * cdef object PetscError = <object>PyExc_RuntimeError             # <<<<<<<<<<<<<<
 * from petsc4py.PETSc import Error as PetscError
 * 
 */
  __pyx_t_2 = ((PyObject *)PyExc_RuntimeError);
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_XGOTREF(__pyx_v_11libpetsc4py_PetscError);
  __Pyx_DECREF_SET(__pyx_v_11libpetsc4py_PetscError, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libpetsc4py.pyx":158
 * 
 * cdef object PetscError = <object>PyExc_RuntimeError
 * from petsc4py.PETSc import Error as PetscError             # <<<<<<<<<<<<<<
 * 
 * cdef inline void PythonSETERR(PetscErrorCode ierr) with gil:
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_Error);
  __Pyx_GIVEREF(__pyx_n_s_Error);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Error);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_petsc4py_PETSc, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 158, __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_Error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_XGOTREF(__pyx_v_11libpetsc4py_PetscError);
  __Pyx_DECREF_SET(__pyx_v_11libpetsc4py_PetscError, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":272
 *     return (path, name)
 * 
 * cdef dict module_cache = {}             # <<<<<<<<<<<<<<
 * 
 * cdef object load_module(object path):
 */
  __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_XGOTREF(__pyx_v_11libpetsc4py_module_cache);
  __Pyx_DECREF_SET(__pyx_v_11libpetsc4py_module_cache, ((PyObject*)__pyx_t_3));
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "libpetsc4py.pyx":2629
 * # below trick Cython to treat all these entries as used.
 * 
 * if PETSC_FALSE:             # <<<<<<<<<<<<<<
 *     <void>import_libpetsc4py()
 *     <void>MatPythonGetContext(NULL,NULL)
 */
  if (PETSC_FALSE) {

    /* "libpetsc4py.pyx":2630
 * 
 * if PETSC_FALSE:
 *     <void>import_libpetsc4py()             # <<<<<<<<<<<<<<
 *     <void>MatPythonGetContext(NULL,NULL)
 *     <void>MatPythonSetContext(NULL,NULL)
 */
    __pyx_t_1 = import_libpetsc4py(); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 2630, __pyx_L1_error)
    ((void)__pyx_t_1);

    /* "libpetsc4py.pyx":2631
 * if PETSC_FALSE:
 *     <void>import_libpetsc4py()
 *     <void>MatPythonGetContext(NULL,NULL)             # <<<<<<<<<<<<<<
 *     <void>MatPythonSetContext(NULL,NULL)
 *     <void>PCPythonGetContext(NULL,NULL)
 */
    __pyx_t_4 = MatPythonGetContext(NULL, NULL); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2631, __pyx_L1_error)
    ((void)__pyx_t_4);

    /* "libpetsc4py.pyx":2632
 *     <void>import_libpetsc4py()
 *     <void>MatPythonGetContext(NULL,NULL)
 *     <void>MatPythonSetContext(NULL,NULL)             # <<<<<<<<<<<<<<
 *     <void>PCPythonGetContext(NULL,NULL)
 *     <void>PCPythonSetContext(NULL,NULL)
 */
    __pyx_t_4 = MatPythonSetContext(NULL, NULL); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2632, __pyx_L1_error)
    ((void)__pyx_t_4);

    /* "libpetsc4py.pyx":2633
 *     <void>MatPythonGetContext(NULL,NULL)
 *     <void>MatPythonSetContext(NULL,NULL)
 *     <void>PCPythonGetContext(NULL,NULL)             # <<<<<<<<<<<<<<
 *     <void>PCPythonSetContext(NULL,NULL)
 *     <void>KSPPythonGetContext(NULL,NULL)
 */
    __pyx_t_4 = PCPythonGetContext(NULL, NULL); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2633, __pyx_L1_error)
    ((void)__pyx_t_4);

    /* "libpetsc4py.pyx":2634
 *     <void>MatPythonSetContext(NULL,NULL)
 *     <void>PCPythonGetContext(NULL,NULL)
 *     <void>PCPythonSetContext(NULL,NULL)             # <<<<<<<<<<<<<<
 *     <void>KSPPythonGetContext(NULL,NULL)
 *     <void>KSPPythonSetContext(NULL,NULL)
 */
    __pyx_t_4 = PCPythonSetContext(NULL, NULL); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2634, __pyx_L1_error)
    ((void)__pyx_t_4);

    /* "libpetsc4py.pyx":2635
 *     <void>PCPythonGetContext(NULL,NULL)
 *     <void>PCPythonSetContext(NULL,NULL)
 *     <void>KSPPythonGetContext(NULL,NULL)             # <<<<<<<<<<<<<<
 *     <void>KSPPythonSetContext(NULL,NULL)
 *     <void>SNESPythonGetContext(NULL,NULL)
 */
    __pyx_t_4 = KSPPythonGetContext(NULL, NULL); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2635, __pyx_L1_error)
    ((void)__pyx_t_4);

    /* "libpetsc4py.pyx":2636
 *     <void>PCPythonSetContext(NULL,NULL)
 *     <void>KSPPythonGetContext(NULL,NULL)
 *     <void>KSPPythonSetContext(NULL,NULL)             # <<<<<<<<<<<<<<
 *     <void>SNESPythonGetContext(NULL,NULL)
 *     <void>SNESPythonSetContext(NULL,NULL)
 */
    __pyx_t_4 = KSPPythonSetContext(NULL, NULL); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2636, __pyx_L1_error)
    ((void)__pyx_t_4);

    /* "libpetsc4py.pyx":2637
 *     <void>KSPPythonGetContext(NULL,NULL)
 *     <void>KSPPythonSetContext(NULL,NULL)
 *     <void>SNESPythonGetContext(NULL,NULL)             # <<<<<<<<<<<<<<
 *     <void>SNESPythonSetContext(NULL,NULL)
 *     <void>TSPythonGetContext(NULL,NULL)
 */
    __pyx_t_4 = SNESPythonGetContext(NULL, NULL); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2637, __pyx_L1_error)
    ((void)__pyx_t_4);

    /* "libpetsc4py.pyx":2638
 *     <void>KSPPythonSetContext(NULL,NULL)
 *     <void>SNESPythonGetContext(NULL,NULL)
 *     <void>SNESPythonSetContext(NULL,NULL)             # <<<<<<<<<<<<<<
 *     <void>TSPythonGetContext(NULL,NULL)
 *     <void>TSPythonSetContext(NULL,NULL)
 */
    __pyx_t_4 = SNESPythonSetContext(NULL, NULL); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2638, __pyx_L1_error)
    ((void)__pyx_t_4);

    /* "libpetsc4py.pyx":2639
 *     <void>SNESPythonGetContext(NULL,NULL)
 *     <void>SNESPythonSetContext(NULL,NULL)
 *     <void>TSPythonGetContext(NULL,NULL)             # <<<<<<<<<<<<<<
 *     <void>TSPythonSetContext(NULL,NULL)
 *     <void>PetscPythonRegisterAll()
 */
    __pyx_t_4 = TSPythonGetContext(NULL, NULL); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2639, __pyx_L1_error)
    ((void)__pyx_t_4);

    /* "libpetsc4py.pyx":2640
 *     <void>SNESPythonSetContext(NULL,NULL)
 *     <void>TSPythonGetContext(NULL,NULL)
 *     <void>TSPythonSetContext(NULL,NULL)             # <<<<<<<<<<<<<<
 *     <void>PetscPythonRegisterAll()
 * 
 */
    __pyx_t_4 = TSPythonSetContext(NULL, NULL); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2640, __pyx_L1_error)
    ((void)__pyx_t_4);

    /* "libpetsc4py.pyx":2641
 *     <void>TSPythonGetContext(NULL,NULL)
 *     <void>TSPythonSetContext(NULL,NULL)
 *     <void>PetscPythonRegisterAll()             # <<<<<<<<<<<<<<
 * 
 * # --------------------------------------------------------------------
 */
    __pyx_t_4 = PetscPythonRegisterAll(); if (unlikely(__pyx_t_4 == ((PetscErrorCode)PETSC_ERR_PYTHON))) __PYX_ERR(0, 2641, __pyx_L1_error)
    ((void)__pyx_t_4);

    /* "libpetsc4py.pyx":2629
 * # below trick Cython to treat all these entries as used.
 * 
 * if PETSC_FALSE:             # <<<<<<<<<<<<<<
 *     <void>import_libpetsc4py()
 *     <void>MatPythonGetContext(NULL,NULL)
 */
  }

  /*--- Wrapped vars code ---*/

  if (__Pyx_RegisterCleanup()) __PYX_ERR(0, 1, __pyx_L1_error);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init libpetsc4py", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init libpetsc4py");
  }
  __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
}

static CYTHON_SMALL_CODE void __Pyx_CleanupGlobals(void) {
  Py_CLEAR(__pyx_tuple__2);
  Py_CLEAR(__pyx_tuple__4);
  /* CodeObjectCache.cleanup */
  if (__pyx_code_cache.entries) {
      __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
      int i, count = __pyx_code_cache.count;
      __pyx_code_cache.count = 0;
      __pyx_code_cache.max_count = 0;
      __pyx_code_cache.entries = NULL;
      for (i=0; i<count; i++) {
          Py_DECREF(entries[i].code_object);
      }
      PyMem_Free(entries);
  }

}
static void __pyx_module_cleanup(CYTHON_UNUSED PyObject *self) {
  /*--- Global cleanup code ---*/
  Py_CLEAR(__pyx_v_11libpetsc4py_module_cache);
  Py_CLEAR(__pyx_v_11libpetsc4py_PetscError);
  __Pyx_CleanupGlobals();
  /*--- Type import cleanup code ---*/
  Py_CLEAR(__pyx_ptype_11libpetsc4py_dtype);
  Py_CLEAR(__pyx_ptype_11libpetsc4py_ndarray);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_AO);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_Comm);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_DM);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_DMLabel);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_DS);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_FE);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_IS);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_KSP);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_LGMap);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_Mat);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_NullSpace);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_Object);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_PC);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_Partitioner);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_Quad);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_Random);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_SF);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_SNES);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_Scatter);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_Section);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_TAO);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_TS);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_Vec);
  Py_CLEAR(__pyx_ptype_8petsc4py_5PETSc_Viewer);
  /*--- Builtin cleanup code ---*/
  Py_CLEAR(__pyx_builtin_open);
  Py_CLEAR(__pyx_builtin_compile);
  /*--- Intern cleanup code ---*/
  Py_CLEAR(__pyx_empty_tuple);
  Py_CLEAR(__pyx_d);
  Py_CLEAR(__pyx_cython_runtime);
  Py_CLEAR(__pyx_b);
}

/* --- 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;
}

/* 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

/* WriteUnraisableException */
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#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;
}

/* decode_c_bytes */
static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
         const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    if (unlikely((start < 0) | (stop < 0))) {
        if (start < 0) {
            start += length;
            if (start < 0)
                start = 0;
        }
        if (stop < 0)
            stop += length;
    }
    if (stop > length)
        stop = length;
    if (unlikely(stop <= start))
        return __Pyx_NewRef(__pyx_empty_unicode);
    length = stop - start;
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

/* 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

/* 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

/* 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

/* 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

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
    if (likely(PyCFunction_Check(func)))
#endif
    {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* 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

/* 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 (__Pyx_PyFastCFunction_Check(func)) {
            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

/* 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;
}

/* SwapException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(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
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#endif

/* 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

/* PyExec */
static CYTHON_INLINE PyObject* __Pyx_PyExec2(PyObject* o, PyObject* globals) {
    return __Pyx_PyExec3(o, globals, NULL);
}
static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals) {
    PyObject* result;
    PyObject* s = 0;
    char *code = 0;
    if (!globals || globals == Py_None) {
        globals = __pyx_d;
    } else if (!PyDict_Check(globals)) {
        PyErr_Format(PyExc_TypeError, "exec() arg 2 must be a dict, not %.200s",
                     Py_TYPE(globals)->tp_name);
        goto bad;
    }
    if (!locals || locals == Py_None) {
        locals = globals;
    }
    if (__Pyx_PyDict_GetItemStr(globals, __pyx_n_s_builtins) == NULL) {
        if (PyDict_SetItem(globals, __pyx_n_s_builtins, PyEval_GetBuiltins()) < 0)
            goto bad;
    }
    if (PyCode_Check(o)) {
        if (__Pyx_PyCode_HasFreeVars((PyCodeObject *)o)) {
            PyErr_SetString(PyExc_TypeError,
                "code object passed to exec() may not contain free variables");
            goto bad;
        }
        #if CYTHON_COMPILING_IN_PYPY || PY_VERSION_HEX < 0x030200B1
        result = PyEval_EvalCode((PyCodeObject *)o, globals, locals);
        #else
        result = PyEval_EvalCode(o, globals, locals);
        #endif
    } else {
        PyCompilerFlags cf;
        cf.cf_flags = 0;
#if PY_VERSION_HEX >= 0x030800A3
        cf.cf_feature_version = PY_MINOR_VERSION;
#endif
        if (PyUnicode_Check(o)) {
            cf.cf_flags = PyCF_SOURCE_IS_UTF8;
            s = PyUnicode_AsUTF8String(o);
            if (!s) goto bad;
            o = s;
        #if PY_MAJOR_VERSION >= 3
        } else if (!PyBytes_Check(o)) {
        #else
        } else if (!PyString_Check(o)) {
        #endif
            PyErr_Format(PyExc_TypeError,
                "exec: arg 1 must be string, bytes or code object, got %.200s",
                Py_TYPE(o)->tp_name);
            goto bad;
        }
        #if PY_MAJOR_VERSION >= 3
        code = PyBytes_AS_STRING(o);
        #else
        code = PyString_AS_STRING(o);
        #endif
        if (PyEval_MergeCompilerFlags(&cf)) {
            result = PyRun_StringFlags(code, Py_file_input, globals, locals, &cf);
        } else {
            result = PyRun_String(code, Py_file_input, globals, locals);
        }
        Py_XDECREF(s);
    }
    return result;
bad:
    Py_XDECREF(s);
    return 0;
}

/* 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);
}

/* 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;
}

/* 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;
    }
}

/* 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

/* 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

/* 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;
}

/* GetVTable */
static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

/* 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;
}

/* RegisterModuleCleanup */
#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject* __pyx_module_cleanup_atexit(PyObject *module, CYTHON_UNUSED PyObject *unused) {
    __pyx_module_cleanup(module);
    Py_INCREF(Py_None); return Py_None;
}
static int __Pyx_RegisterCleanup(void) {
    static PyMethodDef cleanup_def = {
        "__cleanup", (PyCFunction)__pyx_module_cleanup_atexit, METH_NOARGS, 0};
    PyObject *cleanup_func = 0;
    PyObject *atexit = 0;
    PyObject *reg = 0;
    PyObject *args = 0;
    PyObject *res = 0;
    int ret = -1;
    cleanup_func = PyCFunction_New(&cleanup_def, 0);
    if (!cleanup_func)
        goto bad;
    atexit = PyImport_ImportModule("atexit");
    if (!atexit)
        goto bad;
    reg = PyObject_GetAttrString(atexit, "_exithandlers");
    if (reg && PyList_Check(reg)) {
        PyObject *a, *kw;
        a = PyTuple_New(0);
        kw = PyDict_New();
        if (!a || !kw) {
            Py_XDECREF(a);
            Py_XDECREF(kw);
            goto bad;
        }
        args = PyTuple_Pack(3, cleanup_func, a, kw);
        Py_DECREF(a);
        Py_DECREF(kw);
        if (!args)
            goto bad;
        ret = PyList_Insert(reg, 0, args);
    } else {
        if (!reg)
            PyErr_Clear();
        Py_XDECREF(reg);
        reg = PyObject_GetAttrString(atexit, "register");
        if (!reg)
            goto bad;
        args = PyTuple_Pack(1, cleanup_func);
        if (!args)
            goto bad;
        res = PyObject_CallObject(reg, args);
        if (!res)
            goto bad;
        ret = 0;
    }
bad:
    Py_XDECREF(cleanup_func);
    Py_XDECREF(atexit);
    Py_XDECREF(reg);
    Py_XDECREF(args);
    Py_XDECREF(res);
    return ret;
}
#endif

/* 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

/* 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);
}

/* None */
static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void) {
  int err;
  #ifdef WITH_THREAD
  PyGILState_STATE _save = PyGILState_Ensure();
  #endif
  err = !!PyErr_Occurred();
  #ifdef WITH_THREAD
  PyGILState_Release(_save);
  #endif
  return err;
}

/* 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;\
    }

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_PetscInt(PetscInt value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const PetscInt neg_one = (PetscInt) -1, const_zero = (PetscInt) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(PetscInt) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(PetscInt) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(PetscInt) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(PetscInt) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(PetscInt) <= 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(PetscInt),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE PetscInt __Pyx_PyInt_As_PetscInt(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const PetscInt neg_one = (PetscInt) -1, const_zero = (PetscInt) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(PetscInt) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(PetscInt, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (PetscInt) 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 (PetscInt) 0;
                case  1: __PYX_VERIFY_RETURN_INT(PetscInt, digit, digits[0])
                case 2:
                    if (8 * sizeof(PetscInt) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscInt, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscInt) >= 2 * PyLong_SHIFT) {
                            return (PetscInt) (((((PetscInt)digits[1]) << PyLong_SHIFT) | (PetscInt)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(PetscInt) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscInt, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscInt) >= 3 * PyLong_SHIFT) {
                            return (PetscInt) (((((((PetscInt)digits[2]) << PyLong_SHIFT) | (PetscInt)digits[1]) << PyLong_SHIFT) | (PetscInt)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(PetscInt) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscInt, 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(PetscInt) >= 4 * PyLong_SHIFT) {
                            return (PetscInt) (((((((((PetscInt)digits[3]) << PyLong_SHIFT) | (PetscInt)digits[2]) << PyLong_SHIFT) | (PetscInt)digits[1]) << PyLong_SHIFT) | (PetscInt)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 (PetscInt) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(PetscInt) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(PetscInt, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(PetscInt) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(PetscInt, 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 (PetscInt) 0;
                case -1: __PYX_VERIFY_RETURN_INT(PetscInt, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(PetscInt,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(PetscInt) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscInt, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscInt) - 1 > 2 * PyLong_SHIFT) {
                            return (PetscInt) (((PetscInt)-1)*(((((PetscInt)digits[1]) << PyLong_SHIFT) | (PetscInt)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(PetscInt) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscInt, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscInt) - 1 > 2 * PyLong_SHIFT) {
                            return (PetscInt) ((((((PetscInt)digits[1]) << PyLong_SHIFT) | (PetscInt)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(PetscInt) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscInt, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscInt) - 1 > 3 * PyLong_SHIFT) {
                            return (PetscInt) (((PetscInt)-1)*(((((((PetscInt)digits[2]) << PyLong_SHIFT) | (PetscInt)digits[1]) << PyLong_SHIFT) | (PetscInt)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(PetscInt) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscInt, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscInt) - 1 > 3 * PyLong_SHIFT) {
                            return (PetscInt) ((((((((PetscInt)digits[2]) << PyLong_SHIFT) | (PetscInt)digits[1]) << PyLong_SHIFT) | (PetscInt)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(PetscInt) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscInt, 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(PetscInt) - 1 > 4 * PyLong_SHIFT) {
                            return (PetscInt) (((PetscInt)-1)*(((((((((PetscInt)digits[3]) << PyLong_SHIFT) | (PetscInt)digits[2]) << PyLong_SHIFT) | (PetscInt)digits[1]) << PyLong_SHIFT) | (PetscInt)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(PetscInt) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscInt, 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(PetscInt) - 1 > 4 * PyLong_SHIFT) {
                            return (PetscInt) ((((((((((PetscInt)digits[3]) << PyLong_SHIFT) | (PetscInt)digits[2]) << PyLong_SHIFT) | (PetscInt)digits[1]) << PyLong_SHIFT) | (PetscInt)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(PetscInt) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(PetscInt, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(PetscInt) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(PetscInt, 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
            PetscInt 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 (PetscInt) -1;
        }
    } else {
        PetscInt val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (PetscInt) -1;
        val = __Pyx_PyInt_As_PetscInt(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to PetscInt");
    return (PetscInt) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to PetscInt");
    return (PetscInt) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    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_int(int value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    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);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_MatSORType(MatSORType value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const MatSORType neg_one = (MatSORType) -1, const_zero = (MatSORType) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(MatSORType) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(MatSORType) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(MatSORType) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(MatSORType) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(MatSORType) <= 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(MatSORType),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE PetscBool __Pyx_PyInt_As_PetscBool(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const PetscBool neg_one = (PetscBool) -1, const_zero = (PetscBool) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(PetscBool) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(PetscBool, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (PetscBool) 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 (PetscBool) 0;
                case  1: __PYX_VERIFY_RETURN_INT(PetscBool, digit, digits[0])
                case 2:
                    if (8 * sizeof(PetscBool) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscBool, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscBool) >= 2 * PyLong_SHIFT) {
                            return (PetscBool) (((((PetscBool)digits[1]) << PyLong_SHIFT) | (PetscBool)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(PetscBool) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscBool, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscBool) >= 3 * PyLong_SHIFT) {
                            return (PetscBool) (((((((PetscBool)digits[2]) << PyLong_SHIFT) | (PetscBool)digits[1]) << PyLong_SHIFT) | (PetscBool)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(PetscBool) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscBool, 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(PetscBool) >= 4 * PyLong_SHIFT) {
                            return (PetscBool) (((((((((PetscBool)digits[3]) << PyLong_SHIFT) | (PetscBool)digits[2]) << PyLong_SHIFT) | (PetscBool)digits[1]) << PyLong_SHIFT) | (PetscBool)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 (PetscBool) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(PetscBool) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(PetscBool, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(PetscBool) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(PetscBool, 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 (PetscBool) 0;
                case -1: __PYX_VERIFY_RETURN_INT(PetscBool, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(PetscBool,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(PetscBool) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscBool, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscBool) - 1 > 2 * PyLong_SHIFT) {
                            return (PetscBool) (((PetscBool)-1)*(((((PetscBool)digits[1]) << PyLong_SHIFT) | (PetscBool)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(PetscBool) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscBool, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscBool) - 1 > 2 * PyLong_SHIFT) {
                            return (PetscBool) ((((((PetscBool)digits[1]) << PyLong_SHIFT) | (PetscBool)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(PetscBool) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscBool, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscBool) - 1 > 3 * PyLong_SHIFT) {
                            return (PetscBool) (((PetscBool)-1)*(((((((PetscBool)digits[2]) << PyLong_SHIFT) | (PetscBool)digits[1]) << PyLong_SHIFT) | (PetscBool)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(PetscBool) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscBool, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(PetscBool) - 1 > 3 * PyLong_SHIFT) {
                            return (PetscBool) ((((((((PetscBool)digits[2]) << PyLong_SHIFT) | (PetscBool)digits[1]) << PyLong_SHIFT) | (PetscBool)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(PetscBool) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscBool, 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(PetscBool) - 1 > 4 * PyLong_SHIFT) {
                            return (PetscBool) (((PetscBool)-1)*(((((((((PetscBool)digits[3]) << PyLong_SHIFT) | (PetscBool)digits[2]) << PyLong_SHIFT) | (PetscBool)digits[1]) << PyLong_SHIFT) | (PetscBool)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(PetscBool) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(PetscBool, 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(PetscBool) - 1 > 4 * PyLong_SHIFT) {
                            return (PetscBool) ((((((((((PetscBool)digits[3]) << PyLong_SHIFT) | (PetscBool)digits[2]) << PyLong_SHIFT) | (PetscBool)digits[1]) << PyLong_SHIFT) | (PetscBool)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(PetscBool) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(PetscBool, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(PetscBool) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(PetscBool, 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
            PetscBool 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 (PetscBool) -1;
        }
    } else {
        PetscBool val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (PetscBool) -1;
        val = __Pyx_PyInt_As_PetscBool(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to PetscBool");
    return (PetscBool) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to PetscBool");
    return (PetscBool) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_NormType(NormType value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const NormType neg_one = (NormType) -1, const_zero = (NormType) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(NormType) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(NormType) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(NormType) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(NormType) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(NormType) <= 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(NormType),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    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;
}

/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    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;
}

/* 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;
}

/* FunctionImport */
#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* 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 */
