/* Generated by Cython 0.24 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [
            "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/cysignals/pxi.h", 
            "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/cysignals/struct_signals.h"
        ], 
        "extra_link_args": [
            "-lpari", 
            "-Ddummy"
        ], 
        "include_dirs": [
            "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/cysignals", 
            "/Users/slabbe/Applications/sage-git/local/include", 
            "/Users/slabbe/Applications/sage-git/local/include/python2.7", 
            "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.9-x86_64.egg/numpy/core/include", 
            "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages", 
            "/Users/slabbe/Applications/sage-git/local/lib/python2.7/site-packages/sage/ext"
        ]
    }
}
END: Cython Metadata */

#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 < 0x03020000)
    #error Cython requires Python 2.6+ or Python 3.2+.
#else
#define CYTHON_ABI "0_24"
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
  #define CYTHON_USE_PYLONG_INTERNALS 1
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
#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"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyType_Type
#endif
#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
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #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(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#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
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !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
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
typedef struct {
    unaryfunc am_await;
    unaryfunc am_aiter;
    unaryfunc am_anext;
} __Pyx_PyAsyncMethodsStruct;
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#else
#define __Pyx_PyType_AsAsync(obj) NULL
#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
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)

#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#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


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

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

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

#define __PYX_HAVE__slabbe__mult_cont_frac
#define __PYX_HAVE_API__slabbe__mult_cont_frac
#include "struct_signals.h"
#include "pxi.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#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_DEFAULT 0
#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)))  )
#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) && defined (_M_X64)
    #define __Pyx_sst_abs(value) _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 char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_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)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#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));
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


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

static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static 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[] = {
  "slabbe/mult_cont_frac.pyx",
  "stringsource",
  "signals.pxi",
};

/*--- Type declarations ---*/
struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm;
struct __pyx_obj_6slabbe_14mult_cont_frac_Brun;
struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse;
struct __pyx_obj_6slabbe_14mult_cont_frac_ARP;
struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy;
struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare;
struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer;
struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive;
struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Brun;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_BrunMulti;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Selmer;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Meester;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARP;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARPMulti;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Poincare;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevert;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARMonteil;
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Delaunay;
struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerron;
struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditif;
struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr;
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr;
struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d;
struct __pyx_ctuple_double__and_double;
typedef struct __pyx_ctuple_double__and_double __pyx_ctuple_double__and_double;

/* "slabbe/mult_cont_frac.pyx":112
 * include "cysignals/signals.pxi"   # ctrl-c interrupt block support
 * 
 * cdef struct PairPoint3d:             # <<<<<<<<<<<<<<
 *     double x
 *     double y
 */
struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d {
  double x;
  double y;
  double z;
  double u;
  double v;
  double w;
  int branch;
};

/* "slabbe/mult_cont_frac.pyx":3591
 *     return P
 * 
 * cdef inline (double, double) projection3to2(double x, double y, double z):             # <<<<<<<<<<<<<<
 *     cdef double s = -SQRT3SUR2 * x + SQRT3SUR2 * y
 *     cdef double t = -.5 * x -.5 * y + z
 */
struct __pyx_ctuple_double__and_double {
  double f0;
  double f1;
};

/* "slabbe/mult_cont_frac.pyx":127
 * "lime", "olive", "magenta", "purple", "teal", "violet"]
 * 
 * cdef class MCFAlgorithm(object):             # <<<<<<<<<<<<<<
 *     ########################################
 *     # METHODS IMPLEMENTED IN HERITED CLASSES
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm {
  PyObject_HEAD
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_vtab;
};


/* "slabbe/mult_cont_frac.pyx":2117
 *         print float(len(S) / ndivs**2)
 * 
 * cdef class Brun(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Brun {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2214
 *                 123: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 * cdef class Reverse(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2312
 *                 4:  WordMorphism({1: [2,3], 2: [1,3], 3: [1,2]})}
 * 
 * cdef class ARP(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_ARP {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2424
 *                 231: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 * cdef class ArnouxRauzy(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2510
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]})}
 * cdef class Poincare(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2591
 *                 231: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 * cdef class Selmer(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2688
 *                 213: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 * cdef class FullySubtractive(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2774
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]})}
 * 
 * cdef class Cassaigne(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2855
 *                 2:  WordMorphism({1: [2], 2: [1], 3: [2,3]})}
 * 
 * cdef class Sorted_Brun(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Brun {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2898
 *         return Sort(P)
 * 
 * cdef class Sorted_BrunMulti(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_BrunMulti {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2921
 *         return Sort(P)
 * 
 * cdef class Sorted_Selmer(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Selmer {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2943
 *         return Sort(P)
 * 
 * cdef class Sorted_Meester(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Meester {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":2967
 *         return Sort(P)
 * 
 * cdef class Sorted_ArnouxRauzy(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":3009
 *         return Sort(R)
 * 
 * cdef class Sorted_ArnouxRauzyMulti(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":3024
 *         return Sort(P)
 * 
 * cdef class Sorted_ARP(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARP {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":3060
 *             return _Sorted_Poincare(P)
 * 
 * cdef class Sorted_ARPMulti(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARPMulti {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":3083
 *             return _Sorted_Poincare(P)
 * 
 * cdef class Sorted_Poincare(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Poincare {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":3124
 *         return Sort(R)
 * 
 * cdef class Sorted_ARrevert(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevert {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":3178
 *         return R
 * 
 * cdef class Sorted_ARrevertMulti(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":3233
 *         return R
 * 
 * cdef class Sorted_ARMonteil(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARMonteil {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":3273
 * 
 *         return Sort(R)
 * cdef class Sorted_Delaunay(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Delaunay {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":3306
 *         else:
 *             return _Sorted_Meester(P)
 * cdef class JacobiPerron(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerron {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":3349
 * 
 *         return R
 * cdef class JacobiPerronAdditif(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditif {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":3395
 *             raise ValueError("jacobi not defined for (x,y,z)=(%s,%s,%s)"%(P.x,P.y,P.z))
 *         return R
 * cdef class JacobiPerronAdditifv2(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};


/* "slabbe/mult_cont_frac.pyx":274
 *         return
 * 
 *     def _test_coherence(self, int n_iterations=1000):             # <<<<<<<<<<<<<<
 *         r"""
 *         Check coherence between substitutions and the algo.
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence {
  PyObject_HEAD
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self;
};


/* "slabbe/mult_cont_frac.pyx":291
 *         cdef PairPoint3d P, R
 * 
 *         A = dict((k,s.incidence_matrix()) for k,s in self.substitutions().iteritems())             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr {
  PyObject_HEAD
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *__pyx_outer_scope;
  PyObject *__pyx_v_k;
  PyObject *__pyx_v_s;
};


/* "slabbe/mult_cont_frac.pyx":466
 *         return f()
 * 
 *     def coding_iterator(self, start):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator {
  PyObject_HEAD
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  double __pyx_v_s;
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self;
  PyObject *__pyx_v_start;
};


/* "slabbe/mult_cont_frac.pyx":530
 *         return cocycle.word_to_matrix(L)
 * 
 *     def simplex_orbit_iterator(self, start=None, norm_xyz='sup', norm_uvw='1'):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator {
  PyObject_HEAD
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  PyObject *__pyx_v_norm_uvw;
  PyObject *__pyx_v_norm_xyz;
  double __pyx_v_s;
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self;
  PyObject *__pyx_v_start;
};


/* "slabbe/mult_cont_frac.pyx":906
 *         return L
 * 
 *     def cone_orbit_iterator(self, start=None):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator {
  PyObject_HEAD
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self;
  PyObject *__pyx_v_start;
};


/* "slabbe/mult_cont_frac.pyx":1425
 *     # COMBINATORICS METHODS
 *     ######################
 *     def s_adic_word(self, v=None, n_iterations=100, nth_letter=1):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the s-adic word obtained from application of the MCF
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word {
  PyObject_HEAD
  PyObject *__pyx_v_A;
  PyObject *__pyx_v_ZZ;
  PyObject *__pyx_v_v;
};


/* "slabbe/mult_cont_frac.pyx":1505
 *             v = (random(), random(), random())
 *         D = self.substitutions()
 *         if all(a in ZZ for a in v):             # <<<<<<<<<<<<<<
 *             S = []
 *             it = self.cone_orbit_iterator(v)
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr {
  PyObject_HEAD
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *__pyx_outer_scope;
  PyObject *__pyx_v_a;
};


/* "slabbe/mult_cont_frac.pyx":1511
 *             for A,B,b in it:
 *                 sig_check()
 *                 if not all(a in ZZ for a in A):             # <<<<<<<<<<<<<<
 *                     raise ValueError("On input={}, algorithm {} reaches"
 *                             " non integer entries {}".format(v, self.name(), A))
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr {
  PyObject_HEAD
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *__pyx_outer_scope;
  PyObject *__pyx_v_a;
};


/* "slabbe/mult_cont_frac.pyx":1579
 *         return D
 * 
 *     def e_one_star_patch(self, v, n):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the n-th iterated patch of normal vector v.
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch {
  PyObject_HEAD
  PyObject *__pyx_v_D;
  PyObject *__pyx_v_keys;
};


/* "slabbe/mult_cont_frac.pyx":1601
 *         keys = [next(it) for _ in range(n)]
 *         D = self.dual_substitutions()
 *         L = prod(D[key] for key in reversed(keys))             # <<<<<<<<<<<<<<
 *         dual_sub = E1Star(L)
 *         cube = Patch([Face((1,0,0),1), Face((0,1,0),2), Face((0,0,1),3)])
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr {
  PyObject_HEAD
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *__pyx_outer_scope;
  PyObject *__pyx_v_key;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
};


/* "slabbe/mult_cont_frac.pyx":1695
 *         return fig
 * 
 *     def natural_extension_plot(self, n_iterations, norm_xyz='1',             # <<<<<<<<<<<<<<
 *             norm_uvw='1', axis_off=False):
 *         r"""
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot {
  PyObject_HEAD
  PyObject *__pyx_v_c;
};


/* "slabbe/mult_cont_frac.pyx":1921
 *         return TikzPicture(s, packages=['pgfplots'])
 * 
 *     def natural_extension_part_png(self, n_iterations, draw,             # <<<<<<<<<<<<<<
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     xrange=(-.866, .866),
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png {
  PyObject_HEAD
  PyObject *__pyx_v_branch_order;
};


/* "slabbe/mult_cont_frac.pyx":2045
 *         return img
 * 
 *     def measure_evaluation(self, n_iterations, draw,             # <<<<<<<<<<<<<<
 *                                 norm_xyz='1', norm_uvw='1',
 *                                 xrange=(-.866, .866),
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation {
  PyObject_HEAD
  PyObject *__pyx_v_L;
};


/* "slabbe/mult_cont_frac.pyx":2105
 * 
 *         if draw.endswith('left'):
 *             S = set((p[0],p[1]) for p in L)             # <<<<<<<<<<<<<<
 *         elif draw.endswith('right'):
 *             S = set((p[2],p[3]) for p in L)
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr {
  PyObject_HEAD
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *__pyx_outer_scope;
  PyObject *__pyx_v_p;
};


/* "slabbe/mult_cont_frac.pyx":2107
 *             S = set((p[0],p[1]) for p in L)
 *         elif draw.endswith('right'):
 *             S = set((p[2],p[3]) for p in L)             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Unkown value for draw(={})".format(draw))
 */
struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr {
  PyObject_HEAD
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *__pyx_outer_scope;
  PyObject *__pyx_v_p;
};



/* "slabbe/mult_cont_frac.pyx":127
 * "lime", "olive", "magenta", "purple", "teal", "violet"]
 * 
 * cdef class MCFAlgorithm(object):             # <<<<<<<<<<<<<<
 *     ########################################
 *     # METHODS IMPLEMENTED IN HERITED CLASSES
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*call)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d);
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;


/* "slabbe/mult_cont_frac.pyx":2117
 *         print float(len(S) / ndivs**2)
 * 
 * cdef class Brun(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Brun {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Brun *__pyx_vtabptr_6slabbe_14mult_cont_frac_Brun;


/* "slabbe/mult_cont_frac.pyx":2214
 *                 123: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 * cdef class Reverse(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Reverse {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Reverse *__pyx_vtabptr_6slabbe_14mult_cont_frac_Reverse;


/* "slabbe/mult_cont_frac.pyx":2312
 *                 4:  WordMorphism({1: [2,3], 2: [1,3], 3: [1,2]})}
 * 
 * cdef class ARP(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_ARP {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_ARP *__pyx_vtabptr_6slabbe_14mult_cont_frac_ARP;


/* "slabbe/mult_cont_frac.pyx":2424
 *                 231: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 * cdef class ArnouxRauzy(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_ArnouxRauzy {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_ArnouxRauzy *__pyx_vtabptr_6slabbe_14mult_cont_frac_ArnouxRauzy;


/* "slabbe/mult_cont_frac.pyx":2510
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]})}
 * cdef class Poincare(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Poincare {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Poincare *__pyx_vtabptr_6slabbe_14mult_cont_frac_Poincare;


/* "slabbe/mult_cont_frac.pyx":2591
 *                 231: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 * cdef class Selmer(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Selmer {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Selmer *__pyx_vtabptr_6slabbe_14mult_cont_frac_Selmer;


/* "slabbe/mult_cont_frac.pyx":2688
 *                 213: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 * cdef class FullySubtractive(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_FullySubtractive {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_FullySubtractive *__pyx_vtabptr_6slabbe_14mult_cont_frac_FullySubtractive;


/* "slabbe/mult_cont_frac.pyx":2774
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]})}
 * 
 * cdef class Cassaigne(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Cassaigne {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Cassaigne *__pyx_vtabptr_6slabbe_14mult_cont_frac_Cassaigne;


/* "slabbe/mult_cont_frac.pyx":2855
 *                 2:  WordMorphism({1: [2], 2: [1], 3: [2,3]})}
 * 
 * cdef class Sorted_Brun(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Brun {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Brun *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Brun;


/* "slabbe/mult_cont_frac.pyx":2898
 *         return Sort(P)
 * 
 * cdef class Sorted_BrunMulti(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_BrunMulti {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_BrunMulti *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_BrunMulti;


/* "slabbe/mult_cont_frac.pyx":2921
 *         return Sort(P)
 * 
 * cdef class Sorted_Selmer(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Selmer {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Selmer *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Selmer;


/* "slabbe/mult_cont_frac.pyx":2943
 *         return Sort(P)
 * 
 * cdef class Sorted_Meester(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Meester {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Meester *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Meester;


/* "slabbe/mult_cont_frac.pyx":2967
 *         return Sort(P)
 * 
 * cdef class Sorted_ArnouxRauzy(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy;


/* "slabbe/mult_cont_frac.pyx":3009
 *         return Sort(R)
 * 
 * cdef class Sorted_ArnouxRauzyMulti(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti;


/* "slabbe/mult_cont_frac.pyx":3024
 *         return Sort(P)
 * 
 * cdef class Sorted_ARP(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARP {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARP *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARP;


/* "slabbe/mult_cont_frac.pyx":3060
 *             return _Sorted_Poincare(P)
 * 
 * cdef class Sorted_ARPMulti(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARPMulti {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARPMulti *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARPMulti;


/* "slabbe/mult_cont_frac.pyx":3083
 *             return _Sorted_Poincare(P)
 * 
 * cdef class Sorted_Poincare(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Poincare {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Poincare *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Poincare;


/* "slabbe/mult_cont_frac.pyx":3124
 *         return Sort(R)
 * 
 * cdef class Sorted_ARrevert(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARrevert {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARrevert *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARrevert;


/* "slabbe/mult_cont_frac.pyx":3178
 *         return R
 * 
 * cdef class Sorted_ARrevertMulti(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti;


/* "slabbe/mult_cont_frac.pyx":3233
 *         return R
 * 
 * cdef class Sorted_ARMonteil(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARMonteil {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARMonteil *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARMonteil;


/* "slabbe/mult_cont_frac.pyx":3273
 * 
 *         return Sort(R)
 * cdef class Sorted_Delaunay(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Delaunay {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Delaunay *__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Delaunay;


/* "slabbe/mult_cont_frac.pyx":3306
 *         else:
 *             return _Sorted_Meester(P)
 * cdef class JacobiPerron(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_JacobiPerron {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_JacobiPerron *__pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerron;


/* "slabbe/mult_cont_frac.pyx":3349
 * 
 *         return R
 * cdef class JacobiPerronAdditif(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_JacobiPerronAdditif {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_JacobiPerronAdditif *__pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerronAdditif;


/* "slabbe/mult_cont_frac.pyx":3395
 *             raise ValueError("jacobi not defined for (x,y,z)=(%s,%s,%s)"%(P.x,P.y,P.z))
 *         return R
 * cdef class JacobiPerronAdditifv2(MCFAlgorithm):             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 *         r"""
 */

struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 {
  struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_base;
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 *__pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2;

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

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

/* PyThreadStateGet.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = PyThreadState_GET();
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#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);
#else
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

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

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

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

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

/* GetModuleGlobalName.proto */
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);

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

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

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

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

/* SaveResetException.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#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

/* PyErrExceptionMatches.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#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

/* GetException.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#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

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

/* PyObjectCallMethod0.proto */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

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

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

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

/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

/* UnpackTupleError.proto */
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);

/* UnpackTuple2.proto */
static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** value1, PyObject** value2,
                                             int is_tuple, int has_known_size, int decref_tuple);

/* dict_iter.proto */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_is_dict);
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
                                              PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

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

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

/* DictGetItem.proto */
#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()) {
            PyObject* args = PyTuple_Pack(1, key);
            if (likely(args))
                PyErr_SetObject(PyExc_KeyError, args);
            Py_XDECREF(args);
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#else
    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif

/* PyIntBinop.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\
    PyObject_RichCompare(op1, op2, Py_EQ)
    #endif

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

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

/* IterNext.proto */
#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);

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

/* IncludeStringH.proto */
#include <string.h>

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* StrEquals.proto */
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

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

/* pyobject_as_double.proto */
static double __Pyx__PyObject_AsDouble(PyObject* obj);
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyObject_AsDouble(obj)\
(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) :\
 likely(PyInt_CheckExact(obj)) ?\
 PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
#else
#define __Pyx_PyObject_AsDouble(obj)\
((likely(PyFloat_CheckExact(obj))) ?\
 PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
#endif

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

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* append.proto */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

/* PyFloatBinop.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyFloat_SubtractObjC(PyObject *op1, PyObject *op2, double floatval, int inplace);
#else
#define __Pyx_PyFloat_SubtractObjC(op1, op2, floatval, inplace)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

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

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

/* pop.proto */
static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L);
#define __Pyx_PyObject_Pop(L) (likely(PyList_CheckExact(L)) ?\
    __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L))
#else
#define __Pyx_PyList_Pop(L)  __Pyx__PyObject_Pop(L)
#define __Pyx_PyObject_Pop(L)  __Pyx__PyObject_Pop(L)
#endif

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod0.proto */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CallUnboundCMethod0(cfunc, self)\
    ((likely((cfunc)->func)) ?\
        (likely((cfunc)->flag == METH_NOARGS) ?  (*((cfunc)->func))(self, NULL) :\
         (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ?  ((*(PyCFunctionWithKeywords)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
             ((cfunc)->flag == METH_VARARGS ?  (*((cfunc)->func))(self, __pyx_empty_tuple) : __Pyx__CallUnboundCMethod0(cfunc, self)))) :\
        __Pyx__CallUnboundCMethod0(cfunc, self))
#else
#define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
#endif

/* PyIntBinop.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

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

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* CythonFunction.proto */
#define __Pyx_CyFunction_USED 1
#include <structmember.h>
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f)\
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
    PyObject *func_weakreflist;
#endif
    PyObject *func_dict;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj;
    void *defaults;
    int defaults_pyobjects;
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
    __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __pyx_CyFunction_init(void);

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

/* SliceObject.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

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

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

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

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

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

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

struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d;
static PyObject* __pyx_convert__to_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d s);
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

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

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

/* PrintOne.proto */
static int __Pyx_PrintOne(PyObject* stream, PyObject *o);

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

/* SwapException.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#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

/* CoroutineBase.proto */
typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyObject *);
typedef struct {
    PyObject_HEAD
    __pyx_coroutine_body_t body;
    PyObject *closure;
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
    PyObject *gi_weakreflist;
    PyObject *classobj;
    PyObject *yieldfrom;
    PyObject *gi_name;
    PyObject *gi_qualname;
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(PyTypeObject *type, __pyx_coroutine_body_t body,
                                                   PyObject *closure, PyObject *name, PyObject *qualname);
static int __Pyx_Coroutine_clear(PyObject *self);
#if 1 || PY_VERSION_HEX < 0x030300B0
static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue);
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue)
#endif

/* PatchModuleWithCoroutine.proto */
static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);

/* PatchGeneratorABC.proto */
static int __Pyx_patch_abc(void);

/* Generator.proto */
#define __Pyx_Generator_USED
static PyTypeObject *__pyx_GeneratorType = 0;
#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
#define __Pyx_Generator_New(body, closure, name, qualname)\
    __Pyx__Coroutine_New(__pyx_GeneratorType, body, closure, name, qualname)
static PyObject *__Pyx_Generator_Next(PyObject *self);
static int __pyx_Generator_init(void);

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

/* PyIdentifierFromString.proto */
#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

/* ModuleImport.proto */
static PyObject *__Pyx_ImportModule(const char *name);

/* VoidPtrImport.proto */
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);

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

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_12MCFAlgorithm_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, CYTHON_UNUSED struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_4Brun_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Brun *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_7Reverse_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_3ARP_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_11ArnouxRauzy_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_8Poincare_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_6Selmer_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_16FullySubtractive_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_9Cassaigne_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_11Sorted_Brun_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Brun *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_16Sorted_BrunMulti_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_BrunMulti *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_13Sorted_Selmer_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Selmer *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_14Sorted_Meester_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Meester *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_18Sorted_ArnouxRauzy_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_23Sorted_ArnouxRauzyMulti_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_10Sorted_ARP_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARP *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_15Sorted_ARPMulti_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARPMulti *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_15Sorted_Poincare_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Poincare *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_15Sorted_ARrevert_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevert *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_20Sorted_ARrevertMulti_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_16Sorted_ARMonteil_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARMonteil *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_15Sorted_Delaunay_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Delaunay *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_12JacobiPerron_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerron *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_19JacobiPerronAdditif_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditif *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_21JacobiPerronAdditifv2_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto*/

/* Module declarations from 'cysignals.__init__' */

/* Module declarations from 'cysignals' */

/* Module declarations from 'cysignals.signals' */
static cysigs_t *__pyx_vp_9cysignals_7signals_cysigs = 0;
#define cysigs (*__pyx_vp_9cysignals_7signals_cysigs)
static void (*__pyx_f_9cysignals_7signals_print_backtrace)(void); /*proto*/
static void (*__pyx_f_9cysignals_7signals__sig_on_interrupt_received)(void); /*proto*/
static void (*__pyx_f_9cysignals_7signals__sig_on_recover)(void); /*proto*/
static void (*__pyx_f_9cysignals_7signals__sig_off_warning)(char const *, int); /*proto*/

/* Module declarations from 'slabbe.mult_cont_frac' */
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Brun = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Reverse = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_ARP = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_ArnouxRauzy = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Poincare = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Selmer = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_FullySubtractive = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Cassaigne = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_Brun = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_BrunMulti = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_Selmer = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_Meester = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ARP = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ARPMulti = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_Poincare = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ARrevert = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ARMonteil = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_Sorted_Delaunay = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_JacobiPerron = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_JacobiPerronAdditif = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr = 0;
static PyTypeObject *__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr = 0;
static double __pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2;
static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac__Poincare(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d); /*proto*/
static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac__Sorted_ArnouxRauzy(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d); /*proto*/
static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac__Sorted_ArnouxRauzyMulti(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d); /*proto*/
static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac__Sorted_Poincare(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d); /*proto*/
static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac__Sorted_Meester(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d); /*proto*/
static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_Sort(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d); /*proto*/
static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "slabbe.mult_cont_frac"
int __pyx_module_is_main_slabbe__mult_cont_frac = 0;

/* Implementation of 'slabbe.mult_cont_frac' */
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_NotImplemented;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_reversed;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_map;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_KeyError;
static const char __pyx_k_[] = "{} != {}\n";
static const char __pyx_k_1[] = "1";
static const char __pyx_k_A[] = "A";
static const char __pyx_k_D[] = "D";
static const char __pyx_k_P[] = "P";
static const char __pyx_k_X[] = "X";
static const char __pyx_k_Y[] = "Y";
static const char __pyx_k_b[] = "b";
static const char __pyx_k_c[] = "c";
static const char __pyx_k_g[] = "g";
static const char __pyx_k_k[] = "k";
static const char __pyx_k_m[] = "m";
static const char __pyx_k_n[] = "n";
static const char __pyx_k_o[] = "o";
static const char __pyx_k_r[] = "r";
static const char __pyx_k_u[] = "u";
static const char __pyx_k_v[] = "v";
static const char __pyx_k_w[] = "w";
static const char __pyx_k_x[] = "x";
static const char __pyx_k_y[] = "y";
static const char __pyx_k_z[] = "z";
static const char __pyx_k_3d[] = "3d";
static const char __pyx_k_ZZ[] = "ZZ";
static const char __pyx_k_ha[] = "ha";
static const char __pyx_k_va[] = "va";
static const char __pyx_k_1pt[] = "1pt";
static const char __pyx_k__17[] = "*";
static const char __pyx_k__27[] = "\n";
static const char __pyx_k__28[] = "";
static const char __pyx_k__29[] = "};\n";
static const char __pyx_k_axx[] = "axx";
static const char __pyx_k_end[] = "end";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_inf[] = "inf";
static const char __pyx_k_key[] = "key";
static const char __pyx_k_log[] = "log";
static const char __pyx_k_map[] = "map";
static const char __pyx_k_pop[] = "pop";
static const char __pyx_k_red[] = "red";
static const char __pyx_k_sup[] = "sup";
static const char __pyx_k_top[] = "top";
static const char __pyx_k_zip[] = "zip";
static const char __pyx_k_Face[] = "Face";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_blue[] = "blue";
static const char __pyx_k_cyan[] = "cyan";
static const char __pyx_k_draw[] = "draw";
static const char __pyx_k_file[] = "file";
static const char __pyx_k_gray[] = "gray";
static const char __pyx_k_join[] = "join";
static const char __pyx_k_keys[] = "keys";
static const char __pyx_k_left[] = "left";
static const char __pyx_k_lime[] = "lime";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_math[] = "math";
static const char __pyx_k_name[] = "name";
static const char __pyx_k_norm[] = "norm";
static const char __pyx_k_part[] = "part";
static const char __pyx_k_pink[] = "pink";
static const char __pyx_k_plot[] = "plot";
static const char __pyx_k_prod[] = "prod";
static const char __pyx_k_send[] = "send";
static const char __pyx_k_size[] = "size";
static const char __pyx_k_sort[] = "sort";
static const char __pyx_k_teal[] = "teal";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_text[] = "text";
static const char __pyx_k_umax[] = "umax";
static const char __pyx_k_umin[] = "umin";
static const char __pyx_k_vmax[] = "vmax";
static const char __pyx_k_vmin[] = "vmin";
static const char __pyx_k_xmax[] = "xmax";
static const char __pyx_k_xmin[] = "xmin";
static const char __pyx_k_ymax[] = "ymax";
static const char __pyx_k_ymin[] = "ymin";
static const char __pyx_k_0_0_1[] = "$(0,0,1)$";
static const char __pyx_k_0_1_0[] = "$(0,1,0)$";
static const char __pyx_k_1_0_0[] = "$(1,0,0)$";
static const char __pyx_k_INPUT[] = "INPUT: ({}, {}, {}, {}, {}, {})\n";
static const char __pyx_k_Patch[] = "Patch";
static const char __pyx_k_black[] = "black";
static const char __pyx_k_brown[] = "brown";
static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_close[] = "close";
static const char __pyx_k_color[] = "color";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_green[] = "green";
static const char __pyx_k_image[] = "image";
static const char __pyx_k_index[] = "index";
static const char __pyx_k_label[] = "label";
static const char __pyx_k_ndivs[] = "ndivs";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_olive[] = "olive";
static const char __pyx_k_print[] = "print";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_right[] = "right";
static const char __pyx_k_start[] = "start";
static const char __pyx_k_throw[] = "throw";
static const char __pyx_k_title[] = "title";
static const char __pyx_k_uint8[] = "uint8";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_white[] = "white";
static const char __pyx_k_words[] = "words";
static const char __pyx_k_zeros[] = "zeros";
static const char __pyx_k_4_by_1[] = "4 by 1";
static const char __pyx_k_E1Star[] = "E1Star";
static const char __pyx_k_OUTPUT[] = "OUTPUT: ({}, {}, {}, {}, {}, {})\n";
static const char __pyx_k_append[] = "append";
static const char __pyx_k_axes3d[] = "axes3d";
static const char __pyx_k_branch[] = "branch";
static const char __pyx_k_clabel[] = "clabel";
static const char __pyx_k_domain[] = "domain";
static const char __pyx_k_figure[] = "figure";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_inline[] = "inline";
static const char __pyx_k_legend[] = "legend";
static const char __pyx_k_length[] = "length";
static const char __pyx_k_name_2[] = "__name__";
static const char __pyx_k_orange[] = "orange";
static const char __pyx_k_purple[] = "purple";
static const char __pyx_k_random[] = "random";
static const char __pyx_k_s_adic[] = "s_adic";
static const char __pyx_k_sharex[] = "sharex";
static const char __pyx_k_sharey[] = "sharey";
static const char __pyx_k_slabbe[] = "slabbe";
static const char __pyx_k_urange[] = "urange";
static const char __pyx_k_values[] = "values";
static const char __pyx_k_vector[] = "vector";
static const char __pyx_k_violet[] = "violet";
static const char __pyx_k_vrange[] = "vrange";
static const char __pyx_k_xrange[] = "xrange";
static const char __pyx_k_yellow[] = "yellow";
static const char __pyx_k_yrange[] = "yrange";
static const char __pyx_k_Algo_IN[] = "Algo IN";
static const char __pyx_k_addplot[] = "\\addplot+[";
static const char __pyx_k_contour[] = "contour";
static const char __pyx_k_cstride[] = "cstride";
static const char __pyx_k_genexpr[] = "genexpr";
static const char __pyx_k_magenta[] = "magenta";
static const char __pyx_k_randint[] = "randint";
static const char __pyx_k_rstride[] = "rstride";
static const char __pyx_k_toimage[] = "toimage";
static const char __pyx_k_verbose[] = "verbose";
static const char __pyx_k_Algo_OUT[] = "Algo OUT";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_axis_off[] = "axis_off";
static const char __pyx_k_cocycles[] = "cocycles";
static const char __pyx_k_darkgray[] = "darkgray";
static const char __pyx_k_end_axis[] = "\\end{axis}\n";
static const char __pyx_k_endswith[] = "endswith";
static const char __pyx_k_fontsize[] = "fontsize";
static const char __pyx_k_marksize[] = "marksize";
static const char __pyx_k_min_part[] = "min_part";
static const char __pyx_k_norm_uvw[] = "norm_uvw";
static const char __pyx_k_norm_xyz[] = "norm_xyz";
static const char __pyx_k_packages[] = "packages";
static const char __pyx_k_pgfplots[] = "pgfplots";
static const char __pyx_k_reversed[] = "reversed";
static const char __pyx_k_subplots[] = "subplots";
static const char __pyx_k_suptitle[] = "suptitle";
static const char __pyx_k_xx_small[] = "xx-small";
static const char __pyx_k_Exception[] = "Exception";
static const char __pyx_k_Frequency[] = "Frequency";
static const char __pyx_k_NatExt_IN[] = "NatExt IN";
static const char __pyx_k_Poincar_e[] = "Poincar\\'e";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_hide_axis[] = "hide axis]";
static const char __pyx_k_iteritems[] = "iteritems";
static const char __pyx_k_lightgray[] = "lightgray";
static const char __pyx_k_set_title[] = "set_title";
static const char __pyx_k_transpose[] = "transpose";
static const char __pyx_k_NatExt_OUT[] = "NatExt OUT";
static const char __pyx_k_PGF_COLORS[] = "PGF_COLORS";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_class_name[] = "class_name";
static const char __pyx_k_color_dict[] = "color_dict";
static const char __pyx_k_group_size[] = "group_size";
static const char __pyx_k_image_left[] = "image_left";
static const char __pyx_k_markersize[] = "markersize";
static const char __pyx_k_matplotlib[] = "matplotlib";
static const char __pyx_k_nth_letter[] = "nth_letter";
static const char __pyx_k_projection[] = "projection";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_scipy_misc[] = "scipy.misc";
static const char __pyx_k_set_zlabel[] = "set_zlabel";
static const char __pyx_k_startswith[] = "startswith";
static const char __pyx_k_TikzPicture[] = "TikzPicture";
static const char __pyx_k_add_subplot[] = "add_subplot";
static const char __pyx_k_axis_cs_s_s[] = "(axis cs:%s, %s)";
static const char __pyx_k_collections[] = "collections";
static const char __pyx_k_coordinates[] = "coordinates {\n";
static const char __pyx_k_defaultdict[] = "defaultdict";
static const char __pyx_k_discrepancy[] = "discrepancy";
static const char __pyx_k_domain_left[] = "domain_left";
static const char __pyx_k_draw_dashed[] = "\\draw[dashed] ";
static const char __pyx_k_finite_word[] = "finite_word";
static const char __pyx_k_image_right[] = "image_right";
static const char __pyx_k_mark_size_s[] = "mark size=%s,";
static const char __pyx_k_markerscale[] = "markerscale";
static const char __pyx_k_mathbf_a__n[] = "$\\mathbf{a}_n$";
static const char __pyx_k_mathbf_x__n[] = "$\\mathbf{x}_n$";
static const char __pyx_k_s_adic_word[] = "s_adic_word";
static const char __pyx_k_u_f_v_f_w_f[] = "u=%f, v=%f, w=%f";
static const char __pyx_k_x_f_y_f_z_f[] = "x=%f, y=%f, z=%f";
static const char __pyx_k_Compositions[] = "Compositions";
static const char __pyx_k_WordMorphism[] = "WordMorphism";
static const char __pyx_k_branch_order[] = "branch_order";
static const char __pyx_k_domain_right[] = "domain_right";
static const char __pyx_k_hypersurface[] = "hypersurface";
static const char __pyx_k_n_iterations[] = "n_iterations";
static const char __pyx_k_set_axis_off[] = "set_axis_off";
static const char __pyx_k_set_figwidth[] = "set_figwidth";
static const char __pyx_k_coordinates_s[] = "coordinates {%s};";
static const char __pyx_k_end_groupplot[] = "\\end{groupplot}";
static const char __pyx_k_mark_size_s_2[] = "mark size=%s]\n";
static const char __pyx_k_nextgroupplot[] = "\\nextgroupplot";
static const char __pyx_k_set_figheight[] = "set_figheight";
static const char __pyx_k_substitutions[] = "substitutions";
static const char __pyx_k_tikzlibraries[] = "tikzlibraries";
static const char __pyx_k_AttributeError[] = "AttributeError";
static const char __pyx_k_NotImplemented[] = "NotImplemented";
static const char __pyx_k_abelian_vector[] = "abelian_vector";
static const char __pyx_k_mathbf_a___n_1[] = "$\\mathbf{a}_{n+1}$";
static const char __pyx_k_mathbf_x___n_1[] = "$\\mathbf{x}_{n+1}$";
static const char __pyx_k_matrix_cocycle[] = "matrix_cocycle";
static const char __pyx_k_plot_wireframe[] = "plot_wireframe";
static const char __pyx_k_word_to_matrix[] = "word_to_matrix";
static const char __pyx_k_Algo_s_nbiter_s[] = "Algo=%s, nbiter=%s";
static const char __pyx_k_begin_groupplot[] = "\\begin{groupplot}";
static const char __pyx_k_c_but_vector_is[] = "c={} but vector is {}";
static const char __pyx_k_coding_iterator[] = "coding_iterator";
static const char __pyx_k_create_sub_plot[] = "create_sub_plot";
static const char __pyx_k_end_tikzpicture[] = "\\end{tikzpicture}";
static const char __pyx_k_legend_marksize[] = "legend_marksize";
static const char __pyx_k_limit_nb_points[] = "limit_nb_points";
static const char __pyx_k_only_marks_mark[] = "only marks,mark=*,";
static const char __pyx_k_set_xticklabels[] = "set_xticklabels";
static const char __pyx_k_set_yticklabels[] = "set_yticklabels";
static const char __pyx_k_addlegendentry_s[] = "\\addlegendentry{%s}";
static const char __pyx_k_incidence_matrix[] = "incidence_matrix";
static const char __pyx_k_sage_misc_misc_c[] = "sage.misc.misc_c";
static const char __pyx_k_Fully_Subtractive[] = "Fully Subtractive";
static const char __pyx_k_end_tikzpicture_2[] = "\\end{tikzpicture}\n";
static const char __pyx_k_matplotlib_pyplot[] = "matplotlib.pyplot";
static const char __pyx_k_sage_misc_prandom[] = "sage.misc.prandom";
static const char __pyx_k_addlegendentry_s_2[] = "\\addlegendentry{%s}\n ";
static const char __pyx_k_dual_substitutions[] = "dual_substitutions";
static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
static const char __pyx_k_cone_orbit_iterator[] = "cone_orbit_iterator";
static const char __pyx_k_on_the_th_iteration[] = "on the {}-th iteration\n";
static const char __pyx_k_pgfplots_groupplots[] = "pgfplots.groupplots";
static const char __pyx_k_height_7cm_width_8cm[] = "height=7cm,width=8cm,";
static const char __pyx_k_mark_options_color_s[] = "mark options={color=%s}] ";
static const char __pyx_k_mpl_toolkits_mplot3d[] = "mpl_toolkits.mplot3d";
static const char __pyx_k_Taking_points_for_key[] = "Taking {} points for key {}";
static const char __pyx_k_Unkown_value_for_draw[] = "Unkown value for draw(={})";
static const char __pyx_k_node_at_axis_cs_s_s_s[] = "\\node at (axis cs:%s, %s) {%s};";
static const char __pyx_k_node_left_mathbf_e__1[] = " node[left] {$\\mathbf{e}_1$} -- ";
static const char __pyx_k_slabbe_mult_cont_frac[] = "slabbe.mult_cont_frac";
static const char __pyx_k_Arnoux_Rauzy_Poincar_e[] = "Arnoux-Rauzy-Poincar\\'e";
static const char __pyx_k_invariant_measure_dict[] = "_invariant_measure_dict";
static const char __pyx_k_natural_extention_dict[] = "_natural_extention_dict";
static const char __pyx_k_node_right_mathbf_e__2[] = " node[right] {$\\mathbf{e}_2$} -- ";
static const char __pyx_k_simplex_orbit_iterator[] = "simplex_orbit_iterator";
static const char __pyx_k_draw_dashed_axis_cs_s_s[] = "\\draw[dashed] \n(axis cs:%s, %s)";
static const char __pyx_k_sage_rings_integer_ring[] = "sage.rings.integer_ring";
static const char __pyx_k_scal_prod_x_y_z_u_v_w_f[] = "scal prod <(x,y,z),(u,v,w)> = %f";
static const char __pyx_k_Arnoux_is_not_defined_on[] = "Arnoux is not defined on {}";
static const char __pyx_k_The_problem_is_on_branch[] = "The problem is on branch {}\n";
static const char __pyx_k_Unknown_value_for_norm_s[] = "Unknown value for norm(=%s)";
static const char __pyx_k_group_style_group_size_s[] = "[group style={group size=%s},";
static const char __pyx_k_sage_combinat_e_one_star[] = "sage.combinat.e_one_star";
static const char __pyx_k_begin_tikzpicture_scale_7[] = "\\begin{tikzpicture}[scale=.7]";
static const char __pyx_k_node_to_group_c3r1_center[] = "node {$\\to$}     (group c3r1.center);";
static const char __pyx_k_sage_combinat_composition[] = "sage.combinat.composition";
static const char __pyx_k_s_adic_word_locals_genexpr[] = "s_adic_word.<locals>.genexpr";
static const char __pyx_k_On_input_algorithm_loops_on[] = "On input={}, algorithm {} loops on {}";
static const char __pyx_k_begin_tikzpicture_scale_7_2[] = "\\begin{tikzpicture}[scale=.7]\n";
static const char __pyx_k_simplex_orbit_filtered_list[] = "simplex_orbit_filtered_list";
static const char __pyx_k_MCFAlgorithm_coding_iterator[] = "MCFAlgorithm.coding_iterator";
static const char __pyx_k_Unknown_value_for_norm_uvw_s[] = "Unknown value for norm_uvw(=%s)";
static const char __pyx_k_Unknown_value_for_norm_xyz_s[] = "Unknown value for norm_xyz(=%s)";
static const char __pyx_k_node_above_mathbf_e__3_cycle[] = " node[above] {$\\mathbf{e}_3$} -- cycle;";
static const char __pyx_k_node_times_group_c2r1_center[] = "node {$\\times$}  (group c2r1.center);";
static const char __pyx_k_node_times_group_c4r1_center[] = "node {$\\times$}  (group c4r1.center);";
static const char __pyx_k_pixels_touchs_parmi_limage_2[] = "{} pixels touch\303\251s parmi limage {}^2 ";
static const char __pyx_k_sage_combinat_words_morphism[] = "sage.combinat.words.morphism";
static const char __pyx_k_test_coherence_locals_genexpr[] = "_test_coherence.<locals>.genexpr";
static const char __pyx_k_Users_slabbe_GitHgSvn_slabbe_0[] = "/Users/slabbe/GitHgSvn/slabbe-0.3b0/slabbe/mult_cont_frac.pyx";
static const char __pyx_k_node_above_mathbf_e__3_cycle_2[] = " node[above] {$\\mathbf{e}_3$} -- cycle;\n";
static const char __pyx_k_node_right_mathbf_e__2_axis_cs[] = " node[right] {$\\mathbf{e}_2$} -- \n(axis cs:%s, %s)";
static const char __pyx_k_3_dimensional_continued_fractio[] = "{} 3-dimensional continued fraction algorithm";
static const char __pyx_k_Multidimensional_Continued_Frac[] = "\nMultidimensional Continued Fraction Algorithms\n\nEXAMPLES::\n\n    sage: from slabbe.mult_cont_frac import Brun\n    sage: algo = Brun()\n\nOrbit in the cone (with dual coordinates)::\n\n    sage: algo.cone_orbit_list((10,23,15), 6)\n    [(10.0, 8.0, 15.0, 1.0, 1.0, 2.0, 132),\n     (10.0, 8.0, 5.0, 3.0, 1.0, 2.0, 213),\n     (2.0, 8.0, 5.0, 3.0, 4.0, 2.0, 321),\n     (2.0, 3.0, 5.0, 3.0, 4.0, 6.0, 132),\n     (2.0, 3.0, 2.0, 3.0, 10.0, 6.0, 123),\n     (2.0, 1.0, 2.0, 3.0, 10.0, 16.0, 132)]\n\nOrbit in the simplex::\n\n    sage: algo.simplex_orbit_list((10,23,15), 3)\n    [(0.30303030303030304,\n      0.24242424242424246,\n      0.45454545454545453,\n      0.25,\n      0.25,\n      0.5,\n      132),\n     (0.43478260869565216,\n      0.3478260869565218,\n      0.21739130434782603,\n      0.5,\n      0.16666666666666666,\n      0.3333333333333333,\n      213),\n     (0.13333333333333328,\n      0.5333333333333334,\n      0.3333333333333333,\n      0.33333333333333337,\n      0.4444444444444445,\n      0.22222222222222224,\n      321)]\n\nDrawing the natural extension::\n\n    sage: fig = algo.natural_extension_plot(3000, norm_xyz='1', axis_off=True)\n    sage: fig\n    <matplotlib.figure.Figure object at ...>\n    sage: fig.savefig('a.png')  # not tested\n\nDrawing the invariant measure::\n\n    sage: fig = algo.invariant_measure_wireframe_plot(10^6, 50)\n    sage: fig\n    <matplotlib.figure.Figure object at ...>\n    sage: fig.savefig('a.png')  # not tested\n\nWord with given frequencies::\n\n    sage: algo.s_adic_word((1,e,pi))\n    word: 1232323123233231232332312323123232312323...\n\nConstruction of the same s-adic word from the substitutions and the coding\niterator::\n\n    sage: from itertools import repeat\n    sage: D = algo.substitutions()\n    sage: it = algo.coding_iterator((1,e,pi))\n    sage: words.s_adic(it, repeat(1), D)\n    word: 1232323123233231232332312323123232312323...\n\n.. TODO::\n\n    - Ajout les algo de reuteneaour, nogueira, autres?""\n    - Allow 2d, 1d, 4d, algorithms\n    - utilise les vecteurs pour les plus grandes dimensions?\n\n    - Replace method ``_natural_extention_dict`` by ``simplex_orbit_filtered_list``\n    - Use ``simplex_orbit_filtered_list`` for ``invariant_measure`` ?\n\n    - Essayer d'utiliser @staticmethod pour call pour que ARP puisse\n      apeler Poincare. Without the cython Error: Cannot call a static\n      method on an instance variable.\n      https://groups.google.com/d/topic/sage-support/DRI_s31D8ks/discussion\n\nQuestion:\n\n    - Comment factoriser le code sans utiliser les yield?\n    - Comment faire un appel de fonction rapide (pour factoriser le code)\n\nAUTHORS:\n\n - S\303\251bastien Labb\303\251, Invariant measures, Lyapounov exponents and natural\n   extensions for a dozen of algorithms, October 2013.\n - S\303\251bastien Labb\303\251, Cleaning the code, Fall 2015\n\n";
static const char __pyx_k_This_algo_does_not_preserve_the[] = "This algo does not preserve the scalar product\n";
static const char __pyx_k_addplot_only_marks_mark_mark_op[] = "\\addplot+[only marks,mark=*,mark options={color=%s},";
static const char __pyx_k_begin_axis_height_7cm_width_8cm[] = "\\begin{axis}[height=7cm,width=8cm,\nxmin=-1.1,xmax=1.1,ymin=-.6,ymax=1.20,\nhide axis]\n";
static const char __pyx_k_draw_draw_none_group_c1r1_cente[] = "\\draw[draw=none] (group c1r1.center) -- ";
static const char __pyx_k_draw_draw_none_group_c2r1_cente[] = "\\draw[draw=none] (group c2r1.center) -- ";
static const char __pyx_k_draw_draw_none_group_c3r1_cente[] = "\\draw[draw=none] (group c3r1.center) -- ";
static const char __pyx_k_e_one_star_patch_locals_genexpr[] = "e_one_star_patch.<locals>.genexpr";
static const char __pyx_k_limit_case_reach_set_of_measure[] = "limit case: reach set of measure zero: {}";
static const char __pyx_k_node_left_mathbf_e__1_axis_cs_s[] = " node[left] {$\\mathbf{e}_1$} -- \n(axis cs:%s, %s)";
static const char __pyx_k_xmin_1_1_xmax_1_1_ymin_6_ymax_1[] = "xmin=-1.1,xmax=1.1,ymin=-.6,ymax=1.20,";
static const char __pyx_k_Density_of_an_orbit_for_algorith[] = "Density of an orbit for\n{} algorithm";
static const char __pyx_k_Incoherence_between_the_definiti[] = "Incoherence between the definition of algo \n";
static const char __pyx_k_MCFAlgorithm_cone_orbit_iterator[] = "MCFAlgorithm.cone_orbit_iterator";
static const char __pyx_k_MCFAlgorithm_simplex_orbit_itera[] = "MCFAlgorithm.simplex_orbit_iterator";
static const char __pyx_k_Matrix_cocyle_not_implemented_fo[] = "Matrix cocyle not implemented for {}";
static const char __pyx_k_No_value_specified_for_struct_at[] = "No value specified for struct attribute 'x'";
static const char __pyx_k_On_input_algorithm_reaches_non_i[] = "On input={}, algorithm {} reaches non integer entries {}";
static const char __pyx_k_Taking_only_points_instead_of_fo[] = "Taking only {} points instead of {} for key {}";
static const char __pyx_k_Transpose_of_substitution_do_not[] = "Transpose of substitution {} do not match with dual substitution for algo  {}";
static const char __pyx_k_and_the_associated_substitutions[] = "and the associated substitutions.\n";
static const char __pyx_k_jacobi_not_defined_for_x_y_z_s_s[] = "jacobi not defined for (x,y,z)=(%s,%s,%s)";
static const char __pyx_k_legend_image_post_style_mark_siz[] = "legend image post style={mark size=%s},";
static const char __pyx_k_measure_evaluation_locals_genexp[] = "measure_evaluation.<locals>.genexpr";
static const char __pyx_k_natural_extension_part_png_local[] = "natural_extension_part_png.<locals>.<lambda>";
static const char __pyx_k_natural_extension_plot_locals_cr[] = "natural_extension_plot.<locals>.create_sub_plot";
static const char __pyx_k_ndivs_s_must_be_less_or_equal_to[] = "ndivs(=%s) must be less or equal to %s";
static const char __pyx_k_nombre_diterations_dans_la_fenet[] = "nombre diterations dans la fenetre : ";
static const char __pyx_k_sage_combinat_words_word_generat[] = "sage.combinat.words.word_generators";
static const char __pyx_k_sage_modules_free_module_element[] = "sage.modules.free_module_element";
static const char __pyx_k_scal_prod_x_y_z_u_v_w_f_after_al[] = "scal prod <(x,y,z),(u,v,w)> = %f (after algo)";
static const char __pyx_k_when_ndivs_is_specified_you_must[] = "when ndivs is specified, you must provide a value for xmin, xmax, ymin, ymax, umin, umax, vmin and vmax";
static const char __pyx_k_Incoherence_between_the_definiti_2[] = "Incoherence between the definition of algo (dual) \n";
static const char __pyx_k_No_value_specified_for_struct_at_2[] = "No value specified for struct attribute 'y'";
static const char __pyx_k_No_value_specified_for_struct_at_3[] = "No value specified for struct attribute 'z'";
static const char __pyx_k_No_value_specified_for_struct_at_4[] = "No value specified for struct attribute 'u'";
static const char __pyx_k_No_value_specified_for_struct_at_5[] = "No value specified for struct attribute 'v'";
static const char __pyx_k_No_value_specified_for_struct_at_6[] = "No value specified for struct attribute 'w'";
static const char __pyx_k_No_value_specified_for_struct_at_7[] = "No value specified for struct attribute 'branch'";
static PyObject *__pyx_kp_s_;
static PyObject *__pyx_kp_s_0_0_1;
static PyObject *__pyx_kp_s_0_1_0;
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_1_0_0;
static PyObject *__pyx_kp_s_1pt;
static PyObject *__pyx_kp_s_3_dimensional_continued_fractio;
static PyObject *__pyx_kp_s_3d;
static PyObject *__pyx_kp_s_4_by_1;
static PyObject *__pyx_n_s_A;
static PyObject *__pyx_kp_s_Algo_IN;
static PyObject *__pyx_kp_s_Algo_OUT;
static PyObject *__pyx_kp_s_Algo_s_nbiter_s;
static PyObject *__pyx_kp_s_Arnoux_Rauzy_Poincar_e;
static PyObject *__pyx_kp_s_Arnoux_is_not_defined_on;
static PyObject *__pyx_n_s_AttributeError;
static PyObject *__pyx_n_s_Compositions;
static PyObject *__pyx_n_s_D;
static PyObject *__pyx_kp_s_Density_of_an_orbit_for_algorith;
static PyObject *__pyx_n_s_E1Star;
static PyObject *__pyx_n_s_Exception;
static PyObject *__pyx_n_s_Face;
static PyObject *__pyx_n_s_Frequency;
static PyObject *__pyx_kp_s_Fully_Subtractive;
static PyObject *__pyx_kp_s_INPUT;
static PyObject *__pyx_kp_s_Incoherence_between_the_definiti;
static PyObject *__pyx_kp_s_Incoherence_between_the_definiti_2;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_n_s_MCFAlgorithm_coding_iterator;
static PyObject *__pyx_n_s_MCFAlgorithm_cone_orbit_iterator;
static PyObject *__pyx_n_s_MCFAlgorithm_simplex_orbit_itera;
static PyObject *__pyx_kp_s_Matrix_cocyle_not_implemented_fo;
static PyObject *__pyx_kp_s_NatExt_IN;
static PyObject *__pyx_kp_s_NatExt_OUT;
static PyObject *__pyx_kp_s_No_value_specified_for_struct_at;
static PyObject *__pyx_kp_s_No_value_specified_for_struct_at_2;
static PyObject *__pyx_kp_s_No_value_specified_for_struct_at_3;
static PyObject *__pyx_kp_s_No_value_specified_for_struct_at_4;
static PyObject *__pyx_kp_s_No_value_specified_for_struct_at_5;
static PyObject *__pyx_kp_s_No_value_specified_for_struct_at_6;
static PyObject *__pyx_kp_s_No_value_specified_for_struct_at_7;
static PyObject *__pyx_n_s_NotImplemented;
static PyObject *__pyx_n_s_NotImplementedError;
static PyObject *__pyx_kp_s_OUTPUT;
static PyObject *__pyx_kp_s_On_input_algorithm_loops_on;
static PyObject *__pyx_kp_s_On_input_algorithm_reaches_non_i;
static PyObject *__pyx_n_s_P;
static PyObject *__pyx_n_s_PGF_COLORS;
static PyObject *__pyx_n_s_Patch;
static PyObject *__pyx_kp_s_Poincar_e;
static PyObject *__pyx_kp_s_Taking_only_points_instead_of_fo;
static PyObject *__pyx_kp_s_Taking_points_for_key;
static PyObject *__pyx_kp_s_The_problem_is_on_branch;
static PyObject *__pyx_kp_s_This_algo_does_not_preserve_the;
static PyObject *__pyx_n_s_TikzPicture;
static PyObject *__pyx_kp_s_Transpose_of_substitution_do_not;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_kp_s_Unknown_value_for_norm_s;
static PyObject *__pyx_kp_s_Unknown_value_for_norm_uvw_s;
static PyObject *__pyx_kp_s_Unknown_value_for_norm_xyz_s;
static PyObject *__pyx_kp_s_Unkown_value_for_draw;
static PyObject *__pyx_kp_s_Users_slabbe_GitHgSvn_slabbe_0;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_s_WordMorphism;
static PyObject *__pyx_n_s_X;
static PyObject *__pyx_n_s_Y;
static PyObject *__pyx_n_s_ZZ;
static PyObject *__pyx_n_s__17;
static PyObject *__pyx_kp_s__27;
static PyObject *__pyx_kp_s__28;
static PyObject *__pyx_kp_s__29;
static PyObject *__pyx_n_s_abelian_vector;
static PyObject *__pyx_n_s_add_subplot;
static PyObject *__pyx_kp_s_addlegendentry_s;
static PyObject *__pyx_kp_s_addlegendentry_s_2;
static PyObject *__pyx_kp_s_addplot;
static PyObject *__pyx_kp_s_addplot_only_marks_mark_mark_op;
static PyObject *__pyx_kp_s_and_the_associated_substitutions;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_axes3d;
static PyObject *__pyx_kp_s_axis_cs_s_s;
static PyObject *__pyx_n_s_axis_off;
static PyObject *__pyx_n_s_axx;
static PyObject *__pyx_n_s_b;
static PyObject *__pyx_kp_s_begin_axis_height_7cm_width_8cm;
static PyObject *__pyx_kp_s_begin_groupplot;
static PyObject *__pyx_kp_s_begin_tikzpicture_scale_7;
static PyObject *__pyx_kp_s_begin_tikzpicture_scale_7_2;
static PyObject *__pyx_n_s_black;
static PyObject *__pyx_n_s_blue;
static PyObject *__pyx_n_s_branch;
static PyObject *__pyx_n_s_branch_order;
static PyObject *__pyx_n_s_brown;
static PyObject *__pyx_n_s_c;
static PyObject *__pyx_kp_s_c_but_vector_is;
static PyObject *__pyx_n_s_clabel;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_class_name;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_cocycles;
static PyObject *__pyx_n_s_coding_iterator;
static PyObject *__pyx_n_s_collections;
static PyObject *__pyx_n_s_color;
static PyObject *__pyx_n_s_color_dict;
static PyObject *__pyx_n_s_cone_orbit_iterator;
static PyObject *__pyx_n_s_contour;
static PyObject *__pyx_kp_s_coordinates;
static PyObject *__pyx_kp_s_coordinates_s;
static PyObject *__pyx_n_s_create_sub_plot;
static PyObject *__pyx_n_s_cstride;
static PyObject *__pyx_n_s_cyan;
static PyObject *__pyx_n_s_darkgray;
static PyObject *__pyx_n_s_defaultdict;
static PyObject *__pyx_n_s_discrepancy;
static PyObject *__pyx_n_s_domain;
static PyObject *__pyx_n_s_domain_left;
static PyObject *__pyx_n_s_domain_right;
static PyObject *__pyx_n_s_draw;
static PyObject *__pyx_kp_s_draw_dashed;
static PyObject *__pyx_kp_s_draw_dashed_axis_cs_s_s;
static PyObject *__pyx_kp_s_draw_draw_none_group_c1r1_cente;
static PyObject *__pyx_kp_s_draw_draw_none_group_c2r1_cente;
static PyObject *__pyx_kp_s_draw_draw_none_group_c3r1_cente;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_dual_substitutions;
static PyObject *__pyx_n_s_e_one_star_patch_locals_genexpr;
static PyObject *__pyx_n_s_end;
static PyObject *__pyx_kp_s_end_axis;
static PyObject *__pyx_kp_s_end_groupplot;
static PyObject *__pyx_kp_s_end_tikzpicture;
static PyObject *__pyx_kp_s_end_tikzpicture_2;
static PyObject *__pyx_n_s_endswith;
static PyObject *__pyx_n_s_figure;
static PyObject *__pyx_n_s_file;
static PyObject *__pyx_n_s_finite_word;
static PyObject *__pyx_n_s_fontsize;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_g;
static PyObject *__pyx_n_s_genexpr;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_gray;
static PyObject *__pyx_n_s_green;
static PyObject *__pyx_n_s_group_size;
static PyObject *__pyx_kp_s_group_style_group_size_s;
static PyObject *__pyx_n_s_ha;
static PyObject *__pyx_kp_s_height_7cm_width_8cm;
static PyObject *__pyx_kp_s_hide_axis;
static PyObject *__pyx_n_s_hypersurface;
static PyObject *__pyx_n_s_image;
static PyObject *__pyx_n_s_image_left;
static PyObject *__pyx_n_s_image_right;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_incidence_matrix;
static PyObject *__pyx_n_s_index;
static PyObject *__pyx_n_s_inf;
static PyObject *__pyx_n_s_inline;
static PyObject *__pyx_n_s_invariant_measure_dict;
static PyObject *__pyx_n_s_iteritems;
static PyObject *__pyx_kp_s_jacobi_not_defined_for_x_y_z_s_s;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_k;
static PyObject *__pyx_n_s_key;
static PyObject *__pyx_n_s_keys;
static PyObject *__pyx_n_s_label;
static PyObject *__pyx_n_s_left;
static PyObject *__pyx_n_s_legend;
static PyObject *__pyx_kp_s_legend_image_post_style_mark_siz;
static PyObject *__pyx_n_s_legend_marksize;
static PyObject *__pyx_n_s_length;
static PyObject *__pyx_n_s_lightgray;
static PyObject *__pyx_n_s_lime;
static PyObject *__pyx_kp_s_limit_case_reach_set_of_measure;
static PyObject *__pyx_n_s_limit_nb_points;
static PyObject *__pyx_n_s_log;
static PyObject *__pyx_n_s_m;
static PyObject *__pyx_n_s_magenta;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_map;
static PyObject *__pyx_kp_s_mark_options_color_s;
static PyObject *__pyx_kp_s_mark_size_s;
static PyObject *__pyx_kp_s_mark_size_s_2;
static PyObject *__pyx_n_s_markerscale;
static PyObject *__pyx_n_s_markersize;
static PyObject *__pyx_n_s_marksize;
static PyObject *__pyx_n_s_math;
static PyObject *__pyx_kp_s_mathbf_a___n_1;
static PyObject *__pyx_kp_s_mathbf_a__n;
static PyObject *__pyx_kp_s_mathbf_x___n_1;
static PyObject *__pyx_kp_s_mathbf_x__n;
static PyObject *__pyx_n_s_matplotlib;
static PyObject *__pyx_n_s_matplotlib_pyplot;
static PyObject *__pyx_n_s_matrix_cocycle;
static PyObject *__pyx_n_s_measure_evaluation_locals_genexp;
static PyObject *__pyx_n_s_min_part;
static PyObject *__pyx_n_s_mpl_toolkits_mplot3d;
static PyObject *__pyx_n_s_n;
static PyObject *__pyx_n_s_n_iterations;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_n_s_natural_extension_part_png_local;
static PyObject *__pyx_n_s_natural_extension_plot_locals_cr;
static PyObject *__pyx_n_s_natural_extention_dict;
static PyObject *__pyx_n_s_ndivs;
static PyObject *__pyx_kp_s_ndivs_s_must_be_less_or_equal_to;
static PyObject *__pyx_kp_s_nextgroupplot;
static PyObject *__pyx_kp_s_node_above_mathbf_e__3_cycle;
static PyObject *__pyx_kp_s_node_above_mathbf_e__3_cycle_2;
static PyObject *__pyx_kp_s_node_at_axis_cs_s_s_s;
static PyObject *__pyx_kp_s_node_left_mathbf_e__1;
static PyObject *__pyx_kp_s_node_left_mathbf_e__1_axis_cs_s;
static PyObject *__pyx_kp_s_node_right_mathbf_e__2;
static PyObject *__pyx_kp_s_node_right_mathbf_e__2_axis_cs;
static PyObject *__pyx_kp_s_node_times_group_c2r1_center;
static PyObject *__pyx_kp_s_node_times_group_c4r1_center;
static PyObject *__pyx_kp_s_node_to_group_c3r1_center;
static PyObject *__pyx_kp_s_nombre_diterations_dans_la_fenet;
static PyObject *__pyx_n_s_norm;
static PyObject *__pyx_n_s_norm_uvw;
static PyObject *__pyx_n_s_norm_xyz;
static PyObject *__pyx_n_s_nth_letter;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_o;
static PyObject *__pyx_n_s_olive;
static PyObject *__pyx_kp_s_on_the_th_iteration;
static PyObject *__pyx_kp_s_only_marks_mark;
static PyObject *__pyx_n_s_orange;
static PyObject *__pyx_n_s_packages;
static PyObject *__pyx_n_s_part;
static PyObject *__pyx_n_s_pgfplots;
static PyObject *__pyx_kp_s_pgfplots_groupplots;
static PyObject *__pyx_n_s_pink;
static PyObject *__pyx_kp_s_pixels_touchs_parmi_limage_2;
static PyObject *__pyx_n_s_plot;
static PyObject *__pyx_n_s_plot_wireframe;
static PyObject *__pyx_n_s_pop;
static PyObject *__pyx_n_s_print;
static PyObject *__pyx_n_s_prod;
static PyObject *__pyx_n_s_projection;
static PyObject *__pyx_n_s_purple;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_r;
static PyObject *__pyx_n_s_randint;
static PyObject *__pyx_n_s_random;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_red;
static PyObject *__pyx_n_s_reversed;
static PyObject *__pyx_n_s_right;
static PyObject *__pyx_n_s_rstride;
static PyObject *__pyx_n_s_s_adic;
static PyObject *__pyx_n_s_s_adic_word;
static PyObject *__pyx_n_s_s_adic_word_locals_genexpr;
static PyObject *__pyx_n_s_sage_combinat_composition;
static PyObject *__pyx_n_s_sage_combinat_e_one_star;
static PyObject *__pyx_n_s_sage_combinat_words_morphism;
static PyObject *__pyx_n_s_sage_combinat_words_word_generat;
static PyObject *__pyx_n_s_sage_misc_misc_c;
static PyObject *__pyx_n_s_sage_misc_prandom;
static PyObject *__pyx_n_s_sage_modules_free_module_element;
static PyObject *__pyx_n_s_sage_rings_integer_ring;
static PyObject *__pyx_kp_s_scal_prod_x_y_z_u_v_w_f;
static PyObject *__pyx_kp_s_scal_prod_x_y_z_u_v_w_f_after_al;
static PyObject *__pyx_n_s_scipy_misc;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_set_axis_off;
static PyObject *__pyx_n_s_set_figheight;
static PyObject *__pyx_n_s_set_figwidth;
static PyObject *__pyx_n_s_set_title;
static PyObject *__pyx_n_s_set_xticklabels;
static PyObject *__pyx_n_s_set_yticklabels;
static PyObject *__pyx_n_s_set_zlabel;
static PyObject *__pyx_n_s_sharex;
static PyObject *__pyx_n_s_sharey;
static PyObject *__pyx_n_s_simplex_orbit_filtered_list;
static PyObject *__pyx_n_s_simplex_orbit_iterator;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_slabbe;
static PyObject *__pyx_n_s_slabbe_mult_cont_frac;
static PyObject *__pyx_n_s_sort;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_startswith;
static PyObject *__pyx_n_s_subplots;
static PyObject *__pyx_n_s_substitutions;
static PyObject *__pyx_n_s_sup;
static PyObject *__pyx_n_s_suptitle;
static PyObject *__pyx_n_s_teal;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_test_coherence_locals_genexpr;
static PyObject *__pyx_n_s_text;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_n_s_tikzlibraries;
static PyObject *__pyx_n_s_title;
static PyObject *__pyx_n_s_toimage;
static PyObject *__pyx_n_s_top;
static PyObject *__pyx_n_s_transpose;
static PyObject *__pyx_n_s_u;
static PyObject *__pyx_kp_s_u_f_v_f_w_f;
static PyObject *__pyx_n_s_uint8;
static PyObject *__pyx_n_s_umax;
static PyObject *__pyx_n_s_umin;
static PyObject *__pyx_n_s_urange;
static PyObject *__pyx_n_s_v;
static PyObject *__pyx_n_s_va;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_n_s_vector;
static PyObject *__pyx_n_s_verbose;
static PyObject *__pyx_n_s_violet;
static PyObject *__pyx_n_s_vmax;
static PyObject *__pyx_n_s_vmin;
static PyObject *__pyx_n_s_vrange;
static PyObject *__pyx_n_s_w;
static PyObject *__pyx_kp_s_when_ndivs_is_specified_you_must;
static PyObject *__pyx_n_s_white;
static PyObject *__pyx_n_s_word_to_matrix;
static PyObject *__pyx_n_s_words;
static PyObject *__pyx_n_s_x;
static PyObject *__pyx_kp_s_x_f_y_f_z_f;
static PyObject *__pyx_n_s_xmax;
static PyObject *__pyx_n_s_xmin;
static PyObject *__pyx_kp_s_xmin_1_1_xmax_1_1_ymin_6_ymax_1;
static PyObject *__pyx_n_s_xrange;
static PyObject *__pyx_kp_s_xx_small;
static PyObject *__pyx_n_s_y;
static PyObject *__pyx_n_s_yellow;
static PyObject *__pyx_n_s_ymax;
static PyObject *__pyx_n_s_ymin;
static PyObject *__pyx_n_s_yrange;
static PyObject *__pyx_n_s_z;
static PyObject *__pyx_n_s_zeros;
static PyObject *__pyx_n_s_zip;
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_4branches(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, int __pyx_v_n_iterations); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_6_test_definition(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, int __pyx_v_n_iterations); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_8_test_dual_substitution_definition(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_15_test_coherence_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_10_test_coherence(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, int __pyx_v_n_iterations); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_12class_name(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_14name(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_16__repr__(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_18__call__(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_20__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_op); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_22matrix_cocycle(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_24coding_iterator(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_27n_matrix(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_n_iterations); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_29simplex_orbit_iterator(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_32simplex_orbit_list(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, int __pyx_v_n_iterations, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_34simplex_orbit_filtered_list(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, int __pyx_v_n_iterations, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, double __pyx_v_xmin, double __pyx_v_xmax, double __pyx_v_ymin, double __pyx_v_ymax, double __pyx_v_umin, double __pyx_v_umax, double __pyx_v_vmin, double __pyx_v_vmax, int __pyx_v_ndivs); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_36cone_orbit_iterator(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_39cone_orbit_list(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, int __pyx_v_n_iterations); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_41image(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_n_iterations); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_43_invariant_measure_dict(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, int __pyx_v_n_iterations, int __pyx_v_ndivs, CYTHON_UNUSED PyObject *__pyx_v_v, PyObject *__pyx_v_norm, PyObject *__pyx_v_verbose); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_45_natural_extention_dict(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, int __pyx_v_n_iterations, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_verbose); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_47lyapunov_exponents(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, int __pyx_v_n_iterations, PyObject *__pyx_v_verbose); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_3genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_49s_adic_word(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_v, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_nth_letter); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_51discrepancy_statistics(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_length); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_16e_one_star_patch_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_53e_one_star_patch(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_v, PyObject *__pyx_v_n); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_55invariant_measure_wireframe_plot(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_ndivs, PyObject *__pyx_v_norm); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_57invariant_measure_contour_plot(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_ndivs, PyObject *__pyx_v_norm); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_22natural_extension_plot_create_sub_plot(PyObject *__pyx_self, PyObject *__pyx_v_axx, PyObject *__pyx_v_D, PyObject *__pyx_v_title, CYTHON_UNUSED PyObject *__pyx_v_norm); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_59natural_extension_plot(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_axis_off); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_61natural_extension_tikz(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_marksize, PyObject *__pyx_v_legend_marksize, PyObject *__pyx_v_group_size); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_63natural_extension_part_tikz(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_part, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_marksize, PyObject *__pyx_v_limit_nb_points, PyObject *__pyx_v_verbose); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda4(PyObject *__pyx_self, PyObject *__pyx_v_a); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda5(PyObject *__pyx_self, PyObject *__pyx_v_a); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_65natural_extension_part_png(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_draw, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_xrange, PyObject *__pyx_v_yrange, PyObject *__pyx_v_urange, PyObject *__pyx_v_vrange, PyObject *__pyx_v_color_dict, PyObject *__pyx_v_branch_order, PyObject *__pyx_v_ndivs, CYTHON_UNUSED PyObject *__pyx_v_verbose); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_3genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_67measure_evaluation(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_draw, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_xrange, PyObject *__pyx_v_yrange, PyObject *__pyx_v_urange, PyObject *__pyx_v_vrange, PyObject *__pyx_v_ndivs, PyObject *__pyx_v_verbose); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_4Brun_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Brun *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_4Brun_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Brun *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_7Reverse_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_7Reverse_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_3ARP_name(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_3ARP_2substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_3ARP_4dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_11ArnouxRauzy_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_11ArnouxRauzy_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_8Poincare_name(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_8Poincare_2substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_8Poincare_4dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_6Selmer_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_6Selmer_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_16FullySubtractive_name(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_16FullySubtractive_2substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_16FullySubtractive_4dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_9Cassaigne_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_9Cassaigne_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne *__pyx_v_self); /* proto */
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Brun(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Reverse(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_ARP(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_ArnouxRauzy(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Poincare(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Selmer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_FullySubtractive(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Cassaigne(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_Brun(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_BrunMulti(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_Selmer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_Meester(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ARP(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ARPMulti(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_Poincare(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ARrevert(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ARMonteil(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_Delaunay(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_JacobiPerron(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_JacobiPerronAdditif(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyList_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
static PyObject *__pyx_float__5;
static PyObject *__pyx_float__8;
static PyObject *__pyx_float_1_;
static PyObject *__pyx_float_0_2;
static PyObject *__pyx_float__866;
static PyObject *__pyx_float_0_0000001;
static PyObject *__pyx_float_neg__5;
static PyObject *__pyx_float_neg__866;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_10;
static PyObject *__pyx_int_12;
static PyObject *__pyx_int_20;
static PyObject *__pyx_int_100;
static PyObject *__pyx_int_111;
static PyObject *__pyx_int_123;
static PyObject *__pyx_int_132;
static PyObject *__pyx_int_213;
static PyObject *__pyx_int_231;
static PyObject *__pyx_int_255;
static PyObject *__pyx_int_312;
static PyObject *__pyx_int_321;
static PyObject *__pyx_int_1024;
static double __pyx_k__2;
static double __pyx_k__3;
static double __pyx_k__4;
static double __pyx_k__5;
static double __pyx_k__6;
static double __pyx_k__7;
static double __pyx_k__8;
static double __pyx_k__9;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__30;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_codeobj__23;

/* "slabbe/mult_cont_frac.pyx":131
 *     # METHODS IMPLEMENTED IN HERITED CLASSES
 *     ########################################
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         This method must be implemented in the inherited classes.
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_12MCFAlgorithm_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, CYTHON_UNUSED struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":138
 * 
 *         """
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 *     def substitutions(self):
 *         r"""
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(0, 138, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":131
 *     # METHODS IMPLEMENTED IN HERITED CLASSES
 *     ########################################
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         This method must be implemented in the inherited classes.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":139
 *         """
 *         raise NotImplementedError
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         This method must be implemented in the inherited classes.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_substitutions[] = "\n        This method must be implemented in the inherited classes.\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: Brun().substitutions()\n            {123: WordMorphism: 1->1, 2->23, 3->3,\n             132: WordMorphism: 1->1, 2->2, 3->32,\n             213: WordMorphism: 1->13, 2->2, 3->3,\n             231: WordMorphism: 1->1, 2->2, 3->31,\n             312: WordMorphism: 1->12, 2->2, 3->3,\n             321: WordMorphism: 1->1, 2->21, 3->3}\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":155
 * 
 *         """
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     def dual_substitutions(self):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(0, 155, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":139
 *         """
 *         raise NotImplementedError
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         This method must be implemented in the inherited classes.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":157
 *         raise NotImplementedError
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         This method must be implemented in the inherited classes.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_2dual_substitutions[] = "\n        This method must be implemented in the inherited classes.\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: Brun().dual_substitutions()\n            {123: WordMorphism: 1->1, 2->2, 3->32,\n             132: WordMorphism: 1->1, 2->23, 3->3,\n             213: WordMorphism: 1->1, 2->2, 3->31,\n             231: WordMorphism: 1->13, 2->2, 3->3,\n             312: WordMorphism: 1->1, 2->21, 3->3,\n             321: WordMorphism: 1->12, 2->2, 3->3}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dual_substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_2dual_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dual_substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":172
 *              321: WordMorphism: 1->12, 2->2, 3->3}
 *         """
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     def branches(self, int n_iterations=1000):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(0, 172, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":157
 *         raise NotImplementedError
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         This method must be implemented in the inherited classes.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.dual_substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":174
 *         raise NotImplementedError
 * 
 *     def branches(self, int n_iterations=1000):             # <<<<<<<<<<<<<<
 *         r"""
 *         Returns the branches labels of the algorithm.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_5branches(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_4branches[] = "\n        Returns the branches labels of the algorithm.\n\n        This method is an heuristic and should be implemented in the\n        inherited classes.\n\n        EXAMPLES::\n\n            sage: import slabbe.mult_cont_frac as mcf\n            sage: mcf.Brun().branches()\n            {123, 132, 213, 231, 312, 321}\n            sage: mcf.ARP().branches()\n            {1, 2, 3, 123, 132, 213, 231, 312, 321}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_5branches(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_n_iterations;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("branches (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "branches") < 0)) __PYX_ERR(0, 174, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_n_iterations = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_n_iterations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 174, __pyx_L3_error)
    } else {
      __pyx_v_n_iterations = ((int)0x3E8);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("branches", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 174, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.branches", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_4branches(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_4branches(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, int __pyx_v_n_iterations) {
  CYTHON_UNUSED unsigned int __pyx_v_i;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  PyObject *__pyx_v_S = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("branches", 0);

  /* "slabbe/mult_cont_frac.pyx":191
 *         cdef unsigned int i         # loop counter
 *         cdef PairPoint3d P
 *         S = set()             # <<<<<<<<<<<<<<
 *         # Loop
 *         for i from 0 <= i < n_iterations:
 */
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_S = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":193
 *         S = set()
 *         # Loop
 *         for i from 0 <= i < n_iterations:             # <<<<<<<<<<<<<<
 * 
 *             # Check for Keyboard interupt
 */
  __pyx_t_2 = __pyx_v_n_iterations;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "slabbe/mult_cont_frac.pyx":196
 * 
 *             # Check for Keyboard interupt
 *             sig_check()             # <<<<<<<<<<<<<<
 * 
 *             # random initial values
 */
    __pyx_t_3 = sig_check(); if (unlikely(__pyx_t_3 == 0)) __PYX_ERR(0, 196, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":199
 * 
 *             # random initial values
 *             P.x = random(); P.y = random(); P.z = random();             # <<<<<<<<<<<<<<
 *             P.u = random(); P.v = random(); P.w = random();
 * 
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 199, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.x = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 199, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.y = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 199, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.z = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":200
 *             # random initial values
 *             P.x = random(); P.y = random(); P.z = random();
 *             P.u = random(); P.v = random(); P.w = random();             # <<<<<<<<<<<<<<
 * 
 *             # Apply Algo
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.u = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.v = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.w = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":203
 * 
 *             # Apply Algo
 *             P = self.call(P)             # <<<<<<<<<<<<<<
 * 
 *             S.add(P.branch)
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self->__pyx_vtab)->call(__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 203, __pyx_L1_error)
    __pyx_v_P = __pyx_t_7;

    /* "slabbe/mult_cont_frac.pyx":205
 *             P = self.call(P)
 * 
 *             S.add(P.branch)             # <<<<<<<<<<<<<<
 *         return S
 *     ######################
 */
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_P.branch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = PySet_Add(__pyx_v_S, __pyx_t_1); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 205, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "slabbe/mult_cont_frac.pyx":206
 * 
 *             S.add(P.branch)
 *         return S             # <<<<<<<<<<<<<<
 *     ######################
 *     # TEST METHODS
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_S);
  __pyx_r = __pyx_v_S;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":174
 *         raise NotImplementedError
 * 
 *     def branches(self, int n_iterations=1000):             # <<<<<<<<<<<<<<
 *         r"""
 *         Returns the branches labels of the algorithm.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.branches", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_S);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":210
 *     # TEST METHODS
 *     ######################
 *     def _test_definition(self, int n_iterations=10000):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_7_test_definition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_6_test_definition[] = "\n        INPUT:\n\n        - ``n_iterations`` -- integer\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: Brun()._test_definition(10000)\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_7_test_definition(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_n_iterations;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_test_definition (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_test_definition") < 0)) __PYX_ERR(0, 210, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_n_iterations = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_n_iterations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 210, __pyx_L3_error)
    } else {
      __pyx_v_n_iterations = ((int)0x2710);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_test_definition", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 210, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._test_definition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_6_test_definition(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_6_test_definition(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, int __pyx_v_n_iterations) {
  double __pyx_v_s;
  double __pyx_v_t;
  unsigned int __pyx_v_i;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  PyObject *__pyx_v_m = 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;
  double __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_10;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  Py_ssize_t __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  __Pyx_RefNannySetupContext("_test_definition", 0);

  /* "slabbe/mult_cont_frac.pyx":227
 * 
 *         # Loop
 *         for i from 0 <= i < n_iterations:             # <<<<<<<<<<<<<<
 * 
 *             # Check for Keyboard interupt
 */
  __pyx_t_1 = __pyx_v_n_iterations;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "slabbe/mult_cont_frac.pyx":230
 * 
 *             # Check for Keyboard interupt
 *             sig_check()             # <<<<<<<<<<<<<<
 * 
 *             # random initial values
 */
    __pyx_t_2 = sig_check(); if (unlikely(__pyx_t_2 == 0)) __PYX_ERR(0, 230, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":233
 * 
 *             # random initial values
 *             P.x = random(); P.y = random(); P.z = random();             # <<<<<<<<<<<<<<
 *             P.u = random(); P.v = random(); P.w = random();
 *             s = P.x*P.u + P.y*P.v + P.z*P.w
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 233, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 233, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.x = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 233, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 233, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.y = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 233, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 233, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.z = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":234
 *             # random initial values
 *             P.x = random(); P.y = random(); P.z = random();
 *             P.u = random(); P.v = random(); P.w = random();             # <<<<<<<<<<<<<<
 *             s = P.x*P.u + P.y*P.v + P.z*P.w
 * 
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.u = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.v = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.w = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":235
 *             P.x = random(); P.y = random(); P.z = random();
 *             P.u = random(); P.v = random(); P.w = random();
 *             s = P.x*P.u + P.y*P.v + P.z*P.w             # <<<<<<<<<<<<<<
 * 
 *             # Apply Algo
 */
    __pyx_v_s = (((__pyx_v_P.x * __pyx_v_P.u) + (__pyx_v_P.y * __pyx_v_P.v)) + (__pyx_v_P.z * __pyx_v_P.w));

    /* "slabbe/mult_cont_frac.pyx":238
 * 
 *             # Apply Algo
 *             try:             # <<<<<<<<<<<<<<
 *                 R = self.call(P)
 *             except ValueError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      /*try:*/ {

        /* "slabbe/mult_cont_frac.pyx":239
 *             # Apply Algo
 *             try:
 *                 R = self.call(P)             # <<<<<<<<<<<<<<
 *             except ValueError:
 *                 continue
 */
        __pyx_t_10 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self->__pyx_vtab)->call(__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 239, __pyx_L5_error)
        __pyx_v_R = __pyx_t_10;

        /* "slabbe/mult_cont_frac.pyx":238
 * 
 *             # Apply Algo
 *             try:             # <<<<<<<<<<<<<<
 *                 R = self.call(P)
 *             except ValueError:
 */
      }
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L12_try_end;
      __pyx_L5_error:;
      __Pyx_PyThreadState_assign
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "slabbe/mult_cont_frac.pyx":240
 *             try:
 *                 R = self.call(P)
 *             except ValueError:             # <<<<<<<<<<<<<<
 *                 continue
 *             t = R.x*R.u + R.y*R.v + R.z*R.w
 */
      __pyx_t_2 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
      if (__pyx_t_2) {
        __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._test_definition", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5) < 0) __PYX_ERR(0, 240, __pyx_L7_except_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_5);

        /* "slabbe/mult_cont_frac.pyx":241
 *                 R = self.call(P)
 *             except ValueError:
 *                 continue             # <<<<<<<<<<<<<<
 *             t = R.x*R.u + R.y*R.v + R.z*R.w
 * 
 */
        goto __pyx_L14_except_continue;
        __pyx_L14_except_continue:;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L11_try_continue;
      }
      goto __pyx_L7_except_error;
      __pyx_L7_except_error:;

      /* "slabbe/mult_cont_frac.pyx":238
 * 
 *             # Apply Algo
 *             try:             # <<<<<<<<<<<<<<
 *                 R = self.call(P)
 *             except ValueError:
 */
      __Pyx_PyThreadState_assign
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      goto __pyx_L1_error;
      __pyx_L11_try_continue:;
      __Pyx_PyThreadState_assign
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      goto __pyx_L3_continue;
      __pyx_L12_try_end:;
    }

    /* "slabbe/mult_cont_frac.pyx":242
 *             except ValueError:
 *                 continue
 *             t = R.x*R.u + R.y*R.v + R.z*R.w             # <<<<<<<<<<<<<<
 * 
 *             if not abs(s - t) < 0.0000001:
 */
    __pyx_v_t = (((__pyx_v_R.x * __pyx_v_R.u) + (__pyx_v_R.y * __pyx_v_R.v)) + (__pyx_v_R.z * __pyx_v_R.w));

    /* "slabbe/mult_cont_frac.pyx":244
 *             t = R.x*R.u + R.y*R.v + R.z*R.w
 * 
 *             if not abs(s - t) < 0.0000001:             # <<<<<<<<<<<<<<
 *                 m = 'This algo does not preserve the scalar product\n'
 *                 m += '{} != {}\n'.format(s,t)
 */
    __pyx_t_11 = ((!((fabs((__pyx_v_s - __pyx_v_t)) < 0.0000001) != 0)) != 0);
    if (__pyx_t_11) {

      /* "slabbe/mult_cont_frac.pyx":245
 * 
 *             if not abs(s - t) < 0.0000001:
 *                 m = 'This algo does not preserve the scalar product\n'             # <<<<<<<<<<<<<<
 *                 m += '{} != {}\n'.format(s,t)
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 */
      __Pyx_INCREF(__pyx_kp_s_This_algo_does_not_preserve_the);
      __pyx_v_m = __pyx_kp_s_This_algo_does_not_preserve_the;

      /* "slabbe/mult_cont_frac.pyx":246
 *             if not abs(s - t) < 0.0000001:
 *                 m = 'This algo does not preserve the scalar product\n'
 *                 m += '{} != {}\n'.format(s,t)             # <<<<<<<<<<<<<<
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 *                 m += 'on the {}-th iteration\n'.format(i)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_s); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_12 = PyFloat_FromDouble(__pyx_v_t); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = NULL;
      __pyx_t_14 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_14 = 1;
        }
      }
      __pyx_t_15 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      if (__pyx_t_13) {
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_t_12);
      __pyx_t_3 = 0;
      __pyx_t_12 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_15, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "slabbe/mult_cont_frac.pyx":247
 *                 m = 'This algo does not preserve the scalar product\n'
 *                 m += '{} != {}\n'.format(s,t)
 *                 m += 'The problem is on branch {}\n'.format(R.branch)             # <<<<<<<<<<<<<<
 *                 m += 'on the {}-th iteration\n'.format(i)
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_The_problem_is_on_branch, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 247, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_R.branch); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 247, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_12 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (!__pyx_t_12) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_12); __pyx_t_12 = NULL;
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_15);
        __pyx_t_15 = 0;
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 247, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "slabbe/mult_cont_frac.pyx":248
 *                 m += '{} != {}\n'.format(s,t)
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 *                 m += 'on the {}-th iteration\n'.format(i)             # <<<<<<<<<<<<<<
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_on_the_th_iteration, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 248, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_15 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_15) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 248, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 248, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_15); __pyx_t_15 = NULL;
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 248, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 248, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "slabbe/mult_cont_frac.pyx":249
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 *                 m += 'on the {}-th iteration\n'.format(i)
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)             # <<<<<<<<<<<<<<
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)
 *                 raise Exception(m)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_INPUT, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_12 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_15 = PyFloat_FromDouble(__pyx_v_P.z); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_13 = PyFloat_FromDouble(__pyx_v_P.u); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_16 = PyFloat_FromDouble(__pyx_v_P.v); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = PyFloat_FromDouble(__pyx_v_P.w); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_18 = NULL;
      __pyx_t_14 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_18)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_18);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_14 = 1;
        }
      }
      __pyx_t_19 = PyTuple_New(6+__pyx_t_14); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      if (__pyx_t_18) {
        __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_18); __pyx_t_18 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_14, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_14, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_19, 2+__pyx_t_14, __pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_19, 3+__pyx_t_14, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_19, 4+__pyx_t_14, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_19, 5+__pyx_t_14, __pyx_t_17);
      __pyx_t_12 = 0;
      __pyx_t_3 = 0;
      __pyx_t_15 = 0;
      __pyx_t_13 = 0;
      __pyx_t_16 = 0;
      __pyx_t_17 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_19, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 249, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "slabbe/mult_cont_frac.pyx":250
 *                 m += 'on the {}-th iteration\n'.format(i)
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)             # <<<<<<<<<<<<<<
 *                 raise Exception(m)
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_OUTPUT, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_19 = PyFloat_FromDouble(__pyx_v_R.x); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_17 = PyFloat_FromDouble(__pyx_v_R.y); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_16 = PyFloat_FromDouble(__pyx_v_R.z); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_13 = PyFloat_FromDouble(__pyx_v_R.u); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_15 = PyFloat_FromDouble(__pyx_v_R.v); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_R.w); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_12 = NULL;
      __pyx_t_14 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_14 = 1;
        }
      }
      __pyx_t_18 = PyTuple_New(6+__pyx_t_14); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      if (__pyx_t_12) {
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_12); __pyx_t_12 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_19);
      PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_14, __pyx_t_19);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_14, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_18, 2+__pyx_t_14, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_18, 3+__pyx_t_14, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_18, 4+__pyx_t_14, __pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_18, 5+__pyx_t_14, __pyx_t_3);
      __pyx_t_19 = 0;
      __pyx_t_17 = 0;
      __pyx_t_16 = 0;
      __pyx_t_13 = 0;
      __pyx_t_15 = 0;
      __pyx_t_3 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "slabbe/mult_cont_frac.pyx":251
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)
 *                 raise Exception(m)             # <<<<<<<<<<<<<<
 * 
 *         return
 */
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 251, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_m);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_Exception, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 251, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 251, __pyx_L1_error)

      /* "slabbe/mult_cont_frac.pyx":244
 *             t = R.x*R.u + R.y*R.v + R.z*R.w
 * 
 *             if not abs(s - t) < 0.0000001:             # <<<<<<<<<<<<<<
 *                 m = 'This algo does not preserve the scalar product\n'
 *                 m += '{} != {}\n'.format(s,t)
 */
    }
    __pyx_L3_continue:;
  }

  /* "slabbe/mult_cont_frac.pyx":253
 *                 raise Exception(m)
 * 
 *         return             # <<<<<<<<<<<<<<
 * 
 *     def _test_dual_substitution_definition(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":210
 *     # TEST METHODS
 *     ######################
 *     def _test_definition(self, int n_iterations=10000):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._test_definition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_m);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":255
 *         return
 * 
 *     def _test_dual_substitution_definition(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_9_test_dual_substitution_definition(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_8_test_dual_substitution_definition[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: t = Brun()._test_dual_substitution_definition()\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_9_test_dual_substitution_definition(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_test_dual_substitution_definition (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_8_test_dual_substitution_definition(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_8_test_dual_substitution_definition(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self) {
  PyObject *__pyx_v_A = NULL;
  PyObject *__pyx_v_B = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_b = 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;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  __Pyx_RefNannySetupContext("_test_dual_substitution_definition", 0);

  /* "slabbe/mult_cont_frac.pyx":262
 *             sage: t = Brun()._test_dual_substitution_definition()
 *         """
 *         A = self.substitutions()             # <<<<<<<<<<<<<<
 *         B = self.dual_substitutions()
 *         assert set(A.keys()) == set(B.keys())
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_substitutions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_A = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":263
 *         """
 *         A = self.substitutions()
 *         B = self.dual_substitutions()             # <<<<<<<<<<<<<<
 *         assert set(A.keys()) == set(B.keys())
 *         for key in A:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dual_substitutions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_B = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":264
 *         A = self.substitutions()
 *         B = self.dual_substitutions()
 *         assert set(A.keys()) == set(B.keys())             # <<<<<<<<<<<<<<
 *         for key in A:
 *             a = A[key].incidence_matrix()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PySet_New(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_B, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PySet_New(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 264, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_5)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 264, __pyx_L1_error)
    }
  }
  #endif

  /* "slabbe/mult_cont_frac.pyx":265
 *         B = self.dual_substitutions()
 *         assert set(A.keys()) == set(B.keys())
 *         for key in A:             # <<<<<<<<<<<<<<
 *             a = A[key].incidence_matrix()
 *             b = B[key].incidence_matrix()
 */
  if (likely(PyList_CheckExact(__pyx_v_A)) || PyTuple_CheckExact(__pyx_v_A)) {
    __pyx_t_1 = __pyx_v_A; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_A); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 265, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 265, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 265, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 265, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "slabbe/mult_cont_frac.pyx":266
 *         assert set(A.keys()) == set(B.keys())
 *         for key in A:
 *             a = A[key].incidence_matrix()             # <<<<<<<<<<<<<<
 *             b = B[key].incidence_matrix()
 *             if not a == b.transpose():
 */
    __pyx_t_2 = PyObject_GetItem(__pyx_v_A, __pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_incidence_matrix); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 266, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_2) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "slabbe/mult_cont_frac.pyx":267
 *         for key in A:
 *             a = A[key].incidence_matrix()
 *             b = B[key].incidence_matrix()             # <<<<<<<<<<<<<<
 *             if not a == b.transpose():
 *                 raise ValueError("Transpose of substitution {} do not "
 */
    __pyx_t_4 = PyObject_GetItem(__pyx_v_B, __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_incidence_matrix); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_b, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "slabbe/mult_cont_frac.pyx":268
 *             a = A[key].incidence_matrix()
 *             b = B[key].incidence_matrix()
 *             if not a == b.transpose():             # <<<<<<<<<<<<<<
 *                 raise ValueError("Transpose of substitution {} do not "
 *                         "match with dual substitution for algo "
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_b, __pyx_n_s_transpose); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_a, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 268, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_8 = ((!__pyx_t_5) != 0);
    if (__pyx_t_8) {

      /* "slabbe/mult_cont_frac.pyx":271
 *                 raise ValueError("Transpose of substitution {} do not "
 *                         "match with dual substitution for algo "
 *                         " {}".format(key, self.name()))             # <<<<<<<<<<<<<<
 *         return
 * 
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Transpose_of_substitution_do_not, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 271, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && 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);
        }
      }
      if (__pyx_t_10) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 271, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else {
        __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 271, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_11 = 1;
        }
      }
      __pyx_t_10 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 271, __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_INCREF(__pyx_v_key);
      __Pyx_GIVEREF(__pyx_v_key);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_11, __pyx_v_key);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_11, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "slabbe/mult_cont_frac.pyx":269
 *             b = B[key].incidence_matrix()
 *             if not a == b.transpose():
 *                 raise ValueError("Transpose of substitution {} do not "             # <<<<<<<<<<<<<<
 *                         "match with dual substitution for algo "
 *                         " {}".format(key, self.name()))
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(0, 269, __pyx_L1_error)

      /* "slabbe/mult_cont_frac.pyx":268
 *             a = A[key].incidence_matrix()
 *             b = B[key].incidence_matrix()
 *             if not a == b.transpose():             # <<<<<<<<<<<<<<
 *                 raise ValueError("Transpose of substitution {} do not "
 *                         "match with dual substitution for algo "
 */
    }

    /* "slabbe/mult_cont_frac.pyx":265
 *         B = self.dual_substitutions()
 *         assert set(A.keys()) == set(B.keys())
 *         for key in A:             # <<<<<<<<<<<<<<
 *             a = A[key].incidence_matrix()
 *             b = B[key].incidence_matrix()
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":272
 *                         "match with dual substitution for algo "
 *                         " {}".format(key, self.name()))
 *         return             # <<<<<<<<<<<<<<
 * 
 *     def _test_coherence(self, int n_iterations=1000):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":255
 *         return
 * 
 *     def _test_dual_substitution_definition(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._test_dual_substitution_definition", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_A);
  __Pyx_XDECREF(__pyx_v_B);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_b);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":274
 *         return
 * 
 *     def _test_coherence(self, int n_iterations=1000):             # <<<<<<<<<<<<<<
 *         r"""
 *         Check coherence between substitutions and the algo.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_11_test_coherence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_10_test_coherence[] = "\n        Check coherence between substitutions and the algo.\n\n        INPUT:\n\n        - ``n_iterations`` -- integer\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: t = Brun()._test_coherence()\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_11_test_coherence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_n_iterations;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_test_coherence (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_test_coherence") < 0)) __PYX_ERR(0, 274, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_n_iterations = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_n_iterations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 274, __pyx_L3_error)
    } else {
      __pyx_v_n_iterations = ((int)0x3E8);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_test_coherence", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 274, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._test_coherence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_10_test_coherence(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_15_test_coherence_2generator3(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "slabbe/mult_cont_frac.pyx":291
 *         cdef PairPoint3d P, R
 * 
 *         A = dict((k,s.incidence_matrix()) for k,s in self.substitutions().iteritems())             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_15_test_coherence_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_15_test_coherence_2generator3, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_test_coherence_locals_genexpr); if (unlikely(!gen)) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._test_coherence.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_15_test_coherence_2generator3(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __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;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 291, __pyx_L1_error)
  __pyx_r = PyDict_New(); if (unlikely(!__pyx_r)) __PYX_ERR(0, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_r);
  __pyx_t_2 = 0;
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 291, __pyx_L1_error) }
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_n_s_substitutions); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (__pyx_t_7) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(__pyx_t_5 == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    __PYX_ERR(0, 291, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_dict_iterator(__pyx_t_5, 0, __pyx_n_s_iteritems, (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_6;
  __pyx_t_6 = 0;
  while (1) {
    __pyx_t_8 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_6, &__pyx_t_5, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_8 == 0)) break;
    if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_k, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_s);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_s, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_s, __pyx_n_s_incidence_matrix); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(PyDict_SetItem(__pyx_r, (PyObject*)__pyx_cur_scope->__pyx_v_k, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":274
 *         return
 * 
 *     def _test_coherence(self, int n_iterations=1000):             # <<<<<<<<<<<<<<
 *         r"""
 *         Check coherence between substitutions and the algo.
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_10_test_coherence(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, int __pyx_v_n_iterations) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *__pyx_cur_scope;
  PyObject *__pyx_v_vector = NULL;
  unsigned int __pyx_v_i;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  PyObject *__pyx_v_A = NULL;
  PyObject *__pyx_v_M = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_m = NULL;
  PyObject *__pyx_v_Mt = NULL;
  PyObject *__pyx_r = NULL;
  __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;
  double __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  int __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  __Pyx_RefNannySetupContext("_test_coherence", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "slabbe/mult_cont_frac.pyx":287
 *             sage: t = Brun()._test_coherence()
 *         """
 *         from sage.modules.free_module_element import vector             # <<<<<<<<<<<<<<
 *         cdef unsigned int i         # loop counter
 *         cdef PairPoint3d P, R
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_vector);
  __Pyx_GIVEREF(__pyx_n_s_vector);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_vector);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_modules_free_module_element, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_vector); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_vector = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":291
 *         cdef PairPoint3d P, R
 * 
 *         A = dict((k,s.incidence_matrix()) for k,s in self.substitutions().iteritems())             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */
  __pyx_t_2 = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_15_test_coherence_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_A = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":294
 * 
 *         # Loop
 *         for i from 0 <= i < n_iterations:             # <<<<<<<<<<<<<<
 * 
 *             # Check for Keyboard interupt
 */
  __pyx_t_3 = __pyx_v_n_iterations;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "slabbe/mult_cont_frac.pyx":297
 * 
 *             # Check for Keyboard interupt
 *             sig_check()             # <<<<<<<<<<<<<<
 * 
 *             # random initial values
 */
    __pyx_t_4 = sig_check(); if (unlikely(__pyx_t_4 == 0)) __PYX_ERR(0, 297, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":300
 * 
 *             # random initial values
 *             P.x = random(); P.y = random(); P.z = random();             # <<<<<<<<<<<<<<
 *             P.u = random(); P.v = random(); P.w = random();
 * 
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 300, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.x = __pyx_t_6;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 300, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.y = __pyx_t_6;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 300, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.z = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":301
 *             # random initial values
 *             P.x = random(); P.y = random(); P.z = random();
 *             P.u = random(); P.v = random(); P.w = random();             # <<<<<<<<<<<<<<
 * 
 *             # Apply Algo
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 301, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.u = __pyx_t_6;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 301, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.v = __pyx_t_6;
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 301, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_P.w = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":304
 * 
 *             # Apply Algo
 *             try:             # <<<<<<<<<<<<<<
 *                 R = self.call(P)
 *             except ValueError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      /*try:*/ {

        /* "slabbe/mult_cont_frac.pyx":305
 *             # Apply Algo
 *             try:
 *                 R = self.call(P)             # <<<<<<<<<<<<<<
 *             except ValueError:
 *                 continue
 */
        __pyx_t_10 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->call(__pyx_cur_scope->__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 305, __pyx_L5_error)
        __pyx_v_R = __pyx_t_10;

        /* "slabbe/mult_cont_frac.pyx":304
 * 
 *             # Apply Algo
 *             try:             # <<<<<<<<<<<<<<
 *                 R = self.call(P)
 *             except ValueError:
 */
      }
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L12_try_end;
      __pyx_L5_error:;
      __Pyx_PyThreadState_assign
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "slabbe/mult_cont_frac.pyx":306
 *             try:
 *                 R = self.call(P)
 *             except ValueError:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
      __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
      if (__pyx_t_4) {
        __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._test_coherence", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_5) < 0) __PYX_ERR(0, 306, __pyx_L7_except_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_5);

        /* "slabbe/mult_cont_frac.pyx":307
 *                 R = self.call(P)
 *             except ValueError:
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             M = A[R.branch]
 */
        goto __pyx_L14_except_continue;
        __pyx_L14_except_continue:;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L11_try_continue;
      }
      goto __pyx_L7_except_error;
      __pyx_L7_except_error:;

      /* "slabbe/mult_cont_frac.pyx":304
 * 
 *             # Apply Algo
 *             try:             # <<<<<<<<<<<<<<
 *                 R = self.call(P)
 *             except ValueError:
 */
      __Pyx_PyThreadState_assign
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      goto __pyx_L1_error;
      __pyx_L11_try_continue:;
      __Pyx_PyThreadState_assign
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      goto __pyx_L3_continue;
      __pyx_L12_try_end:;
    }

    /* "slabbe/mult_cont_frac.pyx":309
 *                 continue
 * 
 *             M = A[R.branch]             # <<<<<<<<<<<<<<
 * 
 *             # Check the algo
 */
    if (unlikely(__pyx_v_A == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 309, __pyx_L1_error)
    }
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_R.branch); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 309, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_A, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_M, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":312
 * 
 *             # Check the algo
 *             s = M * vector((R.x, R.y, R.z))             # <<<<<<<<<<<<<<
 *             t = vector((P.x, P.y, P.z))
 *             if not abs(s - t) < 0.0000001:
 */
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_R.x); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 312, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_R.y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = PyFloat_FromDouble(__pyx_v_R.z); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 312, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 312, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_11);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_t_11 = 0;
    __Pyx_INCREF(__pyx_v_vector);
    __pyx_t_11 = __pyx_v_vector; __pyx_t_1 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = PyNumber_Multiply(__pyx_v_M, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 312, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_11);
    __pyx_t_11 = 0;

    /* "slabbe/mult_cont_frac.pyx":313
 *             # Check the algo
 *             s = M * vector((R.x, R.y, R.z))
 *             t = vector((P.x, P.y, P.z))             # <<<<<<<<<<<<<<
 *             if not abs(s - t) < 0.0000001:
 *                 m = 'Incoherence between the definition of algo \n'
 */
    __pyx_t_2 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 313, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_12 = PyFloat_FromDouble(__pyx_v_P.z); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 313, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_12);
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_t_12 = 0;
    __Pyx_INCREF(__pyx_v_vector);
    __pyx_t_12 = __pyx_v_vector; __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 313, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_11);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_2, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 313, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_11);
    __pyx_t_11 = 0;

    /* "slabbe/mult_cont_frac.pyx":314
 *             s = M * vector((R.x, R.y, R.z))
 *             t = vector((P.x, P.y, P.z))
 *             if not abs(s - t) < 0.0000001:             # <<<<<<<<<<<<<<
 *                 m = 'Incoherence between the definition of algo \n'
 *                 m += 'and the associated substitutions.\n'
 */
    __pyx_t_11 = PyNumber_Subtract(__pyx_v_s, __pyx_v_t); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 314, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = PyNumber_Absolute(__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 314, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = PyObject_RichCompare(__pyx_t_12, __pyx_float_0_0000001, Py_LT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 314, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 314, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_14 = ((!__pyx_t_13) != 0);
    if (__pyx_t_14) {

      /* "slabbe/mult_cont_frac.pyx":315
 *             t = vector((P.x, P.y, P.z))
 *             if not abs(s - t) < 0.0000001:
 *                 m = 'Incoherence between the definition of algo \n'             # <<<<<<<<<<<<<<
 *                 m += 'and the associated substitutions.\n'
 *                 m += '{} != {}\n'.format(s,t)
 */
      __Pyx_INCREF(__pyx_kp_s_Incoherence_between_the_definiti);
      __pyx_v_m = __pyx_kp_s_Incoherence_between_the_definiti;

      /* "slabbe/mult_cont_frac.pyx":316
 *             if not abs(s - t) < 0.0000001:
 *                 m = 'Incoherence between the definition of algo \n'
 *                 m += 'and the associated substitutions.\n'             # <<<<<<<<<<<<<<
 *                 m += '{} != {}\n'.format(s,t)
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 */
      __pyx_t_11 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_kp_s_and_the_associated_substitutions); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_11);
      __pyx_t_11 = 0;

      /* "slabbe/mult_cont_frac.pyx":317
 *                 m = 'Incoherence between the definition of algo \n'
 *                 m += 'and the associated substitutions.\n'
 *                 m += '{} != {}\n'.format(s,t)             # <<<<<<<<<<<<<<
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 *                 m += 'on the {}-th iteration\n'.format(i)
 */
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 317, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_2 = NULL;
      __pyx_t_15 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
          __pyx_t_15 = 1;
        }
      }
      __pyx_t_1 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_15, __pyx_v_s);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_15, __pyx_v_t);
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_1, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 317, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 317, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "slabbe/mult_cont_frac.pyx":318
 *                 m += 'and the associated substitutions.\n'
 *                 m += '{} != {}\n'.format(s,t)
 *                 m += 'The problem is on branch {}\n'.format(R.branch)             # <<<<<<<<<<<<<<
 *                 m += 'on the {}-th iteration\n'.format(i)
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 */
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_The_problem_is_on_branch, __pyx_n_s_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 318, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_R.branch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      if (!__pyx_t_2) {
        __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 318, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_12);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 318, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 318, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 318, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_11);
      __pyx_t_11 = 0;

      /* "slabbe/mult_cont_frac.pyx":319
 *                 m += '{} != {}\n'.format(s,t)
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 *                 m += 'on the {}-th iteration\n'.format(i)             # <<<<<<<<<<<<<<
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)
 */
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_on_the_th_iteration, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_5 = __Pyx_PyInt_From_unsigned_int(__pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 319, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_11);
      } else {
        __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_2, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 319, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "slabbe/mult_cont_frac.pyx":320
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 *                 m += 'on the {}-th iteration\n'.format(i)
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)             # <<<<<<<<<<<<<<
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)
 *                 raise Exception(m)
 */
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_INPUT, __pyx_n_s_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_P.z); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_16 = PyFloat_FromDouble(__pyx_v_P.u); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = PyFloat_FromDouble(__pyx_v_P.v); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_18 = PyFloat_FromDouble(__pyx_v_P.w); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_19 = NULL;
      __pyx_t_15 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_19)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_19);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
          __pyx_t_15 = 1;
        }
      }
      __pyx_t_20 = PyTuple_New(6+__pyx_t_15); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_20);
      if (__pyx_t_19) {
        __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_19); __pyx_t_19 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_15, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_15, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_20, 2+__pyx_t_15, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_20, 3+__pyx_t_15, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_20, 4+__pyx_t_15, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_18);
      PyTuple_SET_ITEM(__pyx_t_20, 5+__pyx_t_15, __pyx_t_18);
      __pyx_t_2 = 0;
      __pyx_t_5 = 0;
      __pyx_t_1 = 0;
      __pyx_t_16 = 0;
      __pyx_t_17 = 0;
      __pyx_t_18 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_20, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_11);
      __pyx_t_11 = 0;

      /* "slabbe/mult_cont_frac.pyx":321
 *                 m += 'on the {}-th iteration\n'.format(i)
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)             # <<<<<<<<<<<<<<
 *                 raise Exception(m)
 * 
 */
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_OUTPUT, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_20 = PyFloat_FromDouble(__pyx_v_R.x); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_20);
      __pyx_t_18 = PyFloat_FromDouble(__pyx_v_R.y); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_17 = PyFloat_FromDouble(__pyx_v_R.z); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_16 = PyFloat_FromDouble(__pyx_v_R.u); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_R.v); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_R.w); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = NULL;
      __pyx_t_15 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
          __pyx_t_15 = 1;
        }
      }
      __pyx_t_19 = PyTuple_New(6+__pyx_t_15); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_20);
      PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_15, __pyx_t_20);
      __Pyx_GIVEREF(__pyx_t_18);
      PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_15, __pyx_t_18);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_19, 2+__pyx_t_15, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_19, 3+__pyx_t_15, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_19, 4+__pyx_t_15, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_19, 5+__pyx_t_15, __pyx_t_5);
      __pyx_t_20 = 0;
      __pyx_t_18 = 0;
      __pyx_t_17 = 0;
      __pyx_t_16 = 0;
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_19, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "slabbe/mult_cont_frac.pyx":322
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)
 *                 raise Exception(m)             # <<<<<<<<<<<<<<
 * 
 *             # Check the dual coordinates
 */
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 322, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_m);
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_Exception, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 322, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_Raise(__pyx_t_11, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __PYX_ERR(0, 322, __pyx_L1_error)

      /* "slabbe/mult_cont_frac.pyx":314
 *             s = M * vector((R.x, R.y, R.z))
 *             t = vector((P.x, P.y, P.z))
 *             if not abs(s - t) < 0.0000001:             # <<<<<<<<<<<<<<
 *                 m = 'Incoherence between the definition of algo \n'
 *                 m += 'and the associated substitutions.\n'
 */
    }

    /* "slabbe/mult_cont_frac.pyx":325
 * 
 *             # Check the dual coordinates
 *             Mt = M.transpose()             # <<<<<<<<<<<<<<
 *             s = Mt * vector((P.u, P.v, P.w))
 *             t = vector((R.u, R.v, R.w))
 */
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_M, __pyx_n_s_transpose); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 325, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_19 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_19)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_19);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (__pyx_t_19) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_19); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 325, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    } else {
      __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 325, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF_SET(__pyx_v_Mt, __pyx_t_11);
    __pyx_t_11 = 0;

    /* "slabbe/mult_cont_frac.pyx":326
 *             # Check the dual coordinates
 *             Mt = M.transpose()
 *             s = Mt * vector((P.u, P.v, P.w))             # <<<<<<<<<<<<<<
 *             t = vector((R.u, R.v, R.w))
 *             if not abs(s - t) < 0.0000001:
 */
    __pyx_t_12 = PyFloat_FromDouble(__pyx_v_P.u); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_19 = PyFloat_FromDouble(__pyx_v_P.v); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_P.w); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_19);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_19);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
    __pyx_t_12 = 0;
    __pyx_t_19 = 0;
    __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_v_vector);
    __pyx_t_5 = __pyx_v_vector; __pyx_t_19 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_19)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_19);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_19) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 326, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_11);
    } else {
      __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 326, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_19); __pyx_t_19 = NULL;
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 326, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Multiply(__pyx_v_Mt, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "slabbe/mult_cont_frac.pyx":327
 *             Mt = M.transpose()
 *             s = Mt * vector((P.u, P.v, P.w))
 *             t = vector((R.u, R.v, R.w))             # <<<<<<<<<<<<<<
 *             if not abs(s - t) < 0.0000001:
 *                 m = 'Incoherence between the definition of algo (dual) \n'
 */
    __pyx_t_11 = PyFloat_FromDouble(__pyx_v_R.u); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 327, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = PyFloat_FromDouble(__pyx_v_R.v); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 327, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_R.w); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_19 = PyTuple_New(3); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 327, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_1);
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v_vector);
    __pyx_t_1 = __pyx_v_vector; __pyx_t_12 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_12) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_19); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 327, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 327, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12); __pyx_t_12 = NULL;
      __Pyx_GIVEREF(__pyx_t_19);
      PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_19);
      __pyx_t_19 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 327, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "slabbe/mult_cont_frac.pyx":328
 *             s = Mt * vector((P.u, P.v, P.w))
 *             t = vector((R.u, R.v, R.w))
 *             if not abs(s - t) < 0.0000001:             # <<<<<<<<<<<<<<
 *                 m = 'Incoherence between the definition of algo (dual) \n'
 *                 m += 'and the associated substitutions.\n'
 */
    __pyx_t_5 = PyNumber_Subtract(__pyx_v_s, __pyx_v_t); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 328, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyNumber_Absolute(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_1, __pyx_float_0_0000001, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 328, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 328, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_13 = ((!__pyx_t_14) != 0);
    if (__pyx_t_13) {

      /* "slabbe/mult_cont_frac.pyx":329
 *             t = vector((R.u, R.v, R.w))
 *             if not abs(s - t) < 0.0000001:
 *                 m = 'Incoherence between the definition of algo (dual) \n'             # <<<<<<<<<<<<<<
 *                 m += 'and the associated substitutions.\n'
 *                 m += '{} != {}\n'.format(s,t)
 */
      __Pyx_INCREF(__pyx_kp_s_Incoherence_between_the_definiti_2);
      __pyx_v_m = __pyx_kp_s_Incoherence_between_the_definiti_2;

      /* "slabbe/mult_cont_frac.pyx":330
 *             if not abs(s - t) < 0.0000001:
 *                 m = 'Incoherence between the definition of algo (dual) \n'
 *                 m += 'and the associated substitutions.\n'             # <<<<<<<<<<<<<<
 *                 m += '{} != {}\n'.format(s,t)
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 */
      __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_kp_s_and_the_associated_substitutions); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 330, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "slabbe/mult_cont_frac.pyx":331
 *                 m = 'Incoherence between the definition of algo (dual) \n'
 *                 m += 'and the associated substitutions.\n'
 *                 m += '{} != {}\n'.format(s,t)             # <<<<<<<<<<<<<<
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 *                 m += 'on the {}-th iteration\n'.format(i)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = NULL;
      __pyx_t_15 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
          __pyx_t_15 = 1;
        }
      }
      __pyx_t_19 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 331, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_INCREF(__pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_15, __pyx_v_s);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_15, __pyx_v_t);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_19, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 331, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "slabbe/mult_cont_frac.pyx":332
 *                 m += 'and the associated substitutions.\n'
 *                 m += '{} != {}\n'.format(s,t)
 *                 m += 'The problem is on branch {}\n'.format(R.branch)             # <<<<<<<<<<<<<<
 *                 m += 'on the {}-th iteration\n'.format(i)
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_The_problem_is_on_branch, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 332, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_19 = __Pyx_PyInt_From_int(__pyx_v_R.branch); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 332, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_11 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (!__pyx_t_11) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 332, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_GIVEREF(__pyx_t_19);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_19);
        __pyx_t_19 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 332, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "slabbe/mult_cont_frac.pyx":333
 *                 m += '{} != {}\n'.format(s,t)
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 *                 m += 'on the {}-th iteration\n'.format(i)             # <<<<<<<<<<<<<<
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_on_the_th_iteration, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_12 = __Pyx_PyInt_From_unsigned_int(__pyx_v_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 333, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_19 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_19)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_19);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (!__pyx_t_19) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 333, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 333, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_19); __pyx_t_19 = NULL;
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_12);
        __pyx_t_12 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 333, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "slabbe/mult_cont_frac.pyx":334
 *                 m += 'The problem is on branch {}\n'.format(R.branch)
 *                 m += 'on the {}-th iteration\n'.format(i)
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)             # <<<<<<<<<<<<<<
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)
 *                 raise Exception(m)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_INPUT, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_11 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_19 = PyFloat_FromDouble(__pyx_v_P.z); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_16 = PyFloat_FromDouble(__pyx_v_P.u); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = PyFloat_FromDouble(__pyx_v_P.v); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_18 = PyFloat_FromDouble(__pyx_v_P.w); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_20 = NULL;
      __pyx_t_15 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_20)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_20);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_15 = 1;
        }
      }
      __pyx_t_2 = PyTuple_New(6+__pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__pyx_t_20) {
        __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_20); __pyx_t_20 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_15, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_15, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_19);
      PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_15, __pyx_t_19);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_2, 3+__pyx_t_15, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_2, 4+__pyx_t_15, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_18);
      PyTuple_SET_ITEM(__pyx_t_2, 5+__pyx_t_15, __pyx_t_18);
      __pyx_t_11 = 0;
      __pyx_t_12 = 0;
      __pyx_t_19 = 0;
      __pyx_t_16 = 0;
      __pyx_t_17 = 0;
      __pyx_t_18 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "slabbe/mult_cont_frac.pyx":335
 *                 m += 'on the {}-th iteration\n'.format(i)
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)             # <<<<<<<<<<<<<<
 *                 raise Exception(m)
 *         return
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_OUTPUT, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_R.x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_18 = PyFloat_FromDouble(__pyx_v_R.y); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_17 = PyFloat_FromDouble(__pyx_v_R.z); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_16 = PyFloat_FromDouble(__pyx_v_R.u); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_19 = PyFloat_FromDouble(__pyx_v_R.v); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_12 = PyFloat_FromDouble(__pyx_v_R.w); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = NULL;
      __pyx_t_15 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
          __pyx_t_15 = 1;
        }
      }
      __pyx_t_20 = PyTuple_New(6+__pyx_t_15); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_20);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_15, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_18);
      PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_15, __pyx_t_18);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_20, 2+__pyx_t_15, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_20, 3+__pyx_t_15, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_19);
      PyTuple_SET_ITEM(__pyx_t_20, 4+__pyx_t_15, __pyx_t_19);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_20, 5+__pyx_t_15, __pyx_t_12);
      __pyx_t_2 = 0;
      __pyx_t_18 = 0;
      __pyx_t_17 = 0;
      __pyx_t_16 = 0;
      __pyx_t_19 = 0;
      __pyx_t_12 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_20, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_m, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF_SET(__pyx_v_m, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "slabbe/mult_cont_frac.pyx":336
 *                 m += 'INPUT: ({}, {}, {}, {}, {}, {})\n'.format(P.x,P.y,P.z,P.u,P.v,P.w)
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)
 *                 raise Exception(m)             # <<<<<<<<<<<<<<
 *         return
 * 
 */
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_m);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_Exception, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 336, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 336, __pyx_L1_error)

      /* "slabbe/mult_cont_frac.pyx":328
 *             s = Mt * vector((P.u, P.v, P.w))
 *             t = vector((R.u, R.v, R.w))
 *             if not abs(s - t) < 0.0000001:             # <<<<<<<<<<<<<<
 *                 m = 'Incoherence between the definition of algo (dual) \n'
 *                 m += 'and the associated substitutions.\n'
 */
    }
    __pyx_L3_continue:;
  }

  /* "slabbe/mult_cont_frac.pyx":337
 *                 m += 'OUTPUT: ({}, {}, {}, {}, {}, {})\n'.format(R.x,R.y,R.z,R.u,R.v,R.w)
 *                 raise Exception(m)
 *         return             # <<<<<<<<<<<<<<
 * 
 *     ######################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":274
 *         return
 * 
 *     def _test_coherence(self, int n_iterations=1000):             # <<<<<<<<<<<<<<
 *         r"""
 *         Check coherence between substitutions and the algo.
 */

  /* 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_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._test_coherence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_vector);
  __Pyx_XDECREF(__pyx_v_A);
  __Pyx_XDECREF(__pyx_v_M);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_m);
  __Pyx_XDECREF(__pyx_v_Mt);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":342
 *     # METHODS FOR THE USER:
 *     ######################
 *     def class_name(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_13class_name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_12class_name[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Reverse, Brun\n            sage: Reverse().class_name()\n            'Reverse'\n            sage: Brun().class_name()\n            'Brun'\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_13class_name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("class_name (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_12class_name(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_12class_name(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("class_name", 0);

  /* "slabbe/mult_cont_frac.pyx":352
 *             'Brun'
 *         """
 *         return self.__class__.__name__             # <<<<<<<<<<<<<<
 *     def name(self):
 *         r"""
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __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;

  /* "slabbe/mult_cont_frac.pyx":342
 *     # METHODS FOR THE USER:
 *     ######################
 *     def class_name(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":353
 *         """
 *         return self.__class__.__name__
 *     def name(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_15name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_14name[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Reverse, Brun\n            sage: Reverse().name()\n            'Reverse'\n            sage: Brun().name()\n            'Brun'\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_15name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("name (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_14name(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_14name(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("name", 0);

  /* "slabbe/mult_cont_frac.pyx":363
 *             'Brun'
 *         """
 *         return self.class_name()             # <<<<<<<<<<<<<<
 *     def __repr__(self):
 *         r"""
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 363, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 363, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":353
 *         """
 *         return self.__class__.__name__
 *     def name(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":364
 *         """
 *         return self.class_name()
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_16__repr__[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Reverse, Brun\n            sage: Reverse()\n            Reverse 3-dimensional continued fraction algorithm\n            sage: Brun()\n            Brun 3-dimensional continued fraction algorithm\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_6slabbe_14mult_cont_frac_12MCFAlgorithm_16__repr__;
#endif
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_16__repr__(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_16__repr__(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "slabbe/mult_cont_frac.pyx":374
 *             Brun 3-dimensional continued fraction algorithm
 *         """
 *         return "{} 3-dimensional continued fraction algorithm".format(self.name())             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, PairPoint3d P):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_3_dimensional_continued_fractio, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 374, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":364
 *         """
 *         return self.class_name()
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":376
 *         return "{} 3-dimensional continued fraction algorithm".format(self.name())
 * 
 *     def __call__(self, PairPoint3d P):             # <<<<<<<<<<<<<<
 *         r"""
 *         Wrapper for the cdef call method.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_18__call__[] = "\n        Wrapper for the cdef call method.\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: D = {'x':.3,'y':.6,'z':.8,'u':.2,'v':.3,'w':.3,'branch':999}\n            sage: E = Brun()(D)\n            sage: sorted(E.iteritems())\n            [('branch', 123),\n             ('u', 0.2),\n             ('v', 0.6),\n             ('w', 0.3),\n             ('x', 0.3),\n             ('y', 0.6),\n             ('z', 0.20000000000000007)]\n\n        ::\n\n            sage: D = {'x':3,'y':6,'z':8,'u':.2,'v':.3,'w':.3,'branch':999}\n            sage: D = Brun()(D); D\n            {'branch': 123, 'u': 0.2, 'v': 0.6, 'w': 0.3, 'x': 3.0, 'y': 6.0, 'z': 2.0}\n\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_6slabbe_14mult_cont_frac_12MCFAlgorithm_18__call__;
#endif
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_P,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_P)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 376, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_P = __pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 376, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 376, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_18__call__(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_P);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_18__call__(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "slabbe/mult_cont_frac.pyx":401
 * 
 *         """
 *         return self.call(P)             # <<<<<<<<<<<<<<
 *     def __richcmp__(self, other, op):
 *         r"""
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self->__pyx_vtab)->call(__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L1_error)
  __pyx_t_2 = __pyx_convert__to_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":376
 *         return "{} 3-dimensional continued fraction algorithm".format(self.name())
 * 
 *     def __call__(self, PairPoint3d P):             # <<<<<<<<<<<<<<
 *         r"""
 *         Wrapper for the cdef call method.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":402
 *         """
 *         return self.call(P)
 *     def __richcmp__(self, other, op):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_21__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_op); /*proto*/
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_21__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_arg_op) {
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  __pyx_v_op = __Pyx_PyInt_From_int(__pyx_arg_op); if (unlikely(!__pyx_v_op)) __PYX_ERR(0, 402, __pyx_L3_error)
  __Pyx_GOTREF(__pyx_v_op);
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_20__richcmp__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((PyObject *)__pyx_v_op));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_20__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, PyObject *__pyx_v_op) {
  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;
  __Pyx_RefNannySetupContext("__richcmp__", 0);

  /* "slabbe/mult_cont_frac.pyx":423
 *         # 4: >
 *         # 5: >=
 *         if not isinstance(other, MCFAlgorithm):             # <<<<<<<<<<<<<<
 *             return NotImplemented
 *         if op == 2 or op == 3:
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":424
 *         # 5: >=
 *         if not isinstance(other, MCFAlgorithm):
 *             return NotImplemented             # <<<<<<<<<<<<<<
 *         if op == 2 or op == 3:
 *             return other.class_name() == self.class_name()
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":423
 *         # 4: >
 *         # 5: >=
 *         if not isinstance(other, MCFAlgorithm):             # <<<<<<<<<<<<<<
 *             return NotImplemented
 *         if op == 2 or op == 3:
 */
  }

  /* "slabbe/mult_cont_frac.pyx":425
 *         if not isinstance(other, MCFAlgorithm):
 *             return NotImplemented
 *         if op == 2 or op == 3:             # <<<<<<<<<<<<<<
 *             return other.class_name() == self.class_name()
 *         else:
 */
  __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_v_op, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_v_op, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":426
 *             return NotImplemented
 *         if op == 2 or op == 3:
 *             return other.class_name() == self.class_name()             # <<<<<<<<<<<<<<
 *         else:
 *             return NotImplemented
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_class_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_class_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 426, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
      }
    }
    if (__pyx_t_6) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 426, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 426, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 426, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":425
 *         if not isinstance(other, MCFAlgorithm):
 *             return NotImplemented
 *         if op == 2 or op == 3:             # <<<<<<<<<<<<<<
 *             return other.class_name() == self.class_name()
 *         else:
 */
  }

  /* "slabbe/mult_cont_frac.pyx":428
 *             return other.class_name() == self.class_name()
 *         else:
 *             return NotImplemented             # <<<<<<<<<<<<<<
 *     ######################
 *     # DYNAMICS METHODS
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_builtin_NotImplemented);
    __pyx_r = __pyx_builtin_NotImplemented;
    goto __pyx_L0;
  }

  /* "slabbe/mult_cont_frac.pyx":402
 *         """
 *         return self.call(P)
 *     def __richcmp__(self, other, op):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":432
 *     # DYNAMICS METHODS
 *     ######################
 *     def matrix_cocycle(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_23matrix_cocycle(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_22matrix_cocycle[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import ARP\n            sage: ARP().matrix_cocycle()\n            Cocycle with 9 gens over Regular language over [1, 2, 3, \n            123, 132, 213, 231, 312, 321]\n            defined by: Automaton with 7 states\n\n        ::\n\n            sage: from slabbe.mult_cont_frac import Sorted_Brun\n            sage: Sorted_Brun().matrix_cocycle()\n            Cocycle with 3 gens over Language of finite words over alphabet\n            [1, 2, 3]\n\n        ::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: Brun().matrix_cocycle()\n            Cocycle with 6 gens over Regular language over \n            [123, 132, 213, 231, 312, 321]\n            defined by: Automaton with 6 states\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_23matrix_cocycle(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("matrix_cocycle (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_22matrix_cocycle(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_22matrix_cocycle(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self) {
  PyObject *__pyx_v_cocycles = NULL;
  PyObject *__pyx_v_f = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __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;
  __Pyx_RefNannySetupContext("matrix_cocycle", 0);

  /* "slabbe/mult_cont_frac.pyx":457
 *             defined by: Automaton with 6 states
 *         """
 *         from matrix_cocycle import cocycles             # <<<<<<<<<<<<<<
 *         try:
 *             f = getattr(cocycles, self.class_name())
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_cocycles);
  __Pyx_GIVEREF(__pyx_n_s_cocycles);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_cocycles);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_matrix_cocycle, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_cocycles); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_cocycles = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":458
 *         """
 *         from matrix_cocycle import cocycles
 *         try:             # <<<<<<<<<<<<<<
 *             f = getattr(cocycles, self.class_name())
 *         except AttributeError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "slabbe/mult_cont_frac.pyx":459
 *         from matrix_cocycle import cocycles
 *         try:
 *             f = getattr(cocycles, self.class_name())             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             msg = "Matrix cocyle not implemented for {}"
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (__pyx_t_6) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 459, __pyx_L3_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 459, __pyx_L3_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_GetAttr(__pyx_v_cocycles, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_f = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "slabbe/mult_cont_frac.pyx":458
 *         """
 *         from matrix_cocycle import cocycles
 *         try:             # <<<<<<<<<<<<<<
 *             f = getattr(cocycles, self.class_name())
 *         except AttributeError:
 */
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "slabbe/mult_cont_frac.pyx":460
 *         try:
 *             f = getattr(cocycles, self.class_name())
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             msg = "Matrix cocyle not implemented for {}"
 *             msg = msg.format(self.class_name())
 */
    __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.matrix_cocycle", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_6) < 0) __PYX_ERR(0, 460, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_6);

      /* "slabbe/mult_cont_frac.pyx":461
 *             f = getattr(cocycles, self.class_name())
 *         except AttributeError:
 *             msg = "Matrix cocyle not implemented for {}"             # <<<<<<<<<<<<<<
 *             msg = msg.format(self.class_name())
 *             raise NotImplementedError(msg)
 */
      __Pyx_INCREF(__pyx_kp_s_Matrix_cocyle_not_implemented_fo);
      __pyx_v_msg = __pyx_kp_s_Matrix_cocyle_not_implemented_fo;

      /* "slabbe/mult_cont_frac.pyx":462
 *         except AttributeError:
 *             msg = "Matrix cocyle not implemented for {}"
 *             msg = msg.format(self.class_name())             # <<<<<<<<<<<<<<
 *             raise NotImplementedError(msg)
 *         return f()
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 462, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class_name); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 462, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      if (__pyx_t_12) {
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 462, __pyx_L5_except_error)
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else {
        __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 462, __pyx_L5_except_error)
      }
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_11) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 462, __pyx_L5_except_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 462, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 462, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "slabbe/mult_cont_frac.pyx":463
 *             msg = "Matrix cocyle not implemented for {}"
 *             msg = msg.format(self.class_name())
 *             raise NotImplementedError(msg)             # <<<<<<<<<<<<<<
 *         return f()
 * 
 */
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 463, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_v_msg);
      __Pyx_GIVEREF(__pyx_v_msg);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_msg);
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 463, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 463, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "slabbe/mult_cont_frac.pyx":458
 *         """
 *         from matrix_cocycle import cocycles
 *         try:             # <<<<<<<<<<<<<<
 *             f = getattr(cocycles, self.class_name())
 *         except AttributeError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L10_try_end:;
  }

  /* "slabbe/mult_cont_frac.pyx":464
 *             msg = msg.format(self.class_name())
 *             raise NotImplementedError(msg)
 *         return f()             # <<<<<<<<<<<<<<
 * 
 *     def coding_iterator(self, start):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_f);
  __pyx_t_2 = __pyx_v_f; __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 464, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":432
 *     # DYNAMICS METHODS
 *     ######################
 *     def matrix_cocycle(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.matrix_cocycle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_cocycles);
  __Pyx_XDECREF(__pyx_v_f);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_26generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "slabbe/mult_cont_frac.pyx":466
 *         return f()
 * 
 *     def coding_iterator(self, start):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_25coding_iterator(PyObject *__pyx_v_self, PyObject *__pyx_v_start); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_24coding_iterator[] = "\n        INPUT:\n\n        - ``start`` -- iterable of three real numbers\n\n        OUTPUT:\n\n            iterator\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import ARP\n            sage: it = ARP().coding_iterator((1,e,pi))\n            sage: [next(it) for _ in range(20)]\n            [123, 2, 1, 123, 1, 231, 3, 3, 3, 3, 123, 1, 1, 1, 231, 2, 321, 2, 3, 312]\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_25coding_iterator(PyObject *__pyx_v_self, PyObject *__pyx_v_start) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("coding_iterator (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_24coding_iterator(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_start));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_24coding_iterator(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("coding_iterator", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_start = __pyx_v_start;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_26generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_coding_iterator, __pyx_n_s_MCFAlgorithm_coding_iterator); if (unlikely(!gen)) __PYX_ERR(0, 466, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.coding_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_26generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *__pyx_cur_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  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 *);
  double __pyx_t_6;
  double __pyx_t_7;
  double __pyx_t_8;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_9;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 466, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":488
 * 
 *         # initial values
 *         P.x, P.y, P.z = start             # <<<<<<<<<<<<<<
 *         P.u = random(); P.v = random(); P.w = random();
 * 
 */
  if ((likely(PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_start))) || (PyList_CheckExact(__pyx_cur_scope->__pyx_v_start))) {
    PyObject* sequence = __pyx_cur_scope->__pyx_v_start;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 488, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 488, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 488, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 488, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_start); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 488, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 2; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 3) < 0) __PYX_ERR(0, 488, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_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, 488, __pyx_L1_error)
    __pyx_L5_unpacking_done:;
  }
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_cur_scope->__pyx_v_P.x = __pyx_t_6;
  __pyx_cur_scope->__pyx_v_P.y = __pyx_t_7;
  __pyx_cur_scope->__pyx_v_P.z = __pyx_t_8;

  /* "slabbe/mult_cont_frac.pyx":489
 *         # initial values
 *         P.x, P.y, P.z = start
 *         P.u = random(); P.v = random(); P.w = random();             # <<<<<<<<<<<<<<
 * 
 *         # Normalize (x,y,z)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_cur_scope->__pyx_v_P.u = __pyx_t_8;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_cur_scope->__pyx_v_P.v = __pyx_t_8;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_cur_scope->__pyx_v_P.w = __pyx_t_8;

  /* "slabbe/mult_cont_frac.pyx":492
 * 
 *         # Normalize (x,y,z)
 *         s = P.x + P.y + P.z             # <<<<<<<<<<<<<<
 *         P.x /= s; P.y /= s; P.z /= s
 * 
 */
  __pyx_cur_scope->__pyx_v_s = ((__pyx_cur_scope->__pyx_v_P.x + __pyx_cur_scope->__pyx_v_P.y) + __pyx_cur_scope->__pyx_v_P.z);

  /* "slabbe/mult_cont_frac.pyx":493
 *         # Normalize (x,y,z)
 *         s = P.x + P.y + P.z
 *         P.x /= s; P.y /= s; P.z /= s             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */
  if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 493, __pyx_L1_error)
  }
  __pyx_cur_scope->__pyx_v_P.x = (__pyx_cur_scope->__pyx_v_P.x / __pyx_cur_scope->__pyx_v_s);
  if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 493, __pyx_L1_error)
  }
  __pyx_cur_scope->__pyx_v_P.y = (__pyx_cur_scope->__pyx_v_P.y / __pyx_cur_scope->__pyx_v_s);
  if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 493, __pyx_L1_error)
  }
  __pyx_cur_scope->__pyx_v_P.z = (__pyx_cur_scope->__pyx_v_P.z / __pyx_cur_scope->__pyx_v_s);

  /* "slabbe/mult_cont_frac.pyx":496
 * 
 *         # Loop
 *         while True:             # <<<<<<<<<<<<<<
 *             P = self.call(P)
 *             yield P.branch
 */
  while (1) {

    /* "slabbe/mult_cont_frac.pyx":497
 *         # Loop
 *         while True:
 *             P = self.call(P)             # <<<<<<<<<<<<<<
 *             yield P.branch
 * 
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->call(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 497, __pyx_L1_error)
    __pyx_cur_scope->__pyx_v_P = __pyx_t_9;

    /* "slabbe/mult_cont_frac.pyx":498
 *         while True:
 *             P = self.call(P)
 *             yield P.branch             # <<<<<<<<<<<<<<
 * 
 *             # Normalize (x,y,z)
 */
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_P.branch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L8_resume_from_yield:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 498, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":501
 * 
 *             # Normalize (x,y,z)
 *             s = P.x + P.y + P.z             # <<<<<<<<<<<<<<
 *             P.x /= s; P.y /= s; P.z /= s
 * 
 */
    __pyx_cur_scope->__pyx_v_s = ((__pyx_cur_scope->__pyx_v_P.x + __pyx_cur_scope->__pyx_v_P.y) + __pyx_cur_scope->__pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":502
 *             # Normalize (x,y,z)
 *             s = P.x + P.y + P.z
 *             P.x /= s; P.y /= s; P.z /= s             # <<<<<<<<<<<<<<
 * 
 *     def n_matrix(self, start, n_iterations):
 */
    if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 502, __pyx_L1_error)
    }
    __pyx_cur_scope->__pyx_v_P.x = (__pyx_cur_scope->__pyx_v_P.x / __pyx_cur_scope->__pyx_v_s);
    if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 502, __pyx_L1_error)
    }
    __pyx_cur_scope->__pyx_v_P.y = (__pyx_cur_scope->__pyx_v_P.y / __pyx_cur_scope->__pyx_v_s);
    if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 502, __pyx_L1_error)
    }
    __pyx_cur_scope->__pyx_v_P.z = (__pyx_cur_scope->__pyx_v_P.z / __pyx_cur_scope->__pyx_v_s);
  }

  /* "slabbe/mult_cont_frac.pyx":466
 *         return f()
 * 
 *     def coding_iterator(self, start):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("coding_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":504
 *             P.x /= s; P.y /= s; P.z /= s
 * 
 *     def n_matrix(self, start, n_iterations):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the n-matrix associated to the direction v.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_28n_matrix(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_27n_matrix[] = "\n        Return the n-matrix associated to the direction v.\n\n        INPUT:\n\n        - ``start`` -- iterable of three real numbers\n        - ``n_iterations`` - integer, number of iterations\n\n        OUTPUT:\n\n            matrix\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import ARP\n            sage: ARP().n_matrix((1,e,pi), 10)\n            [ 31  40   7]\n            [ 84 109  19]\n            [ 97 126  22]\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_28n_matrix(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_n_iterations = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("n_matrix (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start,&__pyx_n_s_n_iterations,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("n_matrix", 1, 2, 2, 1); __PYX_ERR(0, 504, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "n_matrix") < 0)) __PYX_ERR(0, 504, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_start = values[0];
    __pyx_v_n_iterations = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("n_matrix", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 504, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.n_matrix", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_27n_matrix(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_start, __pyx_v_n_iterations);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_27n_matrix(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_n_iterations) {
  PyObject *__pyx_v_it = NULL;
  PyObject *__pyx_v_L = NULL;
  PyObject *__pyx_v_cocycle = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = 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;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  __Pyx_RefNannySetupContext("n_matrix", 0);

  /* "slabbe/mult_cont_frac.pyx":525
 *             [ 97 126  22]
 *         """
 *         it = self.coding_iterator(start)             # <<<<<<<<<<<<<<
 *         L = [next(it) for _ in range(n_iterations)]
 *         cocycle = self.matrix_cocycle()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_coding_iterator); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_start); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_start);
    __Pyx_GIVEREF(__pyx_v_start);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_start);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_it = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":526
 *         """
 *         it = self.coding_iterator(start)
 *         L = [next(it) for _ in range(n_iterations)]             # <<<<<<<<<<<<<<
 *         cocycle = self.matrix_cocycle()
 *         return cocycle.word_to_matrix(L)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_n_iterations);
  __Pyx_GIVEREF(__pyx_v_n_iterations);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_n_iterations);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 526, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 526, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 526, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 526, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 526, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 526, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_6(__pyx_t_2);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 526, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyIter_Next(__pyx_v_it); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 526, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 526, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_L = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":527
 *         it = self.coding_iterator(start)
 *         L = [next(it) for _ in range(n_iterations)]
 *         cocycle = self.matrix_cocycle()             # <<<<<<<<<<<<<<
 *         return cocycle.word_to_matrix(L)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_matrix_cocycle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 527, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 527, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_cocycle = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":528
 *         L = [next(it) for _ in range(n_iterations)]
 *         cocycle = self.matrix_cocycle()
 *         return cocycle.word_to_matrix(L)             # <<<<<<<<<<<<<<
 * 
 *     def simplex_orbit_iterator(self, start=None, norm_xyz='sup', norm_uvw='1'):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_cocycle, __pyx_n_s_word_to_matrix); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_L); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_L);
    __Pyx_GIVEREF(__pyx_v_L);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_L);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":504
 *             P.x /= s; P.y /= s; P.z /= s
 * 
 *     def n_matrix(self, start, n_iterations):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the n-matrix associated to the direction v.
 */

  /* 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("slabbe.mult_cont_frac.MCFAlgorithm.n_matrix", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_it);
  __Pyx_XDECREF(__pyx_v_L);
  __Pyx_XDECREF(__pyx_v_cocycle);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_31generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "slabbe/mult_cont_frac.pyx":530
 *         return cocycle.word_to_matrix(L)
 * 
 *     def simplex_orbit_iterator(self, start=None, norm_xyz='sup', norm_uvw='1'):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_30simplex_orbit_iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_29simplex_orbit_iterator[] = "\n        INPUT:\n\n        - ``start`` - initial vector (default: ``None``), if None, then\n          initial point is random\n        - ``norm_xyz`` -- string (default: ``'sup'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit of points `(x,y,z)` of the algo\n        - ``norm_uvw`` -- string (default: ``'sup'``), either ``'sup'`` or\n          ``'1'`` or ``'hypersurfac'``, the norm used for the orbit of dual\n          coordinates `(u,v,w)`.\n\n        NOTE:\n\n            This iterator is 10x slower because of the yield statement. So\n            avoid using this when writing fast code. Just copy paste the\n            loop or use simplex_orbit_list or simplex_orbit_filtered_list method.\n\n        OUTPUT:\n\n            iterator\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: it = Brun().simplex_orbit_iterator((.414578,.571324,.65513))\n            sage: for _ in range(4): next(it)\n            ((0.7256442929056017, 1.0, 0.14668734378391243), \n             (0.25, 0.5, 0.25), \n             123)\n            ((1.0, 0.37808566783572695, 0.20214772612150184),\n             (0.5, 0.3333333333333333, 0.16666666666666666),\n             312)\n            ((1.0, 0.6079385025908344, 0.32504111204194974),\n             (0.3333333333333333, 0.5555555555555555, 0.1111111111111111),\n             321)\n            ((0.6449032192209051, 1.0, 0.534661171576946),\n             (0.25, 0.6666666666666666, 0.08333333333333333),\n             321)\n\n        ::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: it = Brun().simplex_orbit_iterator((.414578,.571324,.65513), norm_xyz='1')\n            sage: for _ in range(4): next(it)\n            ((0.3875618393056797, 0.5340934161472103, 0.07834474454711005),\n             (0.25, 0.5, 0.25),\n             123)\n             ((0.6328179140018012, 0.23925938363378257, 0.12792270236441622),\n             (0.5, 0.3333333333333333, 0.16""666666666666666),\n             312)\n            ((0.5173360300491189, 0.3145084914443481, 0.16815547850653312),\n             (0.3333333333333333, 0.5555555555555555, 0.1111111111111111),\n             321)\n            ((0.2958862889959549, 0.45880727553726447, 0.24530643546678058),\n             (0.25, 0.6666666666666666, 0.08333333333333333),\n             321)\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_30simplex_orbit_iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_norm_xyz = 0;
  PyObject *__pyx_v_norm_uvw = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("simplex_orbit_iterator (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start,&__pyx_n_s_norm_xyz,&__pyx_n_s_norm_uvw,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)__pyx_n_s_sup);
    values[2] = ((PyObject *)__pyx_kp_s_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_xyz);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_uvw);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "simplex_orbit_iterator") < 0)) __PYX_ERR(0, 530, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_start = values[0];
    __pyx_v_norm_xyz = values[1];
    __pyx_v_norm_uvw = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("simplex_orbit_iterator", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 530, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.simplex_orbit_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_29simplex_orbit_iterator(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_start, __pyx_v_norm_xyz, __pyx_v_norm_uvw);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_29simplex_orbit_iterator(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("simplex_orbit_iterator", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_start = __pyx_v_start;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start);
  __pyx_cur_scope->__pyx_v_norm_xyz = __pyx_v_norm_xyz;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_norm_xyz);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_norm_xyz);
  __pyx_cur_scope->__pyx_v_norm_uvw = __pyx_v_norm_uvw;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_norm_uvw);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_norm_uvw);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_31generator1, (PyObject *) __pyx_cur_scope, __pyx_n_s_simplex_orbit_iterator, __pyx_n_s_MCFAlgorithm_simplex_orbit_itera); if (unlikely(!gen)) __PYX_ERR(0, 530, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.simplex_orbit_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_31generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *__pyx_cur_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_7;
  double __pyx_t_8;
  double __pyx_t_9;
  double __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L9_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 530, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":591
 *         cdef double s           # temporary variables
 *         cdef PairPoint3d P
 *         if start is None:             # <<<<<<<<<<<<<<
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_start == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":592
 *         cdef PairPoint3d P
 *         if start is None:
 *             P.x = random(); P.y = random(); P.z = random()             # <<<<<<<<<<<<<<
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 592, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 592, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.x = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 592, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 592, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.y = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 592, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 592, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.z = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":591
 *         cdef double s           # temporary variables
 *         cdef PairPoint3d P
 *         if start is None:             # <<<<<<<<<<<<<<
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 */
    goto __pyx_L4;
  }

  /* "slabbe/mult_cont_frac.pyx":594
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]             # <<<<<<<<<<<<<<
 *         P.u = 1./3
 *         P.v = 1./3
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_start, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 594, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.x = __pyx_t_6;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_start, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 594, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.y = __pyx_t_6;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_start, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 594, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.z = __pyx_t_6;
  }
  __pyx_L4:;

  /* "slabbe/mult_cont_frac.pyx":595
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1./3             # <<<<<<<<<<<<<<
 *         P.v = 1./3
 *         P.w = 1./3
 */
  __pyx_cur_scope->__pyx_v_P.u = (1. / 3.0);

  /* "slabbe/mult_cont_frac.pyx":596
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1./3
 *         P.v = 1./3             # <<<<<<<<<<<<<<
 *         P.w = 1./3
 * 
 */
  __pyx_cur_scope->__pyx_v_P.v = (1. / 3.0);

  /* "slabbe/mult_cont_frac.pyx":597
 *         P.u = 1./3
 *         P.v = 1./3
 *         P.w = 1./3             # <<<<<<<<<<<<<<
 * 
 *         # Normalize (x,y,z)
 */
  __pyx_cur_scope->__pyx_v_P.w = (1. / 3.0);

  /* "slabbe/mult_cont_frac.pyx":600
 * 
 *         # Normalize (x,y,z)
 *         s = P.x + P.y + P.z             # <<<<<<<<<<<<<<
 *         P.x /= s; P.y /= s; P.z /= s
 * 
 */
  __pyx_cur_scope->__pyx_v_s = ((__pyx_cur_scope->__pyx_v_P.x + __pyx_cur_scope->__pyx_v_P.y) + __pyx_cur_scope->__pyx_v_P.z);

  /* "slabbe/mult_cont_frac.pyx":601
 *         # Normalize (x,y,z)
 *         s = P.x + P.y + P.z
 *         P.x /= s; P.y /= s; P.z /= s             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */
  if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 601, __pyx_L1_error)
  }
  __pyx_cur_scope->__pyx_v_P.x = (__pyx_cur_scope->__pyx_v_P.x / __pyx_cur_scope->__pyx_v_s);
  if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 601, __pyx_L1_error)
  }
  __pyx_cur_scope->__pyx_v_P.y = (__pyx_cur_scope->__pyx_v_P.y / __pyx_cur_scope->__pyx_v_s);
  if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 601, __pyx_L1_error)
  }
  __pyx_cur_scope->__pyx_v_P.z = (__pyx_cur_scope->__pyx_v_P.z / __pyx_cur_scope->__pyx_v_s);

  /* "slabbe/mult_cont_frac.pyx":604
 * 
 *         # Loop
 *         while True:             # <<<<<<<<<<<<<<
 * 
 *             # Apply Algo
 */
  while (1) {

    /* "slabbe/mult_cont_frac.pyx":607
 * 
 *             # Apply Algo
 *             P = self.call(P)             # <<<<<<<<<<<<<<
 * 
 *             # Normalize (xnew,ynew,znew)
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->call(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 607, __pyx_L1_error)
    __pyx_cur_scope->__pyx_v_P = __pyx_t_7;

    /* "slabbe/mult_cont_frac.pyx":610
 * 
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_cur_scope->__pyx_v_norm_xyz, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 610, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":611
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':
 *                 s = P.x + P.y + P.z # norm 1             # <<<<<<<<<<<<<<
 *             elif norm_xyz == 'sup':
 *                 s = max(P.x, P.y, P.z) # norm sup
 */
      __pyx_cur_scope->__pyx_v_s = ((__pyx_cur_scope->__pyx_v_P.x + __pyx_cur_scope->__pyx_v_P.y) + __pyx_cur_scope->__pyx_v_P.z);

      /* "slabbe/mult_cont_frac.pyx":610
 * 
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':
 */
      goto __pyx_L7;
    }

    /* "slabbe/mult_cont_frac.pyx":612
 *             if norm_xyz == '1':
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_cur_scope->__pyx_v_norm_xyz, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 612, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":613
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':
 *                 s = max(P.x, P.y, P.z) # norm sup             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)
 */
      __pyx_t_6 = __pyx_cur_scope->__pyx_v_P.y;
      __pyx_t_8 = __pyx_cur_scope->__pyx_v_P.z;
      __pyx_t_9 = __pyx_cur_scope->__pyx_v_P.x;
      if (((__pyx_t_6 > __pyx_t_9) != 0)) {
        __pyx_t_10 = __pyx_t_6;
      } else {
        __pyx_t_10 = __pyx_t_9;
      }
      __pyx_t_9 = __pyx_t_10;
      if (((__pyx_t_8 > __pyx_t_9) != 0)) {
        __pyx_t_10 = __pyx_t_8;
      } else {
        __pyx_t_10 = __pyx_t_9;
      }
      __pyx_cur_scope->__pyx_v_s = __pyx_t_10;

      /* "slabbe/mult_cont_frac.pyx":612
 *             if norm_xyz == '1':
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 */
      goto __pyx_L7;
    }

    /* "slabbe/mult_cont_frac.pyx":615
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)             # <<<<<<<<<<<<<<
 *             P.x /= s; P.y /= s; P.z /= s
 * 
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_value_for_norm_xyz_s, __pyx_cur_scope->__pyx_v_norm_xyz); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 615, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 615, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 615, __pyx_L1_error)
    }
    __pyx_L7:;

    /* "slabbe/mult_cont_frac.pyx":616
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)
 *             P.x /= s; P.y /= s; P.z /= s             # <<<<<<<<<<<<<<
 * 
 *             # Normalize (unew,vnew,wnew)
 */
    if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 616, __pyx_L1_error)
    }
    __pyx_cur_scope->__pyx_v_P.x = (__pyx_cur_scope->__pyx_v_P.x / __pyx_cur_scope->__pyx_v_s);
    if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 616, __pyx_L1_error)
    }
    __pyx_cur_scope->__pyx_v_P.y = (__pyx_cur_scope->__pyx_v_P.y / __pyx_cur_scope->__pyx_v_s);
    if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 616, __pyx_L1_error)
    }
    __pyx_cur_scope->__pyx_v_P.z = (__pyx_cur_scope->__pyx_v_P.z / __pyx_cur_scope->__pyx_v_s);

    /* "slabbe/mult_cont_frac.pyx":619
 * 
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_cur_scope->__pyx_v_norm_uvw, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 619, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":620
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':
 *                 s = P.u + P.v + P.w    # norm 1             # <<<<<<<<<<<<<<
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup
 */
      __pyx_cur_scope->__pyx_v_s = ((__pyx_cur_scope->__pyx_v_P.u + __pyx_cur_scope->__pyx_v_P.v) + __pyx_cur_scope->__pyx_v_P.w);

      /* "slabbe/mult_cont_frac.pyx":619
 * 
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':
 */
      goto __pyx_L8;
    }

    /* "slabbe/mult_cont_frac.pyx":621
 *             if norm_uvw == '1':
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_cur_scope->__pyx_v_norm_uvw, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 621, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":622
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup             # <<<<<<<<<<<<<<
 *             elif norm_uvw == 'hypersurface':
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 */
      __pyx_t_10 = __pyx_cur_scope->__pyx_v_P.v;
      __pyx_t_6 = __pyx_cur_scope->__pyx_v_P.w;
      __pyx_t_8 = __pyx_cur_scope->__pyx_v_P.u;
      if (((__pyx_t_10 > __pyx_t_8) != 0)) {
        __pyx_t_9 = __pyx_t_10;
      } else {
        __pyx_t_9 = __pyx_t_8;
      }
      __pyx_t_8 = __pyx_t_9;
      if (((__pyx_t_6 > __pyx_t_8) != 0)) {
        __pyx_t_9 = __pyx_t_6;
      } else {
        __pyx_t_9 = __pyx_t_8;
      }
      __pyx_cur_scope->__pyx_v_s = __pyx_t_9;

      /* "slabbe/mult_cont_frac.pyx":621
 *             if norm_uvw == '1':
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 */
      goto __pyx_L8;
    }

    /* "slabbe/mult_cont_frac.pyx":623
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':             # <<<<<<<<<<<<<<
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 *             else:
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_cur_scope->__pyx_v_norm_uvw, __pyx_n_s_hypersurface, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 623, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":624
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)
 */
      __pyx_cur_scope->__pyx_v_s = (((__pyx_cur_scope->__pyx_v_P.x * __pyx_cur_scope->__pyx_v_P.u) + (__pyx_cur_scope->__pyx_v_P.y * __pyx_cur_scope->__pyx_v_P.v)) + (__pyx_cur_scope->__pyx_v_P.z * __pyx_cur_scope->__pyx_v_P.w));

      /* "slabbe/mult_cont_frac.pyx":623
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':             # <<<<<<<<<<<<<<
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 *             else:
 */
      goto __pyx_L8;
    }

    /* "slabbe/mult_cont_frac.pyx":626
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)             # <<<<<<<<<<<<<<
 *             P.u /= s; P.v /= s; P.w /= s
 * 
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_value_for_norm_uvw_s, __pyx_cur_scope->__pyx_v_norm_uvw); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 626, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 626, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 626, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 626, __pyx_L1_error)
    }
    __pyx_L8:;

    /* "slabbe/mult_cont_frac.pyx":627
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)
 *             P.u /= s; P.v /= s; P.w /= s             # <<<<<<<<<<<<<<
 * 
 *             yield (P.x, P.y, P.z), (P.u, P.v, P.w), P.branch
 */
    if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 627, __pyx_L1_error)
    }
    __pyx_cur_scope->__pyx_v_P.u = (__pyx_cur_scope->__pyx_v_P.u / __pyx_cur_scope->__pyx_v_s);
    if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 627, __pyx_L1_error)
    }
    __pyx_cur_scope->__pyx_v_P.v = (__pyx_cur_scope->__pyx_v_P.v / __pyx_cur_scope->__pyx_v_s);
    if (unlikely(__pyx_cur_scope->__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 627, __pyx_L1_error)
    }
    __pyx_cur_scope->__pyx_v_P.w = (__pyx_cur_scope->__pyx_v_P.w / __pyx_cur_scope->__pyx_v_s);

    /* "slabbe/mult_cont_frac.pyx":629
 *             P.u /= s; P.v /= s; P.w /= s
 * 
 *             yield (P.x, P.y, P.z), (P.u, P.v, P.w), P.branch             # <<<<<<<<<<<<<<
 * 
 *     def simplex_orbit_list(self, start=None, int n_iterations=100,
 */
    __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.y); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.z); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.u); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.v); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.w); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_3);
    __pyx_t_5 = 0;
    __pyx_t_4 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_P.branch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L9_resume_from_yield:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 629, __pyx_L1_error)
  }

  /* "slabbe/mult_cont_frac.pyx":530
 *         return cocycle.word_to_matrix(L)
 * 
 *     def simplex_orbit_iterator(self, start=None, norm_xyz='sup', norm_uvw='1'):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("simplex_orbit_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":631
 *             yield (P.x, P.y, P.z), (P.u, P.v, P.w), P.branch
 * 
 *     def simplex_orbit_list(self, start=None, int n_iterations=100,             # <<<<<<<<<<<<<<
 *                                  norm_xyz='1', norm_uvw='1'):
 *         r"""
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_33simplex_orbit_list(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_32simplex_orbit_list[] = "\n        INPUT:\n\n        - ``start`` - initial vector (default: ``None``), if None, then\n          initial point is random\n        - ``n_iterations`` - integer, number of iterations\n        - ``norm_xyz`` -- string (default: ``'sup'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit of points `(x,y,z)` of the algo\n        - ``norm_uvw`` -- string (default: ``'sup'``), either ``'sup'`` or\n          ``'1'`` or ``'hypersurfac'``, the norm used for the orbit of dual\n          coordinates `(u,v,w)`.\n\n        OUTPUT:\n\n            list\n\n        BENCHMARK:\n\n        It could be 10 times faster because 10^6 iterations can be done in\n        about 60ms on this machine. But for drawing images, it does not\n        matter to be 10 times slower::\n\n            sage: %time L = Brun().simplex_orbit_list(10^6)   # not tested\n            CPU times: user 376 ms, sys: 267 ms, total: 643 ms\n            Wall time: 660 ms\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: L = Brun().simplex_orbit_list(n_iterations=10^5)\n            sage: L[-1]    # random\n            (0.7307002153148079,\n             1.0,\n             0.31588474491578816,\n             0.29055326655584235,\n             0.4690741038784866,\n             0.24037262956567113,\n             321)\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_33simplex_orbit_list(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_start = 0;
  int __pyx_v_n_iterations;
  PyObject *__pyx_v_norm_xyz = 0;
  PyObject *__pyx_v_norm_uvw = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("simplex_orbit_list (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start,&__pyx_n_s_n_iterations,&__pyx_n_s_norm_xyz,&__pyx_n_s_norm_uvw,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_kp_s_1);
    values[3] = ((PyObject *)__pyx_kp_s_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_xyz);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_uvw);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "simplex_orbit_list") < 0)) __PYX_ERR(0, 631, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_start = values[0];
    if (values[1]) {
      __pyx_v_n_iterations = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_n_iterations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 631, __pyx_L3_error)
    } else {
      __pyx_v_n_iterations = ((int)0x64);
    }
    __pyx_v_norm_xyz = values[2];
    __pyx_v_norm_uvw = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("simplex_orbit_list", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 631, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.simplex_orbit_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_32simplex_orbit_list(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_start, __pyx_v_n_iterations, __pyx_v_norm_xyz, __pyx_v_norm_uvw);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_32simplex_orbit_list(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, int __pyx_v_n_iterations, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw) {
  double __pyx_v_s;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  CYTHON_UNUSED int __pyx_v_i;
  PyObject *__pyx_v_L = 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;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_9;
  double __pyx_t_10;
  double __pyx_t_11;
  double __pyx_t_12;
  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_t_18;
  __Pyx_RefNannySetupContext("simplex_orbit_list", 0);

  /* "slabbe/mult_cont_frac.pyx":676
 *         cdef PairPoint3d P
 *         cdef int i
 *         if start is None:             # <<<<<<<<<<<<<<
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 */
  __pyx_t_1 = (__pyx_v_start == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":677
 *         cdef int i
 *         if start is None:
 *             P.x = random(); P.y = random(); P.z = random()             # <<<<<<<<<<<<<<
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 677, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 677, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.x = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 677, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 677, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.y = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 677, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 677, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.z = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":676
 *         cdef PairPoint3d P
 *         cdef int i
 *         if start is None:             # <<<<<<<<<<<<<<
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":679
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]             # <<<<<<<<<<<<<<
 *         P.u = 1./3
 *         P.v = 1./3
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_start, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 679, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 679, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.x = __pyx_t_6;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_start, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 679, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 679, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.y = __pyx_t_6;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_start, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 679, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 679, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.z = __pyx_t_6;
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":680
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1./3             # <<<<<<<<<<<<<<
 *         P.v = 1./3
 *         P.w = 1./3
 */
  __pyx_v_P.u = (1. / 3.0);

  /* "slabbe/mult_cont_frac.pyx":681
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1./3
 *         P.v = 1./3             # <<<<<<<<<<<<<<
 *         P.w = 1./3
 * 
 */
  __pyx_v_P.v = (1. / 3.0);

  /* "slabbe/mult_cont_frac.pyx":682
 *         P.u = 1./3
 *         P.v = 1./3
 *         P.w = 1./3             # <<<<<<<<<<<<<<
 * 
 *         # Normalize (x,y,z)
 */
  __pyx_v_P.w = (1. / 3.0);

  /* "slabbe/mult_cont_frac.pyx":685
 * 
 *         # Normalize (x,y,z)
 *         s = P.x + P.y + P.z             # <<<<<<<<<<<<<<
 *         P.x /= s; P.y /= s; P.z /= s
 * 
 */
  __pyx_v_s = ((__pyx_v_P.x + __pyx_v_P.y) + __pyx_v_P.z);

  /* "slabbe/mult_cont_frac.pyx":686
 *         # Normalize (x,y,z)
 *         s = P.x + P.y + P.z
 *         P.x /= s; P.y /= s; P.z /= s             # <<<<<<<<<<<<<<
 * 
 *         L = []
 */
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 686, __pyx_L1_error)
  }
  __pyx_v_P.x = (__pyx_v_P.x / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 686, __pyx_L1_error)
  }
  __pyx_v_P.y = (__pyx_v_P.y / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 686, __pyx_L1_error)
  }
  __pyx_v_P.z = (__pyx_v_P.z / __pyx_v_s);

  /* "slabbe/mult_cont_frac.pyx":688
 *         P.x /= s; P.y /= s; P.z /= s
 * 
 *         L = []             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_L = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":691
 * 
 *         # Loop
 *         for i from 0 <= i < n_iterations:             # <<<<<<<<<<<<<<
 * 
 *             # Check for Keyboard interupt
 */
  __pyx_t_7 = __pyx_v_n_iterations;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "slabbe/mult_cont_frac.pyx":694
 * 
 *             # Check for Keyboard interupt
 *             sig_check()             # <<<<<<<<<<<<<<
 * 
 *             # Apply Algo
 */
    __pyx_t_8 = sig_check(); if (unlikely(__pyx_t_8 == 0)) __PYX_ERR(0, 694, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":697
 * 
 *             # Apply Algo
 *             P = self.call(P)             # <<<<<<<<<<<<<<
 * 
 *             # Normalize (xnew,ynew,znew)
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self->__pyx_vtab)->call(__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 697, __pyx_L1_error)
    __pyx_v_P = __pyx_t_9;

    /* "slabbe/mult_cont_frac.pyx":700
 * 
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_xyz, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 700, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":701
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':
 *                 s = P.x + P.y + P.z # norm 1             # <<<<<<<<<<<<<<
 *             elif norm_xyz == 'sup':
 *                 s = max(P.x, P.y, P.z) # norm sup
 */
      __pyx_v_s = ((__pyx_v_P.x + __pyx_v_P.y) + __pyx_v_P.z);

      /* "slabbe/mult_cont_frac.pyx":700
 * 
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':
 */
      goto __pyx_L6;
    }

    /* "slabbe/mult_cont_frac.pyx":702
 *             if norm_xyz == '1':
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_xyz, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 702, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":703
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':
 *                 s = max(P.x, P.y, P.z) # norm sup             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)
 */
      __pyx_t_6 = __pyx_v_P.y;
      __pyx_t_10 = __pyx_v_P.z;
      __pyx_t_11 = __pyx_v_P.x;
      if (((__pyx_t_6 > __pyx_t_11) != 0)) {
        __pyx_t_12 = __pyx_t_6;
      } else {
        __pyx_t_12 = __pyx_t_11;
      }
      __pyx_t_11 = __pyx_t_12;
      if (((__pyx_t_10 > __pyx_t_11) != 0)) {
        __pyx_t_12 = __pyx_t_10;
      } else {
        __pyx_t_12 = __pyx_t_11;
      }
      __pyx_v_s = __pyx_t_12;

      /* "slabbe/mult_cont_frac.pyx":702
 *             if norm_xyz == '1':
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 */
      goto __pyx_L6;
    }

    /* "slabbe/mult_cont_frac.pyx":705
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)             # <<<<<<<<<<<<<<
 *             P.x /= s; P.y /= s; P.z /= s
 * 
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_value_for_norm_xyz_s, __pyx_v_norm_xyz); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 705, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 705, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 705, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 705, __pyx_L1_error)
    }
    __pyx_L6:;

    /* "slabbe/mult_cont_frac.pyx":706
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)
 *             P.x /= s; P.y /= s; P.z /= s             # <<<<<<<<<<<<<<
 * 
 *             # Normalize (unew,vnew,wnew)
 */
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 706, __pyx_L1_error)
    }
    __pyx_v_P.x = (__pyx_v_P.x / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 706, __pyx_L1_error)
    }
    __pyx_v_P.y = (__pyx_v_P.y / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 706, __pyx_L1_error)
    }
    __pyx_v_P.z = (__pyx_v_P.z / __pyx_v_s);

    /* "slabbe/mult_cont_frac.pyx":709
 * 
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 709, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":710
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':
 *                 s = P.u + P.v + P.w    # norm 1             # <<<<<<<<<<<<<<
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup
 */
      __pyx_v_s = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

      /* "slabbe/mult_cont_frac.pyx":709
 * 
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':
 */
      goto __pyx_L7;
    }

    /* "slabbe/mult_cont_frac.pyx":711
 *             if norm_uvw == '1':
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 711, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":712
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup             # <<<<<<<<<<<<<<
 *             elif norm_uvw == 'hypersurface':
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 */
      __pyx_t_12 = __pyx_v_P.v;
      __pyx_t_6 = __pyx_v_P.w;
      __pyx_t_10 = __pyx_v_P.u;
      if (((__pyx_t_12 > __pyx_t_10) != 0)) {
        __pyx_t_11 = __pyx_t_12;
      } else {
        __pyx_t_11 = __pyx_t_10;
      }
      __pyx_t_10 = __pyx_t_11;
      if (((__pyx_t_6 > __pyx_t_10) != 0)) {
        __pyx_t_11 = __pyx_t_6;
      } else {
        __pyx_t_11 = __pyx_t_10;
      }
      __pyx_v_s = __pyx_t_11;

      /* "slabbe/mult_cont_frac.pyx":711
 *             if norm_uvw == '1':
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 */
      goto __pyx_L7;
    }

    /* "slabbe/mult_cont_frac.pyx":713
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':             # <<<<<<<<<<<<<<
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 *             else:
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_n_s_hypersurface, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 713, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":714
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)
 */
      __pyx_v_s = (((__pyx_v_P.x * __pyx_v_P.u) + (__pyx_v_P.y * __pyx_v_P.v)) + (__pyx_v_P.z * __pyx_v_P.w));

      /* "slabbe/mult_cont_frac.pyx":713
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':             # <<<<<<<<<<<<<<
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 *             else:
 */
      goto __pyx_L7;
    }

    /* "slabbe/mult_cont_frac.pyx":716
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)             # <<<<<<<<<<<<<<
 *             P.u /= s; P.v /= s; P.w /= s
 * 
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_value_for_norm_uvw_s, __pyx_v_norm_uvw); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 716, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 716, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 716, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 716, __pyx_L1_error)
    }
    __pyx_L7:;

    /* "slabbe/mult_cont_frac.pyx":717
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)
 *             P.u /= s; P.v /= s; P.w /= s             # <<<<<<<<<<<<<<
 * 
 *             L.append( (P.x, P.y, P.z, P.u, P.v, P.w, P.branch))
 */
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 717, __pyx_L1_error)
    }
    __pyx_v_P.u = (__pyx_v_P.u / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 717, __pyx_L1_error)
    }
    __pyx_v_P.v = (__pyx_v_P.v / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 717, __pyx_L1_error)
    }
    __pyx_v_P.w = (__pyx_v_P.w / __pyx_v_s);

    /* "slabbe/mult_cont_frac.pyx":719
 *             P.u /= s; P.v /= s; P.w /= s
 * 
 *             L.append( (P.x, P.y, P.z, P.u, P.v, P.w, P.branch))             # <<<<<<<<<<<<<<
 * 
 *         return L
 */
    __pyx_t_3 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_P.z); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_13 = PyFloat_FromDouble(__pyx_v_P.u); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_14 = PyFloat_FromDouble(__pyx_v_P.v); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_15 = PyFloat_FromDouble(__pyx_v_P.w); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_P.branch); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_17 = PyTuple_New(7); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_17, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_17, 3, __pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_14);
    PyTuple_SET_ITEM(__pyx_t_17, 4, __pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_17, 5, __pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_16);
    PyTuple_SET_ITEM(__pyx_t_17, 6, __pyx_t_16);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_13 = 0;
    __pyx_t_14 = 0;
    __pyx_t_15 = 0;
    __pyx_t_16 = 0;
    __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_L, __pyx_t_17); if (unlikely(__pyx_t_18 == -1)) __PYX_ERR(0, 719, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  }

  /* "slabbe/mult_cont_frac.pyx":721
 *             L.append( (P.x, P.y, P.z, P.u, P.v, P.w, P.branch))
 * 
 *         return L             # <<<<<<<<<<<<<<
 * 
 *     def simplex_orbit_filtered_list(self, start=None, int n_iterations=100,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_L);
  __pyx_r = __pyx_v_L;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":631
 *             yield (P.x, P.y, P.z), (P.u, P.v, P.w), P.branch
 * 
 *     def simplex_orbit_list(self, start=None, int n_iterations=100,             # <<<<<<<<<<<<<<
 *                                  norm_xyz='1', norm_uvw='1'):
 *         r"""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.simplex_orbit_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_L);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":723
 *         return L
 * 
 *     def simplex_orbit_filtered_list(self, start=None, int n_iterations=100,             # <<<<<<<<<<<<<<
 *             norm_xyz='1', norm_uvw='1',
 *             double xmin=-float('inf'), double xmax=float('inf'),
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_35simplex_orbit_filtered_list(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_34simplex_orbit_filtered_list[] = "\n        Return a list of the orbit filtered to fit into a rectangle.\n\n        INPUT:\n\n        - ``start`` - initial vector (default: ``None``), if None, then\n          initial point is random\n        - ``n_iterations`` - integer, number of iterations\n        - ``norm_xyz`` -- string (default: ``'sup'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit of points `(x,y,z)` of the algo\n        - ``norm_uvw`` -- string (default: ``'sup'``), either ``'sup'`` or\n          ``'1'`` or ``'hypersurfac'``, the norm used for the orbit of dual\n          coordinates `(u,v,w)`.\n        - ``xmin`` - double\n        - ``ymin`` - double\n        - ``umin`` - double\n        - ``vmin`` - double\n        - ``xmax`` - double\n        - ``ymax`` - double\n        - ``umax`` - double\n        - ``vmax`` - double\n        - ``ndvis`` - integer, number of divisions\n\n        OUTPUT:\n\n            list\n\n        BENCHMARK::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: %time D = Brun().simplex_orbit_filtered_list(10^6) # not tested\n            CPU times: user 366 ms, sys: 203 ms, total: 568 ms\n            Wall time: 570 ms\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: start=(.414578,.571324,.65513)\n            sage: D = Brun().simplex_orbit_filtered_list(start, 3)\n            sage: D      # random\n            [(0.3049590483124023,\n              -0.36889249928767137,\n              -0.21650635094610976,\n              -0.125,\n              312,\n              312),\n             (0.08651831333735083,\n              -0.31784823591841554,\n              -0.34641016151377557,\n              -0.2,\n              312,\n              312),\n             (-0.41045591033143647,\n              -0.20171750067080554,\n              -0.4330127018922195,\n              -0.25000000000000006,\n              312,\n              231)]\n\n        ::\n\n            sage: Brun().simp""lex_orbit_filtered_list(n_iterations=3, norm_xyz='1',ndivs=1000)\n            Traceback (most recent call last):\n            ...\n            ValueError: when ndivs is specified, you must provide a value\n            for xmin, xmax, ymin, ymax, umin, umax, vmin and vmax\n\n        ::\n\n            sage: Brun().simplex_orbit_filtered_list(n_iterations=7,  # random\n            ....:       norm_xyz='1', ndivs=100,\n            ....:       xmin=-.866, xmax=.866, ymin=-.5, ymax=1.,\n            ....:       umin=-.866, umax=.866, vmin=-.5, vmax=1.)\n            [(30, 47, 50, 50, 132, 213),\n             (15, 83, 33, 66, 213, 231),\n             (18, 80, 38, 44, 231, 231),\n             (22, 75, 41, 33, 231, 231),\n             (30, 68, 43, 26, 231, 231),\n             (44, 53, 44, 22, 231, 213),\n             (41, 78, 24, 56, 213, 321)]\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_35simplex_orbit_filtered_list(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_start = 0;
  int __pyx_v_n_iterations;
  PyObject *__pyx_v_norm_xyz = 0;
  PyObject *__pyx_v_norm_uvw = 0;
  double __pyx_v_xmin;
  double __pyx_v_xmax;
  double __pyx_v_ymin;
  double __pyx_v_ymax;
  double __pyx_v_umin;
  double __pyx_v_umax;
  double __pyx_v_vmin;
  double __pyx_v_vmax;
  int __pyx_v_ndivs;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("simplex_orbit_filtered_list (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start,&__pyx_n_s_n_iterations,&__pyx_n_s_norm_xyz,&__pyx_n_s_norm_uvw,&__pyx_n_s_xmin,&__pyx_n_s_xmax,&__pyx_n_s_ymin,&__pyx_n_s_ymax,&__pyx_n_s_umin,&__pyx_n_s_umax,&__pyx_n_s_vmin,&__pyx_n_s_vmax,&__pyx_n_s_ndivs,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_kp_s_1);
    values[3] = ((PyObject *)__pyx_kp_s_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_xyz);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_uvw);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xmin);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xmax);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ymin);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ymax);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_umin);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_umax);
          if (value) { values[9] = value; kw_args--; }
        }
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vmin);
          if (value) { values[10] = value; kw_args--; }
        }
        case 11:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vmax);
          if (value) { values[11] = value; kw_args--; }
        }
        case 12:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndivs);
          if (value) { values[12] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "simplex_orbit_filtered_list") < 0)) __PYX_ERR(0, 723, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_start = values[0];
    if (values[1]) {
      __pyx_v_n_iterations = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_n_iterations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 723, __pyx_L3_error)
    } else {
      __pyx_v_n_iterations = ((int)0x64);
    }
    __pyx_v_norm_xyz = values[2];
    __pyx_v_norm_uvw = values[3];
    if (values[4]) {
      __pyx_v_xmin = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_xmin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 725, __pyx_L3_error)
    } else {
      __pyx_v_xmin = __pyx_k__2;
    }
    if (values[5]) {
      __pyx_v_xmax = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_xmax == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 725, __pyx_L3_error)
    } else {
      __pyx_v_xmax = __pyx_k__3;
    }
    if (values[6]) {
      __pyx_v_ymin = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_ymin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 726, __pyx_L3_error)
    } else {
      __pyx_v_ymin = __pyx_k__4;
    }
    if (values[7]) {
      __pyx_v_ymax = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_ymax == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 726, __pyx_L3_error)
    } else {
      __pyx_v_ymax = __pyx_k__5;
    }
    if (values[8]) {
      __pyx_v_umin = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_umin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 727, __pyx_L3_error)
    } else {
      __pyx_v_umin = __pyx_k__6;
    }
    if (values[9]) {
      __pyx_v_umax = __pyx_PyFloat_AsDouble(values[9]); if (unlikely((__pyx_v_umax == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 727, __pyx_L3_error)
    } else {
      __pyx_v_umax = __pyx_k__7;
    }
    if (values[10]) {
      __pyx_v_vmin = __pyx_PyFloat_AsDouble(values[10]); if (unlikely((__pyx_v_vmin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 728, __pyx_L3_error)
    } else {
      __pyx_v_vmin = __pyx_k__8;
    }
    if (values[11]) {
      __pyx_v_vmax = __pyx_PyFloat_AsDouble(values[11]); if (unlikely((__pyx_v_vmax == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 728, __pyx_L3_error)
    } else {
      __pyx_v_vmax = __pyx_k__9;
    }
    if (values[12]) {
      __pyx_v_ndivs = __Pyx_PyInt_As_int(values[12]); if (unlikely((__pyx_v_ndivs == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 729, __pyx_L3_error)
    } else {
      __pyx_v_ndivs = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("simplex_orbit_filtered_list", 0, 0, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 723, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.simplex_orbit_filtered_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_34simplex_orbit_filtered_list(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_start, __pyx_v_n_iterations, __pyx_v_norm_xyz, __pyx_v_norm_uvw, __pyx_v_xmin, __pyx_v_xmax, __pyx_v_ymin, __pyx_v_ymax, __pyx_v_umin, __pyx_v_umax, __pyx_v_vmin, __pyx_v_vmax, __pyx_v_ndivs);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_34simplex_orbit_filtered_list(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, int __pyx_v_n_iterations, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, double __pyx_v_xmin, double __pyx_v_xmax, double __pyx_v_ymin, double __pyx_v_ymax, double __pyx_v_umin, double __pyx_v_umax, double __pyx_v_vmin, double __pyx_v_vmax, int __pyx_v_ndivs) {
  double __pyx_v_s;
  double __pyx_v_x;
  double __pyx_v_y;
  double __pyx_v_u;
  double __pyx_v_v;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  int __pyx_v_previous_branch;
  int __pyx_v_xa;
  int __pyx_v_ya;
  int __pyx_v_ua;
  int __pyx_v_va;
  CYTHON_UNUSED int __pyx_v_i;
  double __pyx_v_xlen;
  double __pyx_v_ylen;
  double __pyx_v_ulen;
  double __pyx_v_vlen;
  PyObject *__pyx_v_L = 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;
  double __pyx_t_6;
  double __pyx_t_7;
  double __pyx_t_8;
  double __pyx_t_9;
  double __pyx_t_10;
  int __pyx_t_11;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  int __pyx_t_19;
  __Pyx_RefNannySetupContext("simplex_orbit_filtered_list", 0);

  /* "slabbe/mult_cont_frac.pyx":813
 *         """
 *         cdef double s,x,y,u,v           # temporary variables
 *         s = x = y = u = v = 0           # initialize to avoid a warning             # <<<<<<<<<<<<<<
 *         cdef PairPoint3d P
 *         cdef int previous_branch
 */
  __pyx_v_s = 0.0;
  __pyx_v_x = 0.0;
  __pyx_v_y = 0.0;
  __pyx_v_u = 0.0;
  __pyx_v_v = 0.0;

  /* "slabbe/mult_cont_frac.pyx":818
 *         cdef int xa,ya,ua,va
 *         cdef int i
 *         cdef double xlen = xmax - xmin             # <<<<<<<<<<<<<<
 *         cdef double ylen = ymax - ymin
 *         cdef double ulen = umax - umin
 */
  __pyx_v_xlen = (__pyx_v_xmax - __pyx_v_xmin);

  /* "slabbe/mult_cont_frac.pyx":819
 *         cdef int i
 *         cdef double xlen = xmax - xmin
 *         cdef double ylen = ymax - ymin             # <<<<<<<<<<<<<<
 *         cdef double ulen = umax - umin
 *         cdef double vlen = vmax - vmin
 */
  __pyx_v_ylen = (__pyx_v_ymax - __pyx_v_ymin);

  /* "slabbe/mult_cont_frac.pyx":820
 *         cdef double xlen = xmax - xmin
 *         cdef double ylen = ymax - ymin
 *         cdef double ulen = umax - umin             # <<<<<<<<<<<<<<
 *         cdef double vlen = vmax - vmin
 *         if start is None:
 */
  __pyx_v_ulen = (__pyx_v_umax - __pyx_v_umin);

  /* "slabbe/mult_cont_frac.pyx":821
 *         cdef double ylen = ymax - ymin
 *         cdef double ulen = umax - umin
 *         cdef double vlen = vmax - vmin             # <<<<<<<<<<<<<<
 *         if start is None:
 *             P.x = random(); P.y = random(); P.z = random()
 */
  __pyx_v_vlen = (__pyx_v_vmax - __pyx_v_vmin);

  /* "slabbe/mult_cont_frac.pyx":822
 *         cdef double ulen = umax - umin
 *         cdef double vlen = vmax - vmin
 *         if start is None:             # <<<<<<<<<<<<<<
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 */
  __pyx_t_1 = (__pyx_v_start == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":823
 *         cdef double vlen = vmax - vmin
 *         if start is None:
 *             P.x = random(); P.y = random(); P.z = random()             # <<<<<<<<<<<<<<
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 823, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 823, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.x = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 823, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 823, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.y = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 823, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 823, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.z = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":822
 *         cdef double ulen = umax - umin
 *         cdef double vlen = vmax - vmin
 *         if start is None:             # <<<<<<<<<<<<<<
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":825
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]             # <<<<<<<<<<<<<<
 *         P.u = 1./3
 *         P.v = 1./3
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_start, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 825, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 825, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.x = __pyx_t_6;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_start, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 825, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 825, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.y = __pyx_t_6;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_start, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 825, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 825, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.z = __pyx_t_6;
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":826
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1./3             # <<<<<<<<<<<<<<
 *         P.v = 1./3
 *         P.w = 1./3
 */
  __pyx_v_P.u = (1. / 3.0);

  /* "slabbe/mult_cont_frac.pyx":827
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1./3
 *         P.v = 1./3             # <<<<<<<<<<<<<<
 *         P.w = 1./3
 * 
 */
  __pyx_v_P.v = (1. / 3.0);

  /* "slabbe/mult_cont_frac.pyx":828
 *         P.u = 1./3
 *         P.v = 1./3
 *         P.w = 1./3             # <<<<<<<<<<<<<<
 * 
 *         if ndivs and float('inf') in [-xmin, -ymin, -umin, -vmin, xmax, ymax, umax, vmax]:
 */
  __pyx_v_P.w = (1. / 3.0);

  /* "slabbe/mult_cont_frac.pyx":830
 *         P.w = 1./3
 * 
 *         if ndivs and float('inf') in [-xmin, -ymin, -umin, -vmin, xmax, ymax, umax, vmax]:             # <<<<<<<<<<<<<<
 *             raise ValueError("when ndivs is specified, you must provide a"
 *                     " value for xmin, xmax, ymin, ymax, umin, umax, vmin"
 */
  __pyx_t_1 = (__pyx_v_ndivs != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_6 = (-__pyx_v_xmin);
  __pyx_t_7 = (-__pyx_v_ymin);
  __pyx_t_8 = (-__pyx_v_umin);
  __pyx_t_9 = (-__pyx_v_vmin);
  __pyx_t_10 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_10 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 830, __pyx_L1_error)
  __pyx_t_11 = ((__pyx_t_10 == __pyx_t_6) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_1 = __pyx_t_11;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_t_10 == __pyx_t_7) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_1 = __pyx_t_11;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_t_10 == __pyx_t_8) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_1 = __pyx_t_11;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_t_10 == __pyx_t_9) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_1 = __pyx_t_11;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_t_10 == __pyx_v_xmax) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_1 = __pyx_t_11;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_t_10 == __pyx_v_ymax) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_1 = __pyx_t_11;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_t_10 == __pyx_v_umax) != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_1 = __pyx_t_11;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_11 = ((__pyx_t_10 == __pyx_v_vmax) != 0);
  __pyx_t_1 = __pyx_t_11;
  __pyx_L7_bool_binop_done:;
  __pyx_t_11 = (__pyx_t_1 != 0);
  __pyx_t_2 = __pyx_t_11;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":831
 * 
 *         if ndivs and float('inf') in [-xmin, -ymin, -umin, -vmin, xmax, ymax, umax, vmax]:
 *             raise ValueError("when ndivs is specified, you must provide a"             # <<<<<<<<<<<<<<
 *                     " value for xmin, xmax, ymin, ymax, umin, umax, vmin"
 *                     " and vmax")
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 831, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 831, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":830
 *         P.w = 1./3
 * 
 *         if ndivs and float('inf') in [-xmin, -ymin, -umin, -vmin, xmax, ymax, umax, vmax]:             # <<<<<<<<<<<<<<
 *             raise ValueError("when ndivs is specified, you must provide a"
 *                     " value for xmin, xmax, ymin, ymax, umin, umax, vmin"
 */
  }

  /* "slabbe/mult_cont_frac.pyx":836
 * 
 *         # Normalize (x,y,z)
 *         s = P.x + P.y + P.z             # <<<<<<<<<<<<<<
 *         P.x /= s; P.y /= s; P.z /= s
 * 
 */
  __pyx_v_s = ((__pyx_v_P.x + __pyx_v_P.y) + __pyx_v_P.z);

  /* "slabbe/mult_cont_frac.pyx":837
 *         # Normalize (x,y,z)
 *         s = P.x + P.y + P.z
 *         P.x /= s; P.y /= s; P.z /= s             # <<<<<<<<<<<<<<
 * 
 *         L = []
 */
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 837, __pyx_L1_error)
  }
  __pyx_v_P.x = (__pyx_v_P.x / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 837, __pyx_L1_error)
  }
  __pyx_v_P.y = (__pyx_v_P.y / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 837, __pyx_L1_error)
  }
  __pyx_v_P.z = (__pyx_v_P.z / __pyx_v_s);

  /* "slabbe/mult_cont_frac.pyx":839
 *         P.x /= s; P.y /= s; P.z /= s
 * 
 *         L = []             # <<<<<<<<<<<<<<
 * 
 *         # Apply Algo once
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 839, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_L = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":842
 * 
 *         # Apply Algo once
 *         P = self.call(P)             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */
  __pyx_t_12 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self->__pyx_vtab)->call(__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 842, __pyx_L1_error)
  __pyx_v_P = __pyx_t_12;

  /* "slabbe/mult_cont_frac.pyx":845
 * 
 *         # Loop
 *         for i from 0 <= i < n_iterations:             # <<<<<<<<<<<<<<
 * 
 *             # Check for Keyboard interupt
 */
  __pyx_t_13 = __pyx_v_n_iterations;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_13; __pyx_v_i++) {

    /* "slabbe/mult_cont_frac.pyx":848
 * 
 *             # Check for Keyboard interupt
 *             sig_check()             # <<<<<<<<<<<<<<
 * 
 *             # Normalize (xnew,ynew,znew)
 */
    __pyx_t_14 = sig_check(); if (unlikely(__pyx_t_14 == 0)) __PYX_ERR(0, 848, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":851
 * 
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_xyz, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 851, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":852
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':
 *                 s = P.x + P.y + P.z # norm 1             # <<<<<<<<<<<<<<
 *             elif norm_xyz == 'sup':
 *                 s = max(P.x, P.y, P.z) # norm sup
 */
      __pyx_v_s = ((__pyx_v_P.x + __pyx_v_P.y) + __pyx_v_P.z);

      /* "slabbe/mult_cont_frac.pyx":851
 * 
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':
 */
      goto __pyx_L17;
    }

    /* "slabbe/mult_cont_frac.pyx":853
 *             if norm_xyz == '1':
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_xyz, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 853, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":854
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':
 *                 s = max(P.x, P.y, P.z) # norm sup             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)
 */
      __pyx_t_6 = __pyx_v_P.y;
      __pyx_t_7 = __pyx_v_P.z;
      __pyx_t_8 = __pyx_v_P.x;
      if (((__pyx_t_6 > __pyx_t_8) != 0)) {
        __pyx_t_9 = __pyx_t_6;
      } else {
        __pyx_t_9 = __pyx_t_8;
      }
      __pyx_t_8 = __pyx_t_9;
      if (((__pyx_t_7 > __pyx_t_8) != 0)) {
        __pyx_t_9 = __pyx_t_7;
      } else {
        __pyx_t_9 = __pyx_t_8;
      }
      __pyx_v_s = __pyx_t_9;

      /* "slabbe/mult_cont_frac.pyx":853
 *             if norm_xyz == '1':
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 */
      goto __pyx_L17;
    }

    /* "slabbe/mult_cont_frac.pyx":856
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)             # <<<<<<<<<<<<<<
 *             P.x /= s; P.y /= s; P.z /= s
 * 
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_value_for_norm_xyz_s, __pyx_v_norm_xyz); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 856, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 856, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 856, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 856, __pyx_L1_error)
    }
    __pyx_L17:;

    /* "slabbe/mult_cont_frac.pyx":857
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)
 *             P.x /= s; P.y /= s; P.z /= s             # <<<<<<<<<<<<<<
 * 
 *             # Normalize (unew,vnew,wnew)
 */
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 857, __pyx_L1_error)
    }
    __pyx_v_P.x = (__pyx_v_P.x / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 857, __pyx_L1_error)
    }
    __pyx_v_P.y = (__pyx_v_P.y / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 857, __pyx_L1_error)
    }
    __pyx_v_P.z = (__pyx_v_P.z / __pyx_v_s);

    /* "slabbe/mult_cont_frac.pyx":860
 * 
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 860, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":861
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':
 *                 s = P.u + P.v + P.w    # norm 1             # <<<<<<<<<<<<<<
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup
 */
      __pyx_v_s = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

      /* "slabbe/mult_cont_frac.pyx":860
 * 
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':
 */
      goto __pyx_L18;
    }

    /* "slabbe/mult_cont_frac.pyx":862
 *             if norm_uvw == '1':
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 862, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":863
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup             # <<<<<<<<<<<<<<
 *             elif norm_uvw == 'hypersurface':
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 */
      __pyx_t_9 = __pyx_v_P.v;
      __pyx_t_6 = __pyx_v_P.w;
      __pyx_t_7 = __pyx_v_P.u;
      if (((__pyx_t_9 > __pyx_t_7) != 0)) {
        __pyx_t_8 = __pyx_t_9;
      } else {
        __pyx_t_8 = __pyx_t_7;
      }
      __pyx_t_7 = __pyx_t_8;
      if (((__pyx_t_6 > __pyx_t_7) != 0)) {
        __pyx_t_8 = __pyx_t_6;
      } else {
        __pyx_t_8 = __pyx_t_7;
      }
      __pyx_v_s = __pyx_t_8;

      /* "slabbe/mult_cont_frac.pyx":862
 *             if norm_uvw == '1':
 *                 s = P.u + P.v + P.w    # norm 1
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 */
      goto __pyx_L18;
    }

    /* "slabbe/mult_cont_frac.pyx":864
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':             # <<<<<<<<<<<<<<
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 *             else:
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_n_s_hypersurface, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 864, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":865
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)
 */
      __pyx_v_s = (((__pyx_v_P.x * __pyx_v_P.u) + (__pyx_v_P.y * __pyx_v_P.v)) + (__pyx_v_P.z * __pyx_v_P.w));

      /* "slabbe/mult_cont_frac.pyx":864
 *             elif norm_uvw == 'sup':
 *                 s = max(P.u, P.v, P.w) # norm sup
 *             elif norm_uvw == 'hypersurface':             # <<<<<<<<<<<<<<
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 *             else:
 */
      goto __pyx_L18;
    }

    /* "slabbe/mult_cont_frac.pyx":867
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w # hypersurface
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)             # <<<<<<<<<<<<<<
 *             P.u /= s; P.v /= s; P.w /= s
 * 
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_value_for_norm_uvw_s, __pyx_v_norm_uvw); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 867, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 867, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 867, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 867, __pyx_L1_error)
    }
    __pyx_L18:;

    /* "slabbe/mult_cont_frac.pyx":868
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)
 *             P.u /= s; P.v /= s; P.w /= s             # <<<<<<<<<<<<<<
 * 
 *             # Projection
 */
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 868, __pyx_L1_error)
    }
    __pyx_v_P.u = (__pyx_v_P.u / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 868, __pyx_L1_error)
    }
    __pyx_v_P.v = (__pyx_v_P.v / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 868, __pyx_L1_error)
    }
    __pyx_v_P.w = (__pyx_v_P.w / __pyx_v_s);

    /* "slabbe/mult_cont_frac.pyx":871
 * 
 *             # Projection
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 x = -SQRT3SUR2 * P.x + SQRT3SUR2 * P.y
 *                 y = -.5 * P.x -.5 * P.y + P.z
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_xyz, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 871, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":872
 *             # Projection
 *             if norm_xyz == '1':
 *                 x = -SQRT3SUR2 * P.x + SQRT3SUR2 * P.y             # <<<<<<<<<<<<<<
 *                 y = -.5 * P.x -.5 * P.y + P.z
 *             elif norm_xyz == 'sup':
 */
      __pyx_v_x = (((-__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2) * __pyx_v_P.x) + (__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2 * __pyx_v_P.y));

      /* "slabbe/mult_cont_frac.pyx":873
 *             if norm_xyz == '1':
 *                 x = -SQRT3SUR2 * P.x + SQRT3SUR2 * P.y
 *                 y = -.5 * P.x -.5 * P.y + P.z             # <<<<<<<<<<<<<<
 *             elif norm_xyz == 'sup':
 *                 x = P.x
 */
      __pyx_v_y = (((-.5 * __pyx_v_P.x) - (.5 * __pyx_v_P.y)) + __pyx_v_P.z);

      /* "slabbe/mult_cont_frac.pyx":871
 * 
 *             # Projection
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 x = -SQRT3SUR2 * P.x + SQRT3SUR2 * P.y
 *                 y = -.5 * P.x -.5 * P.y + P.z
 */
      goto __pyx_L19;
    }

    /* "slabbe/mult_cont_frac.pyx":874
 *                 x = -SQRT3SUR2 * P.x + SQRT3SUR2 * P.y
 *                 y = -.5 * P.x -.5 * P.y + P.z
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 x = P.x
 *                 y = P.y
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_xyz, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 874, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":875
 *                 y = -.5 * P.x -.5 * P.y + P.z
 *             elif norm_xyz == 'sup':
 *                 x = P.x             # <<<<<<<<<<<<<<
 *                 y = P.y
 * 
 */
      __pyx_t_8 = __pyx_v_P.x;
      __pyx_v_x = __pyx_t_8;

      /* "slabbe/mult_cont_frac.pyx":876
 *             elif norm_xyz == 'sup':
 *                 x = P.x
 *                 y = P.y             # <<<<<<<<<<<<<<
 * 
 *             if norm_uvw == '1':
 */
      __pyx_t_8 = __pyx_v_P.y;
      __pyx_v_y = __pyx_t_8;

      /* "slabbe/mult_cont_frac.pyx":874
 *                 x = -SQRT3SUR2 * P.x + SQRT3SUR2 * P.y
 *                 y = -.5 * P.x -.5 * P.y + P.z
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 x = P.x
 *                 y = P.y
 */
    }
    __pyx_L19:;

    /* "slabbe/mult_cont_frac.pyx":878
 *                 y = P.y
 * 
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 u = -SQRT3SUR2 * P.u + SQRT3SUR2 * P.v
 *                 v = -.5 * P.u -.5 * P.v + P.w
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 878, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":879
 * 
 *             if norm_uvw == '1':
 *                 u = -SQRT3SUR2 * P.u + SQRT3SUR2 * P.v             # <<<<<<<<<<<<<<
 *                 v = -.5 * P.u -.5 * P.v + P.w
 *             elif norm_uvw == 'sup':
 */
      __pyx_v_u = (((-__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2) * __pyx_v_P.u) + (__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2 * __pyx_v_P.v));

      /* "slabbe/mult_cont_frac.pyx":880
 *             if norm_uvw == '1':
 *                 u = -SQRT3SUR2 * P.u + SQRT3SUR2 * P.v
 *                 v = -.5 * P.u -.5 * P.v + P.w             # <<<<<<<<<<<<<<
 *             elif norm_uvw == 'sup':
 *                 u = P.u
 */
      __pyx_v_v = (((-.5 * __pyx_v_P.u) - (.5 * __pyx_v_P.v)) + __pyx_v_P.w);

      /* "slabbe/mult_cont_frac.pyx":878
 *                 y = P.y
 * 
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 u = -SQRT3SUR2 * P.u + SQRT3SUR2 * P.v
 *                 v = -.5 * P.u -.5 * P.v + P.w
 */
      goto __pyx_L20;
    }

    /* "slabbe/mult_cont_frac.pyx":881
 *                 u = -SQRT3SUR2 * P.u + SQRT3SUR2 * P.v
 *                 v = -.5 * P.u -.5 * P.v + P.w
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 u = P.u
 *                 v = P.v
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 881, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "slabbe/mult_cont_frac.pyx":882
 *                 v = -.5 * P.u -.5 * P.v + P.w
 *             elif norm_uvw == 'sup':
 *                 u = P.u             # <<<<<<<<<<<<<<
 *                 v = P.v
 * 
 */
      __pyx_t_8 = __pyx_v_P.u;
      __pyx_v_u = __pyx_t_8;

      /* "slabbe/mult_cont_frac.pyx":883
 *             elif norm_uvw == 'sup':
 *                 u = P.u
 *                 v = P.v             # <<<<<<<<<<<<<<
 * 
 *             # Apply Algo
 */
      __pyx_t_8 = __pyx_v_P.v;
      __pyx_v_v = __pyx_t_8;

      /* "slabbe/mult_cont_frac.pyx":881
 *                 u = -SQRT3SUR2 * P.u + SQRT3SUR2 * P.v
 *                 v = -.5 * P.u -.5 * P.v + P.w
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 u = P.u
 *                 v = P.v
 */
    }
    __pyx_L20:;

    /* "slabbe/mult_cont_frac.pyx":886
 * 
 *             # Apply Algo
 *             previous_branch = P.branch             # <<<<<<<<<<<<<<
 *             P = self.call(P)
 * 
 */
    __pyx_t_14 = __pyx_v_P.branch;
    __pyx_v_previous_branch = __pyx_t_14;

    /* "slabbe/mult_cont_frac.pyx":887
 *             # Apply Algo
 *             previous_branch = P.branch
 *             P = self.call(P)             # <<<<<<<<<<<<<<
 * 
 *             # filter
 */
    __pyx_t_12 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self->__pyx_vtab)->call(__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 887, __pyx_L1_error)
    __pyx_v_P = __pyx_t_12;

    /* "slabbe/mult_cont_frac.pyx":890
 * 
 *             # filter
 *             if not (xmin < x < xmax and ymin < y < ymax and             # <<<<<<<<<<<<<<
 *                     umin < u < umax and vmin < v < vmax):
 *                 continue
 */
    __pyx_t_11 = (__pyx_v_xmin < __pyx_v_x);
    if (__pyx_t_11) {
      __pyx_t_11 = (__pyx_v_x < __pyx_v_xmax);
    }
    __pyx_t_1 = (__pyx_t_11 != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L22_bool_binop_done;
    }
    __pyx_t_1 = (__pyx_v_ymin < __pyx_v_y);
    if (__pyx_t_1) {
      __pyx_t_1 = (__pyx_v_y < __pyx_v_ymax);
    }
    __pyx_t_11 = (__pyx_t_1 != 0);
    if (__pyx_t_11) {
    } else {
      __pyx_t_2 = __pyx_t_11;
      goto __pyx_L22_bool_binop_done;
    }

    /* "slabbe/mult_cont_frac.pyx":891
 *             # filter
 *             if not (xmin < x < xmax and ymin < y < ymax and
 *                     umin < u < umax and vmin < v < vmax):             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
    __pyx_t_11 = (__pyx_v_umin < __pyx_v_u);
    if (__pyx_t_11) {
      __pyx_t_11 = (__pyx_v_u < __pyx_v_umax);
    }
    __pyx_t_1 = (__pyx_t_11 != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L22_bool_binop_done;
    }
    __pyx_t_1 = (__pyx_v_vmin < __pyx_v_v);
    if (__pyx_t_1) {
      __pyx_t_1 = (__pyx_v_v < __pyx_v_vmax);
    }
    __pyx_t_11 = (__pyx_t_1 != 0);
    __pyx_t_2 = __pyx_t_11;
    __pyx_L22_bool_binop_done:;

    /* "slabbe/mult_cont_frac.pyx":890
 * 
 *             # filter
 *             if not (xmin < x < xmax and ymin < y < ymax and             # <<<<<<<<<<<<<<
 *                     umin < u < umax and vmin < v < vmax):
 *                 continue
 */
    __pyx_t_11 = ((!__pyx_t_2) != 0);
    if (__pyx_t_11) {

      /* "slabbe/mult_cont_frac.pyx":892
 *             if not (xmin < x < xmax and ymin < y < ymax and
 *                     umin < u < umax and vmin < v < vmax):
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             # ndivs
 */
      goto __pyx_L15_continue;

      /* "slabbe/mult_cont_frac.pyx":890
 * 
 *             # filter
 *             if not (xmin < x < xmax and ymin < y < ymax and             # <<<<<<<<<<<<<<
 *                     umin < u < umax and vmin < v < vmax):
 *                 continue
 */
    }

    /* "slabbe/mult_cont_frac.pyx":895
 * 
 *             # ndivs
 *             if ndivs:             # <<<<<<<<<<<<<<
 *                 xa = int( (x-xmin) / xlen * ndivs )
 *                 ya = int( (ymax-y) / ylen * ndivs )
 */
    __pyx_t_11 = (__pyx_v_ndivs != 0);
    if (__pyx_t_11) {

      /* "slabbe/mult_cont_frac.pyx":896
 *             # ndivs
 *             if ndivs:
 *                 xa = int( (x-xmin) / xlen * ndivs )             # <<<<<<<<<<<<<<
 *                 ya = int( (ymax-y) / ylen * ndivs )
 *                 ua = int( (u-umin) / ulen * ndivs )
 */
      __pyx_t_8 = (__pyx_v_x - __pyx_v_xmin);
      if (unlikely(__pyx_v_xlen == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 896, __pyx_L1_error)
      }
      __pyx_v_xa = ((int)((__pyx_t_8 / __pyx_v_xlen) * __pyx_v_ndivs));

      /* "slabbe/mult_cont_frac.pyx":897
 *             if ndivs:
 *                 xa = int( (x-xmin) / xlen * ndivs )
 *                 ya = int( (ymax-y) / ylen * ndivs )             # <<<<<<<<<<<<<<
 *                 ua = int( (u-umin) / ulen * ndivs )
 *                 va = int( (vmax-v) / vlen * ndivs )
 */
      __pyx_t_8 = (__pyx_v_ymax - __pyx_v_y);
      if (unlikely(__pyx_v_ylen == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 897, __pyx_L1_error)
      }
      __pyx_v_ya = ((int)((__pyx_t_8 / __pyx_v_ylen) * __pyx_v_ndivs));

      /* "slabbe/mult_cont_frac.pyx":898
 *                 xa = int( (x-xmin) / xlen * ndivs )
 *                 ya = int( (ymax-y) / ylen * ndivs )
 *                 ua = int( (u-umin) / ulen * ndivs )             # <<<<<<<<<<<<<<
 *                 va = int( (vmax-v) / vlen * ndivs )
 *                 L.append( (xa,ya,ua,va, previous_branch, P.branch))
 */
      __pyx_t_8 = (__pyx_v_u - __pyx_v_umin);
      if (unlikely(__pyx_v_ulen == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 898, __pyx_L1_error)
      }
      __pyx_v_ua = ((int)((__pyx_t_8 / __pyx_v_ulen) * __pyx_v_ndivs));

      /* "slabbe/mult_cont_frac.pyx":899
 *                 ya = int( (ymax-y) / ylen * ndivs )
 *                 ua = int( (u-umin) / ulen * ndivs )
 *                 va = int( (vmax-v) / vlen * ndivs )             # <<<<<<<<<<<<<<
 *                 L.append( (xa,ya,ua,va, previous_branch, P.branch))
 *             else:
 */
      __pyx_t_8 = (__pyx_v_vmax - __pyx_v_v);
      if (unlikely(__pyx_v_vlen == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 899, __pyx_L1_error)
      }
      __pyx_v_va = ((int)((__pyx_t_8 / __pyx_v_vlen) * __pyx_v_ndivs));

      /* "slabbe/mult_cont_frac.pyx":900
 *                 ua = int( (u-umin) / ulen * ndivs )
 *                 va = int( (vmax-v) / vlen * ndivs )
 *                 L.append( (xa,ya,ua,va, previous_branch, P.branch))             # <<<<<<<<<<<<<<
 *             else:
 *                 L.append( (x,y,u,v, previous_branch, P.branch))
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_xa); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 900, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_ya); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 900, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_ua); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 900, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_va); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 900, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_previous_branch); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 900, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = __Pyx_PyInt_From_int(__pyx_v_P.branch); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 900, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_18 = PyTuple_New(6); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 900, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_18, 2, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_18, 3, __pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_18, 4, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_18, 5, __pyx_t_17);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_15 = 0;
      __pyx_t_16 = 0;
      __pyx_t_17 = 0;
      __pyx_t_19 = __Pyx_PyList_Append(__pyx_v_L, __pyx_t_18); if (unlikely(__pyx_t_19 == -1)) __PYX_ERR(0, 900, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

      /* "slabbe/mult_cont_frac.pyx":895
 * 
 *             # ndivs
 *             if ndivs:             # <<<<<<<<<<<<<<
 *                 xa = int( (x-xmin) / xlen * ndivs )
 *                 ya = int( (ymax-y) / ylen * ndivs )
 */
      goto __pyx_L26;
    }

    /* "slabbe/mult_cont_frac.pyx":902
 *                 L.append( (xa,ya,ua,va, previous_branch, P.branch))
 *             else:
 *                 L.append( (x,y,u,v, previous_branch, P.branch))             # <<<<<<<<<<<<<<
 * 
 *         return L
 */
    /*else*/ {
      __pyx_t_18 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 902, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_17 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 902, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_16 = PyFloat_FromDouble(__pyx_v_u); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 902, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_15 = PyFloat_FromDouble(__pyx_v_v); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 902, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_previous_branch); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 902, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_P.branch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 902, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 902, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_18);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_18);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_4);
      __pyx_t_18 = 0;
      __pyx_t_17 = 0;
      __pyx_t_16 = 0;
      __pyx_t_15 = 0;
      __pyx_t_5 = 0;
      __pyx_t_4 = 0;
      __pyx_t_19 = __Pyx_PyList_Append(__pyx_v_L, __pyx_t_3); if (unlikely(__pyx_t_19 == -1)) __PYX_ERR(0, 902, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L26:;
    __pyx_L15_continue:;
  }

  /* "slabbe/mult_cont_frac.pyx":904
 *                 L.append( (x,y,u,v, previous_branch, P.branch))
 * 
 *         return L             # <<<<<<<<<<<<<<
 * 
 *     def cone_orbit_iterator(self, start=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_L);
  __pyx_r = __pyx_v_L;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":723
 *         return L
 * 
 *     def simplex_orbit_filtered_list(self, start=None, int n_iterations=100,             # <<<<<<<<<<<<<<
 *             norm_xyz='1', norm_uvw='1',
 *             double xmin=-float('inf'), double xmax=float('inf'),
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.simplex_orbit_filtered_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_L);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_38generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "slabbe/mult_cont_frac.pyx":906
 *         return L
 * 
 *     def cone_orbit_iterator(self, start=None):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_37cone_orbit_iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_36cone_orbit_iterator[] = "\n        INPUT:\n\n        - ``start`` - initial vector (default: ``None``), if None, then\n          initial point is random\n\n        NOTE:\n\n            This iterator is 10x slower because of the yield statement. So\n            avoid using this when writing fast code. Just copy paste the\n            loop or use simplex_orbit_list or simplex_orbit_filtered_list method.\n\n        OUTPUT:\n\n            iterator\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: it = Brun().cone_orbit_iterator((13,17,29))\n            sage: for _ in range(10): next(it)\n            ((13.0, 17.0, 12.0), (1.0, 2.0, 1.0), 123)\n            ((13.0, 4.0, 12.0), (3.0, 2.0, 1.0), 312)\n            ((1.0, 4.0, 12.0), (3.0, 2.0, 4.0), 231)\n            ((1.0, 4.0, 8.0), (3.0, 6.0, 4.0), 123)\n            ((1.0, 4.0, 4.0), (3.0, 10.0, 4.0), 123)\n            ((1.0, 4.0, 0.0), (3.0, 14.0, 4.0), 123)\n            ((1.0, 3.0, 0.0), (17.0, 14.0, 4.0), 312)\n            ((1.0, 2.0, 0.0), (31.0, 14.0, 4.0), 312)\n            ((1.0, 1.0, 0.0), (45.0, 14.0, 4.0), 312)\n            ((1.0, 0.0, 0.0), (59.0, 14.0, 4.0), 312)\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_37cone_orbit_iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cone_orbit_iterator (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cone_orbit_iterator") < 0)) __PYX_ERR(0, 906, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_start = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("cone_orbit_iterator", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 906, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.cone_orbit_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_36cone_orbit_iterator(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_start);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_36cone_orbit_iterator(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cone_orbit_iterator", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_start = __pyx_v_start;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_38generator2, (PyObject *) __pyx_cur_scope, __pyx_n_s_cone_orbit_iterator, __pyx_n_s_MCFAlgorithm_cone_orbit_iterator); if (unlikely(!gen)) __PYX_ERR(0, 906, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.cone_orbit_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_38generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *__pyx_cur_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_t_7;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L7_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 906, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":940
 *         """
 *         cdef PairPoint3d P
 *         if start is None:             # <<<<<<<<<<<<<<
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_start == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":941
 *         cdef PairPoint3d P
 *         if start is None:
 *             P.x = random(); P.y = random(); P.z = random()             # <<<<<<<<<<<<<<
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 941, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 941, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 941, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 941, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.x = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 941, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 941, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 941, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 941, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.y = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 941, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 941, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 941, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 941, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.z = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":940
 *         """
 *         cdef PairPoint3d P
 *         if start is None:             # <<<<<<<<<<<<<<
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 */
    goto __pyx_L4;
  }

  /* "slabbe/mult_cont_frac.pyx":943
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]             # <<<<<<<<<<<<<<
 *         P.u = 1
 *         P.v = 1
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_start, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 943, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 943, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.x = __pyx_t_6;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_start, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 943, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 943, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.y = __pyx_t_6;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_start, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 943, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 943, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_cur_scope->__pyx_v_P.z = __pyx_t_6;
  }
  __pyx_L4:;

  /* "slabbe/mult_cont_frac.pyx":944
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1             # <<<<<<<<<<<<<<
 *         P.v = 1
 *         P.w = 1
 */
  __pyx_cur_scope->__pyx_v_P.u = 1.0;

  /* "slabbe/mult_cont_frac.pyx":945
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1
 *         P.v = 1             # <<<<<<<<<<<<<<
 *         P.w = 1
 * 
 */
  __pyx_cur_scope->__pyx_v_P.v = 1.0;

  /* "slabbe/mult_cont_frac.pyx":946
 *         P.u = 1
 *         P.v = 1
 *         P.w = 1             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */
  __pyx_cur_scope->__pyx_v_P.w = 1.0;

  /* "slabbe/mult_cont_frac.pyx":949
 * 
 *         # Loop
 *         while True:             # <<<<<<<<<<<<<<
 *             sig_check() # Check for Keyboard interupt
 *             # Apply Algo
 */
  while (1) {

    /* "slabbe/mult_cont_frac.pyx":950
 *         # Loop
 *         while True:
 *             sig_check() # Check for Keyboard interupt             # <<<<<<<<<<<<<<
 *             # Apply Algo
 *             P = self.call(P)
 */
    __pyx_t_7 = sig_check(); if (unlikely(__pyx_t_7 == 0)) __PYX_ERR(0, 950, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":952
 *             sig_check() # Check for Keyboard interupt
 *             # Apply Algo
 *             P = self.call(P)             # <<<<<<<<<<<<<<
 *             yield (P.x, P.y, P.z), (P.u, P.v, P.w), P.branch
 *     def cone_orbit_list(self, start=None, int n_iterations=100):
 */
    __pyx_t_8 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->call(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 952, __pyx_L1_error)
    __pyx_cur_scope->__pyx_v_P = __pyx_t_8;

    /* "slabbe/mult_cont_frac.pyx":953
 *             # Apply Algo
 *             P = self.call(P)
 *             yield (P.x, P.y, P.z), (P.u, P.v, P.w), P.branch             # <<<<<<<<<<<<<<
 *     def cone_orbit_list(self, start=None, int n_iterations=100):
 *         r"""
 */
    __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 953, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.y); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 953, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.z); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 953, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 953, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.u); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 953, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.v); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 953, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_P.w); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 953, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 953, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_3);
    __pyx_t_5 = 0;
    __pyx_t_4 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_P.branch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 953, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 953, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L7_resume_from_yield:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 953, __pyx_L1_error)
  }

  /* "slabbe/mult_cont_frac.pyx":906
 *         return L
 * 
 *     def cone_orbit_iterator(self, start=None):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cone_orbit_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":954
 *             P = self.call(P)
 *             yield (P.x, P.y, P.z), (P.u, P.v, P.w), P.branch
 *     def cone_orbit_list(self, start=None, int n_iterations=100):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_40cone_orbit_list(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_39cone_orbit_list[] = "\n        INPUT:\n\n        - ``start`` - initial vector (default: ``None``), if None, then\n          initial point is random\n        - ``n_iterations`` - integer, number of iterations\n\n        OUTPUT:\n\n            list\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: L = Brun().cone_orbit_list((10, 21, 37), 20)\n            sage: L[-1]\n            (1.0, 0.0, 0.0, 68.0, 55.0, 658.0, 231)\n\n        .. TODO::\n\n            Check for a fixed point stop then.\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_40cone_orbit_list(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_start = 0;
  int __pyx_v_n_iterations;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cone_orbit_list (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start,&__pyx_n_s_n_iterations,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cone_orbit_list") < 0)) __PYX_ERR(0, 954, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_start = values[0];
    if (values[1]) {
      __pyx_v_n_iterations = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_n_iterations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 954, __pyx_L3_error)
    } else {
      __pyx_v_n_iterations = ((int)0x64);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("cone_orbit_list", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 954, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.cone_orbit_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_39cone_orbit_list(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_start, __pyx_v_n_iterations);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_39cone_orbit_list(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, int __pyx_v_n_iterations) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  CYTHON_UNUSED int __pyx_v_i;
  PyObject *__pyx_v_L = 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;
  double __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __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;
  int __pyx_t_15;
  __Pyx_RefNannySetupContext("cone_orbit_list", 0);

  /* "slabbe/mult_cont_frac.pyx":980
 *         cdef PairPoint3d P
 *         cdef int i
 *         if start is None:             # <<<<<<<<<<<<<<
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 */
  __pyx_t_1 = (__pyx_v_start == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":981
 *         cdef int i
 *         if start is None:
 *             P.x = random(); P.y = random(); P.z = random()             # <<<<<<<<<<<<<<
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 981, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 981, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 981, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.x = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 981, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 981, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 981, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.y = __pyx_t_6;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 981, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 981, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 981, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 981, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.z = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":980
 *         cdef PairPoint3d P
 *         cdef int i
 *         if start is None:             # <<<<<<<<<<<<<<
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":983
 *             P.x = random(); P.y = random(); P.z = random()
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]             # <<<<<<<<<<<<<<
 *         P.u = 1
 *         P.v = 1
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_start, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 983, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 983, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.x = __pyx_t_6;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_start, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 983, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 983, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.y = __pyx_t_6;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_start, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 983, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 983, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_P.z = __pyx_t_6;
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":984
 *         else:
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1             # <<<<<<<<<<<<<<
 *         P.v = 1
 *         P.w = 1
 */
  __pyx_v_P.u = 1.0;

  /* "slabbe/mult_cont_frac.pyx":985
 *             P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1
 *         P.v = 1             # <<<<<<<<<<<<<<
 *         P.w = 1
 * 
 */
  __pyx_v_P.v = 1.0;

  /* "slabbe/mult_cont_frac.pyx":986
 *         P.u = 1
 *         P.v = 1
 *         P.w = 1             # <<<<<<<<<<<<<<
 * 
 *         L = []
 */
  __pyx_v_P.w = 1.0;

  /* "slabbe/mult_cont_frac.pyx":988
 *         P.w = 1
 * 
 *         L = []             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 988, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_L = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":991
 * 
 *         # Loop
 *         for i from 0 <= i < n_iterations:             # <<<<<<<<<<<<<<
 *             sig_check() # Check for Keyboard interupt
 *             P = self.call(P)
 */
  __pyx_t_7 = __pyx_v_n_iterations;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {

    /* "slabbe/mult_cont_frac.pyx":992
 *         # Loop
 *         for i from 0 <= i < n_iterations:
 *             sig_check() # Check for Keyboard interupt             # <<<<<<<<<<<<<<
 *             P = self.call(P)
 *             L.append( (P.x, P.y, P.z, P.u, P.v, P.w, P.branch))
 */
    __pyx_t_8 = sig_check(); if (unlikely(__pyx_t_8 == 0)) __PYX_ERR(0, 992, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":993
 *         for i from 0 <= i < n_iterations:
 *             sig_check() # Check for Keyboard interupt
 *             P = self.call(P)             # <<<<<<<<<<<<<<
 *             L.append( (P.x, P.y, P.z, P.u, P.v, P.w, P.branch))
 *         return L
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self->__pyx_vtab)->call(__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 993, __pyx_L1_error)
    __pyx_v_P = __pyx_t_9;

    /* "slabbe/mult_cont_frac.pyx":994
 *             sig_check() # Check for Keyboard interupt
 *             P = self.call(P)
 *             L.append( (P.x, P.y, P.z, P.u, P.v, P.w, P.branch))             # <<<<<<<<<<<<<<
 *         return L
 * 
 */
    __pyx_t_3 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 994, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 994, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_P.z); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 994, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_10 = PyFloat_FromDouble(__pyx_v_P.u); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 994, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = PyFloat_FromDouble(__pyx_v_P.v); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 994, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = PyFloat_FromDouble(__pyx_v_P.w); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 994, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_P.branch); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 994, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_14 = PyTuple_New(7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 994, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_14, 4, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_14, 5, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_14, 6, __pyx_t_13);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_10 = 0;
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_13 = 0;
    __pyx_t_15 = __Pyx_PyList_Append(__pyx_v_L, __pyx_t_14); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 994, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }

  /* "slabbe/mult_cont_frac.pyx":995
 *             P = self.call(P)
 *             L.append( (P.x, P.y, P.z, P.u, P.v, P.w, P.branch))
 *         return L             # <<<<<<<<<<<<<<
 * 
 *     def image(self, start, n_iterations=1):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_L);
  __pyx_r = __pyx_v_L;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":954
 *             P = self.call(P)
 *             yield (P.x, P.y, P.z), (P.u, P.v, P.w), P.branch
 *     def cone_orbit_list(self, start=None, int n_iterations=100):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __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_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.cone_orbit_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_L);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":997
 *         return L
 * 
 *     def image(self, start, n_iterations=1):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the image of a vector in R^3 after n iterations.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_42image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_41image[] = "\n        Return the image of a vector in R^3 after n iterations.\n\n        INPUT:\n\n        - ``start`` - initial vector\n        - ``n_iterations`` - integer, number of iterations (default: 1)\n\n        OUTPUT:\n\n            tuple of three floats\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: Brun().image((10, 21, 37))\n            (10.0, 21.0, 16.0)\n            sage: Brun().image((10, 21, 37), 2)\n            (10.0, 5.0, 16.0)\n            sage: Brun().image((10, 21, 37), 3)\n            (10.0, 5.0, 6.0)\n            sage: Brun().image((10, 21, 37), 10)\n            (1.0, 1.0, 0.0)\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_42image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_n_iterations = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("image (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start,&__pyx_n_s_n_iterations,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "image") < 0)) __PYX_ERR(0, 997, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_start = values[0];
    __pyx_v_n_iterations = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("image", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 997, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.image", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_41image(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_start, __pyx_v_n_iterations);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_41image(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_n_iterations) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  CYTHON_UNUSED int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  double __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("image", 0);

  /* "slabbe/mult_cont_frac.pyx":1024
 *         cdef PairPoint3d P
 *         cdef int i
 *         P.x = start[0]; P.y = start[1]; P.z = start[2]             # <<<<<<<<<<<<<<
 *         P.u = 1
 *         P.v = 1
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_start, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1024, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1024, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_P.x = __pyx_t_2;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_start, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1024, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1024, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_P.y = __pyx_t_2;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_start, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1024, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1024, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_P.z = __pyx_t_2;

  /* "slabbe/mult_cont_frac.pyx":1025
 *         cdef int i
 *         P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1             # <<<<<<<<<<<<<<
 *         P.v = 1
 *         P.w = 1
 */
  __pyx_v_P.u = 1.0;

  /* "slabbe/mult_cont_frac.pyx":1026
 *         P.x = start[0]; P.y = start[1]; P.z = start[2]
 *         P.u = 1
 *         P.v = 1             # <<<<<<<<<<<<<<
 *         P.w = 1
 * 
 */
  __pyx_v_P.v = 1.0;

  /* "slabbe/mult_cont_frac.pyx":1027
 *         P.u = 1
 *         P.v = 1
 *         P.w = 1             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */
  __pyx_v_P.w = 1.0;

  /* "slabbe/mult_cont_frac.pyx":1030
 * 
 *         # Loop
 *         for i from 0 <= i < n_iterations:             # <<<<<<<<<<<<<<
 *             sig_check() # Check for Keyboard interupt
 *             P = self.call(P)
 */
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_n_iterations); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1030, __pyx_L1_error)
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "slabbe/mult_cont_frac.pyx":1031
 *         # Loop
 *         for i from 0 <= i < n_iterations:
 *             sig_check() # Check for Keyboard interupt             # <<<<<<<<<<<<<<
 *             P = self.call(P)
 *         return (P.x, P.y, P.z)
 */
    __pyx_t_4 = sig_check(); if (unlikely(__pyx_t_4 == 0)) __PYX_ERR(0, 1031, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1032
 *         for i from 0 <= i < n_iterations:
 *             sig_check() # Check for Keyboard interupt
 *             P = self.call(P)             # <<<<<<<<<<<<<<
 *         return (P.x, P.y, P.z)
 * 
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self->__pyx_vtab)->call(__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1032, __pyx_L1_error)
    __pyx_v_P = __pyx_t_5;
  }

  /* "slabbe/mult_cont_frac.pyx":1033
 *             sig_check() # Check for Keyboard interupt
 *             P = self.call(P)
 *         return (P.x, P.y, P.z)             # <<<<<<<<<<<<<<
 * 
 *     def _invariant_measure_dict(self, int n_iterations, int ndivs, v=None,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyFloat_FromDouble(__pyx_v_P.z); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_r = __pyx_t_8;
  __pyx_t_8 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":997
 *         return L
 * 
 *     def image(self, start, n_iterations=1):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the image of a vector in R^3 after n iterations.
 */

  /* 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("slabbe.mult_cont_frac.MCFAlgorithm.image", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1035
 *         return (P.x, P.y, P.z)
 * 
 *     def _invariant_measure_dict(self, int n_iterations, int ndivs, v=None,             # <<<<<<<<<<<<<<
 *             str norm='1', verbose=False):
 *         r"""
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_44_invariant_measure_dict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_43_invariant_measure_dict[] = "\n        INPUT:\n\n        - ``n_iterations`` - integer, number of iterations\n        - ``ndvis`` - integer (less than or equal to 256), number of divisions per dimension\n        - ``v`` - initial vector (default: ``None``)\n        - ``norm`` -- string (default: ``'sup'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit of the algo\n        - ``verbose`` -- bool (default: ``False``)\n\n        OUTPUT:\n\n            dict\n\n        .. NOTE::\n\n            This method should be erased and replaced by code in the spirit of\n            simplex_orbit_list. Or otherwise read [1] and change cpdef int\n            C[NDIVS][NDIVS][NDIVS]\n\n            [1] https://groups.google.com/forum/?fromgroups=#!topic/sage-devel/NCBmj2KjwEM\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: D = Brun()._invariant_measure_dict(4, 10, verbose=True) # random\n            0.0799404500357 0.199341464229 0.720718085735\n            0 1\n            0.0998433745026 0.248971884172 0.651184741325\n            0 2\n            0.132942259282 0.331508073966 0.535549666752\n            1 3\n            0.198868907918 0.495904379777 0.305226712305\n            1 4\n\n        ::\n\n            sage: D = Brun()._invariant_measure_dict(100000, 5)\n            sage: sorted(D.iteritems())\n            [((0, 0), ...),\n             ((0, 1), ...),\n             ((0, 2), ...),\n             ((0, 3), ...),\n             ((0, 4), ...),\n             ((1, 1), ...),\n             ((1, 2), ...),\n             ((1, 3), ...),\n             ((2, 2), ...)]\n\n        It is 1000 times faster using C counter instead of a python dict counter::\n\n            sage: D = Brun()._invariant_measure_dict(1000000, 10) # 0.05s\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_44_invariant_measure_dict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_n_iterations;
  int __pyx_v_ndivs;
  CYTHON_UNUSED PyObject *__pyx_v_v = 0;
  PyObject *__pyx_v_norm = 0;
  PyObject *__pyx_v_verbose = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_invariant_measure_dict (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,&__pyx_n_s_ndivs,&__pyx_n_s_v,&__pyx_n_s_norm,&__pyx_n_s_verbose,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject*)__pyx_kp_s_1);

    /* "slabbe/mult_cont_frac.pyx":1036
 * 
 *     def _invariant_measure_dict(self, int n_iterations, int ndivs, v=None,
 *             str norm='1', verbose=False):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */
    values[4] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndivs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_invariant_measure_dict", 0, 2, 5, 1); __PYX_ERR(0, 1035, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_v);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_verbose);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_invariant_measure_dict") < 0)) __PYX_ERR(0, 1035, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_n_iterations = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_n_iterations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1035, __pyx_L3_error)
    __pyx_v_ndivs = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_ndivs == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1035, __pyx_L3_error)
    __pyx_v_v = values[2];
    __pyx_v_norm = ((PyObject*)values[3]);
    __pyx_v_verbose = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_invariant_measure_dict", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1035, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._invariant_measure_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_norm), (&PyString_Type), 1, "norm", 1))) __PYX_ERR(0, 1036, __pyx_L1_error)
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_43_invariant_measure_dict(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations, __pyx_v_ndivs, __pyx_v_v, __pyx_v_norm, __pyx_v_verbose);

  /* "slabbe/mult_cont_frac.pyx":1035
 *         return (P.x, P.y, P.z)
 * 
 *     def _invariant_measure_dict(self, int n_iterations, int ndivs, v=None,             # <<<<<<<<<<<<<<
 *             str norm='1', verbose=False):
 *         r"""
 */

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_43_invariant_measure_dict(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, int __pyx_v_n_iterations, int __pyx_v_ndivs, CYTHON_UNUSED PyObject *__pyx_v_v, PyObject *__pyx_v_norm, PyObject *__pyx_v_verbose) {
  double __pyx_v_s;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_X;
  int __pyx_v_Y;
  int __pyx_v_C[0x64][0x64];
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  PyObject *__pyx_v_D = NULL;
  int __pyx_v_c;
  PyObject *__pyx_r = NULL;
  __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;
  double __pyx_t_6;
  int __pyx_t_7;
  double __pyx_t_8;
  double __pyx_t_9;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_10;
  int __pyx_t_11;
  double __pyx_t_12;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("_invariant_measure_dict", 0);

  /* "slabbe/mult_cont_frac.pyx":1093
 *         # 146 works, 147 causes segmentation error!!!
 *         DEF NDIVS = 100
 *         assert ndivs <= NDIVS, "ndivs(=%s) must be less or equal to %s" % (ndivs, NDIVS)             # <<<<<<<<<<<<<<
 *         cdef double s
 *         cdef int i,j
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_ndivs <= 0x64) != 0))) {
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ndivs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1093, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1093, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_INCREF(__pyx_int_100);
      __Pyx_GIVEREF(__pyx_int_100);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_100);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_ndivs_s_must_be_less_or_equal_to, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1093, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 1093, __pyx_L1_error)
    }
  }
  #endif

  /* "slabbe/mult_cont_frac.pyx":1102
 *         # see https://groups.google.com/forum/?fromgroups=#!topic/sage-devel/NCBmj2KjwEM
 *         cpdef int C[NDIVS][NDIVS]
 *         for j from 0 <= j <= ndivs:             # <<<<<<<<<<<<<<
 *             for i from 0 <= i <= ndivs:
 *                 C[i][j] = 0
 */
  __pyx_t_3 = __pyx_v_ndivs;
  for (__pyx_v_j = 0; __pyx_v_j <= __pyx_t_3; __pyx_v_j++) {

    /* "slabbe/mult_cont_frac.pyx":1103
 *         cpdef int C[NDIVS][NDIVS]
 *         for j from 0 <= j <= ndivs:
 *             for i from 0 <= i <= ndivs:             # <<<<<<<<<<<<<<
 *                 C[i][j] = 0
 * 
 */
    __pyx_t_4 = __pyx_v_ndivs;
    for (__pyx_v_i = 0; __pyx_v_i <= __pyx_t_4; __pyx_v_i++) {

      /* "slabbe/mult_cont_frac.pyx":1104
 *         for j from 0 <= j <= ndivs:
 *             for i from 0 <= i <= ndivs:
 *                 C[i][j] = 0             # <<<<<<<<<<<<<<
 * 
 *         cdef PairPoint3d P
 */
      ((__pyx_v_C[__pyx_v_i])[__pyx_v_j]) = 0;
    }
  }

  /* "slabbe/mult_cont_frac.pyx":1107
 * 
 *         cdef PairPoint3d P
 *         P.x = random()             # <<<<<<<<<<<<<<
 *         P.y = random()
 *         P.z = random()
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1107, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1107, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1107, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_P.x = __pyx_t_6;

  /* "slabbe/mult_cont_frac.pyx":1108
 *         cdef PairPoint3d P
 *         P.x = random()
 *         P.y = random()             # <<<<<<<<<<<<<<
 *         P.z = random()
 *         P.u = .3
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1108, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1108, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1108, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_P.y = __pyx_t_6;

  /* "slabbe/mult_cont_frac.pyx":1109
 *         P.x = random()
 *         P.y = random()
 *         P.z = random()             # <<<<<<<<<<<<<<
 *         P.u = .3
 *         P.v = .3
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1109, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1109, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1109, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_P.z = __pyx_t_6;

  /* "slabbe/mult_cont_frac.pyx":1110
 *         P.y = random()
 *         P.z = random()
 *         P.u = .3             # <<<<<<<<<<<<<<
 *         P.v = .3
 *         P.w = .3
 */
  __pyx_v_P.u = .3;

  /* "slabbe/mult_cont_frac.pyx":1111
 *         P.z = random()
 *         P.u = .3
 *         P.v = .3             # <<<<<<<<<<<<<<
 *         P.w = .3
 *         P.branch = 999
 */
  __pyx_v_P.v = .3;

  /* "slabbe/mult_cont_frac.pyx":1112
 *         P.u = .3
 *         P.v = .3
 *         P.w = .3             # <<<<<<<<<<<<<<
 *         P.branch = 999
 * 
 */
  __pyx_v_P.w = .3;

  /* "slabbe/mult_cont_frac.pyx":1113
 *         P.v = .3
 *         P.w = .3
 *         P.branch = 999             # <<<<<<<<<<<<<<
 * 
 *         # Order (x,y,z)
 */
  __pyx_v_P.branch = 0x3E7;

  /* "slabbe/mult_cont_frac.pyx":1116
 * 
 *         # Order (x,y,z)
 *         if P.y > P.z: P.z,P.y = P.y,P.z             # <<<<<<<<<<<<<<
 *         if P.x > P.z: P.x,P.y,P.z = P.y,P.z,P.x
 *         elif P.x > P.y: P.x,P.y = P.y,P.x
 */
  __pyx_t_7 = ((__pyx_v_P.y > __pyx_v_P.z) != 0);
  if (__pyx_t_7) {
    __pyx_t_6 = __pyx_v_P.y;
    __pyx_t_8 = __pyx_v_P.z;
    __pyx_v_P.z = __pyx_t_6;
    __pyx_v_P.y = __pyx_t_8;
  }

  /* "slabbe/mult_cont_frac.pyx":1117
 *         # Order (x,y,z)
 *         if P.y > P.z: P.z,P.y = P.y,P.z
 *         if P.x > P.z: P.x,P.y,P.z = P.y,P.z,P.x             # <<<<<<<<<<<<<<
 *         elif P.x > P.y: P.x,P.y = P.y,P.x
 * 
 */
  __pyx_t_7 = ((__pyx_v_P.x > __pyx_v_P.z) != 0);
  if (__pyx_t_7) {
    __pyx_t_8 = __pyx_v_P.y;
    __pyx_t_6 = __pyx_v_P.z;
    __pyx_t_9 = __pyx_v_P.x;
    __pyx_v_P.x = __pyx_t_8;
    __pyx_v_P.y = __pyx_t_6;
    __pyx_v_P.z = __pyx_t_9;
    goto __pyx_L8;
  }

  /* "slabbe/mult_cont_frac.pyx":1118
 *         if P.y > P.z: P.z,P.y = P.y,P.z
 *         if P.x > P.z: P.x,P.y,P.z = P.y,P.z,P.x
 *         elif P.x > P.y: P.x,P.y = P.y,P.x             # <<<<<<<<<<<<<<
 * 
 *         # Normalize (x,y,z)
 */
  __pyx_t_7 = ((__pyx_v_P.x > __pyx_v_P.y) != 0);
  if (__pyx_t_7) {
    __pyx_t_9 = __pyx_v_P.y;
    __pyx_t_6 = __pyx_v_P.x;
    __pyx_v_P.x = __pyx_t_9;
    __pyx_v_P.y = __pyx_t_6;
  }
  __pyx_L8:;

  /* "slabbe/mult_cont_frac.pyx":1121
 * 
 *         # Normalize (x,y,z)
 *         s = P.x + P.y + P.z             # <<<<<<<<<<<<<<
 *         P.x /= s; P.y /= s; P.z /= s
 * 
 */
  __pyx_v_s = ((__pyx_v_P.x + __pyx_v_P.y) + __pyx_v_P.z);

  /* "slabbe/mult_cont_frac.pyx":1122
 *         # Normalize (x,y,z)
 *         s = P.x + P.y + P.z
 *         P.x /= s; P.y /= s; P.z /= s             # <<<<<<<<<<<<<<
 * 
 *         for i from 0 <= i < n_iterations:
 */
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1122, __pyx_L1_error)
  }
  __pyx_v_P.x = (__pyx_v_P.x / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1122, __pyx_L1_error)
  }
  __pyx_v_P.y = (__pyx_v_P.y / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1122, __pyx_L1_error)
  }
  __pyx_v_P.z = (__pyx_v_P.z / __pyx_v_s);

  /* "slabbe/mult_cont_frac.pyx":1124
 *         P.x /= s; P.y /= s; P.z /= s
 * 
 *         for i from 0 <= i < n_iterations:             # <<<<<<<<<<<<<<
 * 
 *             # Check for Keyboard interupt
 */
  __pyx_t_3 = __pyx_v_n_iterations;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "slabbe/mult_cont_frac.pyx":1127
 * 
 *             # Check for Keyboard interupt
 *             sig_check()             # <<<<<<<<<<<<<<
 * 
 *             # Apply Algo
 */
    __pyx_t_4 = sig_check(); if (unlikely(__pyx_t_4 == 0)) __PYX_ERR(0, 1127, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1130
 * 
 *             # Apply Algo
 *             P = self.call(P)             # <<<<<<<<<<<<<<
 * 
 *             # Normalize (xnew,ynew,znew)
 */
    __pyx_t_10 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self->__pyx_vtab)->call(__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1130, __pyx_L1_error)
    __pyx_v_P = __pyx_t_10;

    /* "slabbe/mult_cont_frac.pyx":1133
 * 
 *             # Normalize (xnew,ynew,znew)
 *             if norm== '1':             # <<<<<<<<<<<<<<
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm== 'sup':
 */
    __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_norm, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1133, __pyx_L1_error)
    __pyx_t_11 = (__pyx_t_7 != 0);
    if (__pyx_t_11) {

      /* "slabbe/mult_cont_frac.pyx":1134
 *             # Normalize (xnew,ynew,znew)
 *             if norm== '1':
 *                 s = P.x + P.y + P.z # norm 1             # <<<<<<<<<<<<<<
 *             elif norm== 'sup':
 *                 s = max(P.x, P.y, P.z) # norm sup
 */
      __pyx_v_s = ((__pyx_v_P.x + __pyx_v_P.y) + __pyx_v_P.z);

      /* "slabbe/mult_cont_frac.pyx":1133
 * 
 *             # Normalize (xnew,ynew,znew)
 *             if norm== '1':             # <<<<<<<<<<<<<<
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm== 'sup':
 */
      goto __pyx_L11;
    }

    /* "slabbe/mult_cont_frac.pyx":1135
 *             if norm== '1':
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm== 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 */
    __pyx_t_11 = (__Pyx_PyString_Equals(__pyx_v_norm, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1135, __pyx_L1_error)
    __pyx_t_7 = (__pyx_t_11 != 0);
    if (__pyx_t_7) {

      /* "slabbe/mult_cont_frac.pyx":1136
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm== 'sup':
 *                 s = max(P.x, P.y, P.z) # norm sup             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Unknown value for norm(=%s)" %norm)
 */
      __pyx_t_6 = __pyx_v_P.y;
      __pyx_t_9 = __pyx_v_P.z;
      __pyx_t_8 = __pyx_v_P.x;
      if (((__pyx_t_6 > __pyx_t_8) != 0)) {
        __pyx_t_12 = __pyx_t_6;
      } else {
        __pyx_t_12 = __pyx_t_8;
      }
      __pyx_t_8 = __pyx_t_12;
      if (((__pyx_t_9 > __pyx_t_8) != 0)) {
        __pyx_t_12 = __pyx_t_9;
      } else {
        __pyx_t_12 = __pyx_t_8;
      }
      __pyx_v_s = __pyx_t_12;

      /* "slabbe/mult_cont_frac.pyx":1135
 *             if norm== '1':
 *                 s = P.x + P.y + P.z # norm 1
 *             elif norm== 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 */
      goto __pyx_L11;
    }

    /* "slabbe/mult_cont_frac.pyx":1138
 *                 s = max(P.x, P.y, P.z) # norm sup
 *             else:
 *                 raise ValueError("Unknown value for norm(=%s)" %norm)             # <<<<<<<<<<<<<<
 *             P.x /= s; P.y /= s; P.z /= s
 * 
 */
    /*else*/ {
      __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_value_for_norm_s, __pyx_v_norm); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 1138, __pyx_L1_error)
    }
    __pyx_L11:;

    /* "slabbe/mult_cont_frac.pyx":1139
 *             else:
 *                 raise ValueError("Unknown value for norm(=%s)" %norm)
 *             P.x /= s; P.y /= s; P.z /= s             # <<<<<<<<<<<<<<
 * 
 *             # Increase by one the counter for that part
 */
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 1139, __pyx_L1_error)
    }
    __pyx_v_P.x = (__pyx_v_P.x / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 1139, __pyx_L1_error)
    }
    __pyx_v_P.y = (__pyx_v_P.y / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 1139, __pyx_L1_error)
    }
    __pyx_v_P.z = (__pyx_v_P.z / __pyx_v_s);

    /* "slabbe/mult_cont_frac.pyx":1142
 * 
 *             # Increase by one the counter for that part
 *             X = int(P.x*ndivs)             # <<<<<<<<<<<<<<
 *             Y = int(P.y*ndivs)
 *             C[X][Y] += 1
 */
    __pyx_v_X = ((int)(__pyx_v_P.x * __pyx_v_ndivs));

    /* "slabbe/mult_cont_frac.pyx":1143
 *             # Increase by one the counter for that part
 *             X = int(P.x*ndivs)
 *             Y = int(P.y*ndivs)             # <<<<<<<<<<<<<<
 *             C[X][Y] += 1
 * 
 */
    __pyx_v_Y = ((int)(__pyx_v_P.y * __pyx_v_ndivs));

    /* "slabbe/mult_cont_frac.pyx":1144
 *             X = int(P.x*ndivs)
 *             Y = int(P.y*ndivs)
 *             C[X][Y] += 1             # <<<<<<<<<<<<<<
 * 
 *             if verbose:
 */
    __pyx_t_4 = __pyx_v_X;
    __pyx_t_13 = __pyx_v_Y;
    ((__pyx_v_C[__pyx_t_4])[__pyx_t_13]) = (((__pyx_v_C[__pyx_t_4])[__pyx_t_13]) + 1);

    /* "slabbe/mult_cont_frac.pyx":1146
 *             C[X][Y] += 1
 * 
 *             if verbose:             # <<<<<<<<<<<<<<
 *                 print P.x,P.y,P.z
 *                 print X,Y
 */
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1146, __pyx_L1_error)
    if (__pyx_t_7) {

      /* "slabbe/mult_cont_frac.pyx":1147
 * 
 *             if verbose:
 *                 print P.x,P.y,P.z             # <<<<<<<<<<<<<<
 *                 print X,Y
 * 
 */
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_P.z); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_14 = PyTuple_New(3); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_5);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_5 = 0;
      if (__Pyx_Print(0, __pyx_t_14, 1) < 0) __PYX_ERR(0, 1147, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "slabbe/mult_cont_frac.pyx":1148
 *             if verbose:
 *                 print P.x,P.y,P.z
 *                 print X,Y             # <<<<<<<<<<<<<<
 * 
 *         # Translate the counter into a python dict
 */
      __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_X); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1148, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_Y); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1148, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1148, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
      __pyx_t_14 = 0;
      __pyx_t_5 = 0;
      if (__Pyx_Print(0, __pyx_t_2, 1) < 0) __PYX_ERR(0, 1148, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "slabbe/mult_cont_frac.pyx":1146
 *             C[X][Y] += 1
 * 
 *             if verbose:             # <<<<<<<<<<<<<<
 *                 print P.x,P.y,P.z
 *                 print X,Y
 */
    }
  }

  /* "slabbe/mult_cont_frac.pyx":1151
 * 
 *         # Translate the counter into a python dict
 *         D = {}             # <<<<<<<<<<<<<<
 *         for j from 0 <= j <= ndivs:
 *             for i from 0 <= i <= ndivs:
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_D = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1152
 *         # Translate the counter into a python dict
 *         D = {}
 *         for j from 0 <= j <= ndivs:             # <<<<<<<<<<<<<<
 *             for i from 0 <= i <= ndivs:
 *                 c = C[i][j]
 */
  __pyx_t_3 = __pyx_v_ndivs;
  for (__pyx_v_j = 0; __pyx_v_j <= __pyx_t_3; __pyx_v_j++) {

    /* "slabbe/mult_cont_frac.pyx":1153
 *         D = {}
 *         for j from 0 <= j <= ndivs:
 *             for i from 0 <= i <= ndivs:             # <<<<<<<<<<<<<<
 *                 c = C[i][j]
 *                 if c > 0:
 */
    __pyx_t_4 = __pyx_v_ndivs;
    for (__pyx_v_i = 0; __pyx_v_i <= __pyx_t_4; __pyx_v_i++) {

      /* "slabbe/mult_cont_frac.pyx":1154
 *         for j from 0 <= j <= ndivs:
 *             for i from 0 <= i <= ndivs:
 *                 c = C[i][j]             # <<<<<<<<<<<<<<
 *                 if c > 0:
 *                     D[(i,j)] = c
 */
      __pyx_v_c = ((__pyx_v_C[__pyx_v_i])[__pyx_v_j]);

      /* "slabbe/mult_cont_frac.pyx":1155
 *             for i from 0 <= i <= ndivs:
 *                 c = C[i][j]
 *                 if c > 0:             # <<<<<<<<<<<<<<
 *                     D[(i,j)] = c
 *         return D
 */
      __pyx_t_7 = ((__pyx_v_c > 0) != 0);
      if (__pyx_t_7) {

        /* "slabbe/mult_cont_frac.pyx":1156
 *                 c = C[i][j]
 *                 if c > 0:
 *                     D[(i,j)] = c             # <<<<<<<<<<<<<<
 *         return D
 * 
 */
        __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_c); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1156, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1156, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1156, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1156, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_14);
        __pyx_t_5 = 0;
        __pyx_t_14 = 0;
        if (unlikely(PyDict_SetItem(__pyx_v_D, __pyx_t_1, __pyx_t_2) < 0)) __PYX_ERR(0, 1156, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "slabbe/mult_cont_frac.pyx":1155
 *             for i from 0 <= i <= ndivs:
 *                 c = C[i][j]
 *                 if c > 0:             # <<<<<<<<<<<<<<
 *                     D[(i,j)] = c
 *         return D
 */
      }
    }
  }

  /* "slabbe/mult_cont_frac.pyx":1157
 *                 if c > 0:
 *                     D[(i,j)] = c
 *         return D             # <<<<<<<<<<<<<<
 * 
 *     def _natural_extention_dict(self, int n_iterations, norm_xyz='sup',
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_D);
  __pyx_r = __pyx_v_D;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":1035
 *         return (P.x, P.y, P.z)
 * 
 *     def _invariant_measure_dict(self, int n_iterations, int ndivs, v=None,             # <<<<<<<<<<<<<<
 *             str norm='1', verbose=False):
 *         r"""
 */

  /* 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_14);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._invariant_measure_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_D);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1159
 *         return D
 * 
 *     def _natural_extention_dict(self, int n_iterations, norm_xyz='sup',             # <<<<<<<<<<<<<<
 *             norm_uvw='1', verbose=False):
 *         r"""
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_46_natural_extention_dict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_45_natural_extention_dict[] = "\n        INPUT:\n\n        - ``n_iterations`` -- integer\n        - ``norm_xyz`` -- string (default: ``'sup'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit of points `(x,y,z)` of the algo\n        - ``norm_uvw`` -- string (default: ``'sup'``), either ``'sup'`` or\n          ``'1'`` or ``'hypersurfac'``, the norm used for the orbit of dual\n          coordinates `(u,v,w)`.\n        - ``verbose`` -- bool (default: ``False``)\n\n        OUTPUT:\n\n            dict, dict, dict, dict\n\n        .. NOTE::\n\n            This method should be erased and replaced by simplex_orbit_list\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import ARP\n            sage: t = ARP()._natural_extention_dict(10000)\n            sage: map(type, t)\n            [<type 'collections.defaultdict'>,\n             <type 'collections.defaultdict'>,\n             <type 'collections.defaultdict'>,\n             <type 'collections.defaultdict'>]\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_46_natural_extention_dict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_n_iterations;
  PyObject *__pyx_v_norm_xyz = 0;
  PyObject *__pyx_v_norm_uvw = 0;
  PyObject *__pyx_v_verbose = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_natural_extention_dict (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,&__pyx_n_s_norm_xyz,&__pyx_n_s_norm_uvw,&__pyx_n_s_verbose,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)__pyx_n_s_sup);
    values[2] = ((PyObject *)__pyx_kp_s_1);

    /* "slabbe/mult_cont_frac.pyx":1160
 * 
 *     def _natural_extention_dict(self, int n_iterations, norm_xyz='sup',
 *             norm_uvw='1', verbose=False):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_xyz);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_uvw);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_verbose);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_natural_extention_dict") < 0)) __PYX_ERR(0, 1159, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_n_iterations = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_n_iterations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1159, __pyx_L3_error)
    __pyx_v_norm_xyz = values[1];
    __pyx_v_norm_uvw = values[2];
    __pyx_v_verbose = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_natural_extention_dict", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1159, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._natural_extention_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_45_natural_extention_dict(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations, __pyx_v_norm_xyz, __pyx_v_norm_uvw, __pyx_v_verbose);

  /* "slabbe/mult_cont_frac.pyx":1159
 *         return D
 * 
 *     def _natural_extention_dict(self, int n_iterations, norm_xyz='sup',             # <<<<<<<<<<<<<<
 *             norm_uvw='1', verbose=False):
 *         r"""
 */

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_45_natural_extention_dict(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, int __pyx_v_n_iterations, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_verbose) {
  double __pyx_v_x;
  double __pyx_v_y;
  double __pyx_v_z;
  double __pyx_v_u;
  double __pyx_v_v;
  double __pyx_v_w;
  double __pyx_v_s;
  double __pyx_v_t;
  CYTHON_UNUSED unsigned int __pyx_v_i;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  PyObject *__pyx_v_collections = NULL;
  PyObject *__pyx_v_domain_right = NULL;
  PyObject *__pyx_v_image_right = NULL;
  PyObject *__pyx_v_domain_left = NULL;
  PyObject *__pyx_v_image_left = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  double __pyx_t_4;
  int __pyx_t_5;
  double __pyx_t_6;
  double __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_11;
  double __pyx_t_12;
  int __pyx_t_13;
  __Pyx_RefNannySetupContext("_natural_extention_dict", 0);

  /* "slabbe/mult_cont_frac.pyx":1199
 * 
 *         # random initial values
 *         x = random(); y = random(); z = random();             # <<<<<<<<<<<<<<
 *         u = 1./3; v = 1./3; w = 1./3;
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1199, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1199, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1199, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_x = __pyx_t_4;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1199, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1199, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1199, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_y = __pyx_t_4;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1199, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1199, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1199, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_z = __pyx_t_4;

  /* "slabbe/mult_cont_frac.pyx":1200
 *         # random initial values
 *         x = random(); y = random(); z = random();
 *         u = 1./3; v = 1./3; w = 1./3;             # <<<<<<<<<<<<<<
 * 
 *         # Order (x,y,z)
 */
  __pyx_v_u = (1. / 3.0);
  __pyx_v_v = (1. / 3.0);
  __pyx_v_w = (1. / 3.0);

  /* "slabbe/mult_cont_frac.pyx":1203
 * 
 *         # Order (x,y,z)
 *         if y > z: z,y = y,z             # <<<<<<<<<<<<<<
 *         if x > z: x,y,z = y,z,x
 *         elif x > y: x,y = y,x
 */
  __pyx_t_5 = ((__pyx_v_y > __pyx_v_z) != 0);
  if (__pyx_t_5) {
    __pyx_t_4 = __pyx_v_y;
    __pyx_t_6 = __pyx_v_z;
    __pyx_v_z = __pyx_t_4;
    __pyx_v_y = __pyx_t_6;
  }

  /* "slabbe/mult_cont_frac.pyx":1204
 *         # Order (x,y,z)
 *         if y > z: z,y = y,z
 *         if x > z: x,y,z = y,z,x             # <<<<<<<<<<<<<<
 *         elif x > y: x,y = y,x
 * 
 */
  __pyx_t_5 = ((__pyx_v_x > __pyx_v_z) != 0);
  if (__pyx_t_5) {
    __pyx_t_6 = __pyx_v_y;
    __pyx_t_4 = __pyx_v_z;
    __pyx_t_7 = __pyx_v_x;
    __pyx_v_x = __pyx_t_6;
    __pyx_v_y = __pyx_t_4;
    __pyx_v_z = __pyx_t_7;
    goto __pyx_L4;
  }

  /* "slabbe/mult_cont_frac.pyx":1205
 *         if y > z: z,y = y,z
 *         if x > z: x,y,z = y,z,x
 *         elif x > y: x,y = y,x             # <<<<<<<<<<<<<<
 * 
 *         # Normalize (x,y,z)
 */
  __pyx_t_5 = ((__pyx_v_x > __pyx_v_y) != 0);
  if (__pyx_t_5) {
    __pyx_t_7 = __pyx_v_y;
    __pyx_t_4 = __pyx_v_x;
    __pyx_v_x = __pyx_t_7;
    __pyx_v_y = __pyx_t_4;
  }
  __pyx_L4:;

  /* "slabbe/mult_cont_frac.pyx":1208
 * 
 *         # Normalize (x,y,z)
 *         s = x + y + z             # <<<<<<<<<<<<<<
 *         x /= s; y /= s; z /= s
 * 
 */
  __pyx_v_s = ((__pyx_v_x + __pyx_v_y) + __pyx_v_z);

  /* "slabbe/mult_cont_frac.pyx":1209
 *         # Normalize (x,y,z)
 *         s = x + y + z
 *         x /= s; y /= s; z /= s             # <<<<<<<<<<<<<<
 * 
 *         cdef PairPoint3d P,R
 */
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1209, __pyx_L1_error)
  }
  __pyx_v_x = (__pyx_v_x / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1209, __pyx_L1_error)
  }
  __pyx_v_y = (__pyx_v_y / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1209, __pyx_L1_error)
  }
  __pyx_v_z = (__pyx_v_z / __pyx_v_s);

  /* "slabbe/mult_cont_frac.pyx":1212
 * 
 *         cdef PairPoint3d P,R
 *         P.x = x             # <<<<<<<<<<<<<<
 *         P.y = y
 *         P.z = z
 */
  __pyx_v_P.x = __pyx_v_x;

  /* "slabbe/mult_cont_frac.pyx":1213
 *         cdef PairPoint3d P,R
 *         P.x = x
 *         P.y = y             # <<<<<<<<<<<<<<
 *         P.z = z
 *         P.u = u
 */
  __pyx_v_P.y = __pyx_v_y;

  /* "slabbe/mult_cont_frac.pyx":1214
 *         P.x = x
 *         P.y = y
 *         P.z = z             # <<<<<<<<<<<<<<
 *         P.u = u
 *         P.v = v
 */
  __pyx_v_P.z = __pyx_v_z;

  /* "slabbe/mult_cont_frac.pyx":1215
 *         P.y = y
 *         P.z = z
 *         P.u = u             # <<<<<<<<<<<<<<
 *         P.v = v
 *         P.w = w
 */
  __pyx_v_P.u = __pyx_v_u;

  /* "slabbe/mult_cont_frac.pyx":1216
 *         P.z = z
 *         P.u = u
 *         P.v = v             # <<<<<<<<<<<<<<
 *         P.w = w
 * 
 */
  __pyx_v_P.v = __pyx_v_v;

  /* "slabbe/mult_cont_frac.pyx":1217
 *         P.u = u
 *         P.v = v
 *         P.w = w             # <<<<<<<<<<<<<<
 * 
 *         import collections
 */
  __pyx_v_P.w = __pyx_v_w;

  /* "slabbe/mult_cont_frac.pyx":1219
 *         P.w = w
 * 
 *         import collections             # <<<<<<<<<<<<<<
 *         domain_right = collections.defaultdict(list)
 *         image_right = collections.defaultdict(list)
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_collections, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_collections = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1220
 * 
 *         import collections
 *         domain_right = collections.defaultdict(list)             # <<<<<<<<<<<<<<
 *         image_right = collections.defaultdict(list)
 *         domain_left = collections.defaultdict(list)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_collections, __pyx_n_s_defaultdict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)(&PyList_Type))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1220, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1220, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(((PyObject *)(&PyList_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyList_Type)));
    PyTuple_SET_ITEM(__pyx_t_8, 0+1, ((PyObject *)(&PyList_Type)));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1220, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_domain_right = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1221
 *         import collections
 *         domain_right = collections.defaultdict(list)
 *         image_right = collections.defaultdict(list)             # <<<<<<<<<<<<<<
 *         domain_left = collections.defaultdict(list)
 *         image_left = collections.defaultdict(list)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_collections, __pyx_n_s_defaultdict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)(&PyList_Type))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); __pyx_t_8 = NULL;
    __Pyx_INCREF(((PyObject *)(&PyList_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyList_Type)));
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, ((PyObject *)(&PyList_Type)));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_image_right = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1222
 *         domain_right = collections.defaultdict(list)
 *         image_right = collections.defaultdict(list)
 *         domain_left = collections.defaultdict(list)             # <<<<<<<<<<<<<<
 *         image_left = collections.defaultdict(list)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_collections, __pyx_n_s_defaultdict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)(&PyList_Type))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(((PyObject *)(&PyList_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyList_Type)));
    PyTuple_SET_ITEM(__pyx_t_8, 0+1, ((PyObject *)(&PyList_Type)));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_domain_left = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1223
 *         image_right = collections.defaultdict(list)
 *         domain_left = collections.defaultdict(list)
 *         image_left = collections.defaultdict(list)             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_collections, __pyx_n_s_defaultdict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)(&PyList_Type))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); __pyx_t_8 = NULL;
    __Pyx_INCREF(((PyObject *)(&PyList_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyList_Type)));
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, ((PyObject *)(&PyList_Type)));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_image_left = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1226
 * 
 *         # Loop
 *         for i from 0 <= i < n_iterations:             # <<<<<<<<<<<<<<
 * 
 *             # Check for Keyboard interupt
 */
  __pyx_t_9 = __pyx_v_n_iterations;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

    /* "slabbe/mult_cont_frac.pyx":1229
 * 
 *             # Check for Keyboard interupt
 *             sig_check()             # <<<<<<<<<<<<<<
 * 
 *             # Apply Algo
 */
    __pyx_t_10 = sig_check(); if (unlikely(__pyx_t_10 == 0)) __PYX_ERR(0, 1229, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1232
 * 
 *             # Apply Algo
 *             R = self.call(P)             # <<<<<<<<<<<<<<
 * 
 *             if verbose:
 */
    __pyx_t_11 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self->__pyx_vtab)->call(__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1232, __pyx_L1_error)
    __pyx_v_R = __pyx_t_11;

    /* "slabbe/mult_cont_frac.pyx":1234
 *             R = self.call(P)
 * 
 *             if verbose:             # <<<<<<<<<<<<<<
 *                 print("x=%f, y=%f, z=%f" % (R.x,R.y,R.z))
 *                 #print("u=%f, v=%f, w=%f" % (u,v,w))
 */
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1234, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "slabbe/mult_cont_frac.pyx":1235
 * 
 *             if verbose:
 *                 print("x=%f, y=%f, z=%f" % (R.x,R.y,R.z))             # <<<<<<<<<<<<<<
 *                 #print("u=%f, v=%f, w=%f" % (u,v,w))
 *                 #s = x*u + y*v + z*w
 */
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_R.x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1235, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_R.y); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1235, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_R.z); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1235, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1235, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_3);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_x_f_y_f_z_f, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1235, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_3) < 0) __PYX_ERR(0, 1235, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "slabbe/mult_cont_frac.pyx":1234
 *             R = self.call(P)
 * 
 *             if verbose:             # <<<<<<<<<<<<<<
 *                 print("x=%f, y=%f, z=%f" % (R.x,R.y,R.z))
 *                 #print("u=%f, v=%f, w=%f" % (u,v,w))
 */
    }

    /* "slabbe/mult_cont_frac.pyx":1241
 * 
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 s = R.x + R.y + R.z # norm 1
 *             elif norm_xyz == 'sup':
 */
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_norm_xyz, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1241, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "slabbe/mult_cont_frac.pyx":1242
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':
 *                 s = R.x + R.y + R.z # norm 1             # <<<<<<<<<<<<<<
 *             elif norm_xyz == 'sup':
 *                 s = max(R.x, R.y, R.z) # norm sup
 */
      __pyx_v_s = ((__pyx_v_R.x + __pyx_v_R.y) + __pyx_v_R.z);

      /* "slabbe/mult_cont_frac.pyx":1241
 * 
 *             # Normalize (xnew,ynew,znew)
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 s = R.x + R.y + R.z # norm 1
 *             elif norm_xyz == 'sup':
 */
      goto __pyx_L8;
    }

    /* "slabbe/mult_cont_frac.pyx":1243
 *             if norm_xyz == '1':
 *                 s = R.x + R.y + R.z # norm 1
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(R.x, R.y, R.z) # norm sup
 *             else:
 */
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_norm_xyz, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1243, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "slabbe/mult_cont_frac.pyx":1244
 *                 s = R.x + R.y + R.z # norm 1
 *             elif norm_xyz == 'sup':
 *                 s = max(R.x, R.y, R.z) # norm sup             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)
 */
      __pyx_t_4 = __pyx_v_R.y;
      __pyx_t_7 = __pyx_v_R.z;
      __pyx_t_6 = __pyx_v_R.x;
      if (((__pyx_t_4 > __pyx_t_6) != 0)) {
        __pyx_t_12 = __pyx_t_4;
      } else {
        __pyx_t_12 = __pyx_t_6;
      }
      __pyx_t_6 = __pyx_t_12;
      if (((__pyx_t_7 > __pyx_t_6) != 0)) {
        __pyx_t_12 = __pyx_t_7;
      } else {
        __pyx_t_12 = __pyx_t_6;
      }
      __pyx_v_s = __pyx_t_12;

      /* "slabbe/mult_cont_frac.pyx":1243
 *             if norm_xyz == '1':
 *                 s = R.x + R.y + R.z # norm 1
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(R.x, R.y, R.z) # norm sup
 *             else:
 */
      goto __pyx_L8;
    }

    /* "slabbe/mult_cont_frac.pyx":1246
 *                 s = max(R.x, R.y, R.z) # norm sup
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)             # <<<<<<<<<<<<<<
 *             R.x /= s; R.y /= s; R.z /= s
 * 
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_value_for_norm_xyz_s, __pyx_v_norm_xyz); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 1246, __pyx_L1_error)
    }
    __pyx_L8:;

    /* "slabbe/mult_cont_frac.pyx":1247
 *             else:
 *                 raise ValueError("Unknown value for norm_xyz(=%s)" %norm_xyz)
 *             R.x /= s; R.y /= s; R.z /= s             # <<<<<<<<<<<<<<
 * 
 *             # Normalize (unew,vnew,wnew)
 */
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 1247, __pyx_L1_error)
    }
    __pyx_v_R.x = (__pyx_v_R.x / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 1247, __pyx_L1_error)
    }
    __pyx_v_R.y = (__pyx_v_R.y / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 1247, __pyx_L1_error)
    }
    __pyx_v_R.z = (__pyx_v_R.z / __pyx_v_s);

    /* "slabbe/mult_cont_frac.pyx":1250
 * 
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 s = R.u + R.v + R.w    # norm 1
 *             elif norm_uvw == 'sup':
 */
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1250, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "slabbe/mult_cont_frac.pyx":1251
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':
 *                 s = R.u + R.v + R.w    # norm 1             # <<<<<<<<<<<<<<
 *             elif norm_uvw == 'sup':
 *                 s = max(R.u, R.v, R.w) # norm sup
 */
      __pyx_v_s = ((__pyx_v_R.u + __pyx_v_R.v) + __pyx_v_R.w);

      /* "slabbe/mult_cont_frac.pyx":1250
 * 
 *             # Normalize (unew,vnew,wnew)
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 s = R.u + R.v + R.w    # norm 1
 *             elif norm_uvw == 'sup':
 */
      goto __pyx_L9;
    }

    /* "slabbe/mult_cont_frac.pyx":1252
 *             if norm_uvw == '1':
 *                 s = R.u + R.v + R.w    # norm 1
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(R.u, R.v, R.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 */
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1252, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "slabbe/mult_cont_frac.pyx":1253
 *                 s = R.u + R.v + R.w    # norm 1
 *             elif norm_uvw == 'sup':
 *                 s = max(R.u, R.v, R.w) # norm sup             # <<<<<<<<<<<<<<
 *             elif norm_uvw == 'hypersurface':
 *                 s = R.x*R.u + R.y*R.v + R.z*R.w # hypersurface
 */
      __pyx_t_12 = __pyx_v_R.v;
      __pyx_t_4 = __pyx_v_R.w;
      __pyx_t_7 = __pyx_v_R.u;
      if (((__pyx_t_12 > __pyx_t_7) != 0)) {
        __pyx_t_6 = __pyx_t_12;
      } else {
        __pyx_t_6 = __pyx_t_7;
      }
      __pyx_t_7 = __pyx_t_6;
      if (((__pyx_t_4 > __pyx_t_7) != 0)) {
        __pyx_t_6 = __pyx_t_4;
      } else {
        __pyx_t_6 = __pyx_t_7;
      }
      __pyx_v_s = __pyx_t_6;

      /* "slabbe/mult_cont_frac.pyx":1252
 *             if norm_uvw == '1':
 *                 s = R.u + R.v + R.w    # norm 1
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 s = max(R.u, R.v, R.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 */
      goto __pyx_L9;
    }

    /* "slabbe/mult_cont_frac.pyx":1254
 *             elif norm_uvw == 'sup':
 *                 s = max(R.u, R.v, R.w) # norm sup
 *             elif norm_uvw == 'hypersurface':             # <<<<<<<<<<<<<<
 *                 s = R.x*R.u + R.y*R.v + R.z*R.w # hypersurface
 *             else:
 */
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_n_s_hypersurface, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1254, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "slabbe/mult_cont_frac.pyx":1255
 *                 s = max(R.u, R.v, R.w) # norm sup
 *             elif norm_uvw == 'hypersurface':
 *                 s = R.x*R.u + R.y*R.v + R.z*R.w # hypersurface             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)
 */
      __pyx_v_s = (((__pyx_v_R.x * __pyx_v_R.u) + (__pyx_v_R.y * __pyx_v_R.v)) + (__pyx_v_R.z * __pyx_v_R.w));

      /* "slabbe/mult_cont_frac.pyx":1254
 *             elif norm_uvw == 'sup':
 *                 s = max(R.u, R.v, R.w) # norm sup
 *             elif norm_uvw == 'hypersurface':             # <<<<<<<<<<<<<<
 *                 s = R.x*R.u + R.y*R.v + R.z*R.w # hypersurface
 *             else:
 */
      goto __pyx_L9;
    }

    /* "slabbe/mult_cont_frac.pyx":1257
 *                 s = R.x*R.u + R.y*R.v + R.z*R.w # hypersurface
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)             # <<<<<<<<<<<<<<
 *             R.u /= s; R.v /= s; R.w /= s
 * 
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_value_for_norm_uvw_s, __pyx_v_norm_uvw); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1257, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1257, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1257, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 1257, __pyx_L1_error)
    }
    __pyx_L9:;

    /* "slabbe/mult_cont_frac.pyx":1258
 *             else:
 *                 raise ValueError("Unknown value for norm_uvw(=%s)" %norm_uvw)
 *             R.u /= s; R.v /= s; R.w /= s             # <<<<<<<<<<<<<<
 * 
 *             # Projection
 */
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 1258, __pyx_L1_error)
    }
    __pyx_v_R.u = (__pyx_v_R.u / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 1258, __pyx_L1_error)
    }
    __pyx_v_R.v = (__pyx_v_R.v / __pyx_v_s);
    if (unlikely(__pyx_v_s == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 1258, __pyx_L1_error)
    }
    __pyx_v_R.w = (__pyx_v_R.w / __pyx_v_s);

    /* "slabbe/mult_cont_frac.pyx":1261
 * 
 *             # Projection
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 s = -SQRT3SUR2 * P.x + SQRT3SUR2 * P.y
 *                 t = -.5 * P.x -.5 * P.y + P.z
 */
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_norm_xyz, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1261, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "slabbe/mult_cont_frac.pyx":1262
 *             # Projection
 *             if norm_xyz == '1':
 *                 s = -SQRT3SUR2 * P.x + SQRT3SUR2 * P.y             # <<<<<<<<<<<<<<
 *                 t = -.5 * P.x -.5 * P.y + P.z
 *                 domain_left[R.branch].append((s,t))
 */
      __pyx_v_s = (((-__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2) * __pyx_v_P.x) + (__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2 * __pyx_v_P.y));

      /* "slabbe/mult_cont_frac.pyx":1263
 *             if norm_xyz == '1':
 *                 s = -SQRT3SUR2 * P.x + SQRT3SUR2 * P.y
 *                 t = -.5 * P.x -.5 * P.y + P.z             # <<<<<<<<<<<<<<
 *                 domain_left[R.branch].append((s,t))
 *                 s = -SQRT3SUR2 * R.x + SQRT3SUR2 * R.y
 */
      __pyx_v_t = (((-.5 * __pyx_v_P.x) - (.5 * __pyx_v_P.y)) + __pyx_v_P.z);

      /* "slabbe/mult_cont_frac.pyx":1264
 *                 s = -SQRT3SUR2 * P.x + SQRT3SUR2 * P.y
 *                 t = -.5 * P.x -.5 * P.y + P.z
 *                 domain_left[R.branch].append((s,t))             # <<<<<<<<<<<<<<
 *                 s = -SQRT3SUR2 * R.x + SQRT3SUR2 * R.y
 *                 t = -.5 * R.x -.5 * R.y + R.z
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_domain_left, __pyx_v_R.branch, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1264, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyFloat_FromDouble(__pyx_v_s); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1264, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1264, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1264, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __pyx_t_8 = 0;
      __pyx_t_2 = 0;
      __pyx_t_13 = __Pyx_PyObject_Append(__pyx_t_3, __pyx_t_1); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1264, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "slabbe/mult_cont_frac.pyx":1265
 *                 t = -.5 * P.x -.5 * P.y + P.z
 *                 domain_left[R.branch].append((s,t))
 *                 s = -SQRT3SUR2 * R.x + SQRT3SUR2 * R.y             # <<<<<<<<<<<<<<
 *                 t = -.5 * R.x -.5 * R.y + R.z
 *                 image_left[R.branch].append((s,t))
 */
      __pyx_v_s = (((-__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2) * __pyx_v_R.x) + (__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2 * __pyx_v_R.y));

      /* "slabbe/mult_cont_frac.pyx":1266
 *                 domain_left[R.branch].append((s,t))
 *                 s = -SQRT3SUR2 * R.x + SQRT3SUR2 * R.y
 *                 t = -.5 * R.x -.5 * R.y + R.z             # <<<<<<<<<<<<<<
 *                 image_left[R.branch].append((s,t))
 *             elif norm_xyz == 'sup':
 */
      __pyx_v_t = (((-.5 * __pyx_v_R.x) - (.5 * __pyx_v_R.y)) + __pyx_v_R.z);

      /* "slabbe/mult_cont_frac.pyx":1267
 *                 s = -SQRT3SUR2 * R.x + SQRT3SUR2 * R.y
 *                 t = -.5 * R.x -.5 * R.y + R.z
 *                 image_left[R.branch].append((s,t))             # <<<<<<<<<<<<<<
 *             elif norm_xyz == 'sup':
 *                 domain_left[R.branch].append((P.x,P.y))
 */
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_image_left, __pyx_v_R.branch, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_s); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
      __pyx_t_3 = 0;
      __pyx_t_2 = 0;
      __pyx_t_13 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_t_8); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1267, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "slabbe/mult_cont_frac.pyx":1261
 * 
 *             # Projection
 *             if norm_xyz == '1':             # <<<<<<<<<<<<<<
 *                 s = -SQRT3SUR2 * P.x + SQRT3SUR2 * P.y
 *                 t = -.5 * P.x -.5 * P.y + P.z
 */
      goto __pyx_L10;
    }

    /* "slabbe/mult_cont_frac.pyx":1268
 *                 t = -.5 * R.x -.5 * R.y + R.z
 *                 image_left[R.branch].append((s,t))
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 domain_left[R.branch].append((P.x,P.y))
 *                 image_left[R.branch].append((R.x,R.y))
 */
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_norm_xyz, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1268, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "slabbe/mult_cont_frac.pyx":1269
 *                 image_left[R.branch].append((s,t))
 *             elif norm_xyz == 'sup':
 *                 domain_left[R.branch].append((P.x,P.y))             # <<<<<<<<<<<<<<
 *                 image_left[R.branch].append((R.x,R.y))
 * 
 */
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_domain_left, __pyx_v_R.branch, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1269, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1269, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1269, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1269, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_13 = __Pyx_PyObject_Append(__pyx_t_8, __pyx_t_3); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1269, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "slabbe/mult_cont_frac.pyx":1270
 *             elif norm_xyz == 'sup':
 *                 domain_left[R.branch].append((P.x,P.y))
 *                 image_left[R.branch].append((R.x,R.y))             # <<<<<<<<<<<<<<
 * 
 *             if norm_uvw == '1':
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_image_left, __pyx_v_R.branch, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1270, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyFloat_FromDouble(__pyx_v_R.x); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1270, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_R.y); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1270, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1270, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __pyx_t_8 = 0;
      __pyx_t_2 = 0;
      __pyx_t_13 = __Pyx_PyObject_Append(__pyx_t_3, __pyx_t_1); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1270, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "slabbe/mult_cont_frac.pyx":1268
 *                 t = -.5 * R.x -.5 * R.y + R.z
 *                 image_left[R.branch].append((s,t))
 *             elif norm_xyz == 'sup':             # <<<<<<<<<<<<<<
 *                 domain_left[R.branch].append((P.x,P.y))
 *                 image_left[R.branch].append((R.x,R.y))
 */
    }
    __pyx_L10:;

    /* "slabbe/mult_cont_frac.pyx":1272
 *                 image_left[R.branch].append((R.x,R.y))
 * 
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 s = -SQRT3SUR2 * P.u + SQRT3SUR2 * P.v
 *                 t = -.5 * P.u -.5 * P.v + P.w
 */
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1272, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "slabbe/mult_cont_frac.pyx":1273
 * 
 *             if norm_uvw == '1':
 *                 s = -SQRT3SUR2 * P.u + SQRT3SUR2 * P.v             # <<<<<<<<<<<<<<
 *                 t = -.5 * P.u -.5 * P.v + P.w
 *                 domain_right[R.branch].append((s,t))
 */
      __pyx_v_s = (((-__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2) * __pyx_v_P.u) + (__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2 * __pyx_v_P.v));

      /* "slabbe/mult_cont_frac.pyx":1274
 *             if norm_uvw == '1':
 *                 s = -SQRT3SUR2 * P.u + SQRT3SUR2 * P.v
 *                 t = -.5 * P.u -.5 * P.v + P.w             # <<<<<<<<<<<<<<
 *                 domain_right[R.branch].append((s,t))
 *                 s = -SQRT3SUR2 * R.u + SQRT3SUR2 * R.v
 */
      __pyx_v_t = (((-.5 * __pyx_v_P.u) - (.5 * __pyx_v_P.v)) + __pyx_v_P.w);

      /* "slabbe/mult_cont_frac.pyx":1275
 *                 s = -SQRT3SUR2 * P.u + SQRT3SUR2 * P.v
 *                 t = -.5 * P.u -.5 * P.v + P.w
 *                 domain_right[R.branch].append((s,t))             # <<<<<<<<<<<<<<
 *                 s = -SQRT3SUR2 * R.u + SQRT3SUR2 * R.v
 *                 t = -.5 * R.u -.5 * R.v + R.w
 */
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_domain_right, __pyx_v_R.branch, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1275, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_s); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1275, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1275, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1275, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
      __pyx_t_3 = 0;
      __pyx_t_2 = 0;
      __pyx_t_13 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_t_8); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1275, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "slabbe/mult_cont_frac.pyx":1276
 *                 t = -.5 * P.u -.5 * P.v + P.w
 *                 domain_right[R.branch].append((s,t))
 *                 s = -SQRT3SUR2 * R.u + SQRT3SUR2 * R.v             # <<<<<<<<<<<<<<
 *                 t = -.5 * R.u -.5 * R.v + R.w
 *                 image_right[R.branch].append((s,t))
 */
      __pyx_v_s = (((-__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2) * __pyx_v_R.u) + (__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2 * __pyx_v_R.v));

      /* "slabbe/mult_cont_frac.pyx":1277
 *                 domain_right[R.branch].append((s,t))
 *                 s = -SQRT3SUR2 * R.u + SQRT3SUR2 * R.v
 *                 t = -.5 * R.u -.5 * R.v + R.w             # <<<<<<<<<<<<<<
 *                 image_right[R.branch].append((s,t))
 *             elif norm_uvw == 'sup':
 */
      __pyx_v_t = (((-.5 * __pyx_v_R.u) - (.5 * __pyx_v_R.v)) + __pyx_v_R.w);

      /* "slabbe/mult_cont_frac.pyx":1278
 *                 s = -SQRT3SUR2 * R.u + SQRT3SUR2 * R.v
 *                 t = -.5 * R.u -.5 * R.v + R.w
 *                 image_right[R.branch].append((s,t))             # <<<<<<<<<<<<<<
 *             elif norm_uvw == 'sup':
 *                 domain_right[R.branch].append((P.u,P.v))
 */
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_image_right, __pyx_v_R.branch, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_s); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_13 = __Pyx_PyObject_Append(__pyx_t_8, __pyx_t_3); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1278, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "slabbe/mult_cont_frac.pyx":1272
 *                 image_left[R.branch].append((R.x,R.y))
 * 
 *             if norm_uvw == '1':             # <<<<<<<<<<<<<<
 *                 s = -SQRT3SUR2 * P.u + SQRT3SUR2 * P.v
 *                 t = -.5 * P.u -.5 * P.v + P.w
 */
      goto __pyx_L11;
    }

    /* "slabbe/mult_cont_frac.pyx":1279
 *                 t = -.5 * R.u -.5 * R.v + R.w
 *                 image_right[R.branch].append((s,t))
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 domain_right[R.branch].append((P.u,P.v))
 *                 image_right[R.branch].append((R.u,R.v))
 */
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_norm_uvw, __pyx_n_s_sup, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1279, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "slabbe/mult_cont_frac.pyx":1280
 *                 image_right[R.branch].append((s,t))
 *             elif norm_uvw == 'sup':
 *                 domain_right[R.branch].append((P.u,P.v))             # <<<<<<<<<<<<<<
 *                 image_right[R.branch].append((R.u,R.v))
 * 
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_domain_right, __pyx_v_R.branch, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1280, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyFloat_FromDouble(__pyx_v_P.u); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1280, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_P.v); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1280, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1280, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __pyx_t_8 = 0;
      __pyx_t_2 = 0;
      __pyx_t_13 = __Pyx_PyObject_Append(__pyx_t_3, __pyx_t_1); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1280, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "slabbe/mult_cont_frac.pyx":1281
 *             elif norm_uvw == 'sup':
 *                 domain_right[R.branch].append((P.u,P.v))
 *                 image_right[R.branch].append((R.u,R.v))             # <<<<<<<<<<<<<<
 * 
 *             P = R
 */
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_image_right, __pyx_v_R.branch, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1281, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_R.u); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1281, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_R.v); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1281, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1281, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
      __pyx_t_3 = 0;
      __pyx_t_2 = 0;
      __pyx_t_13 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_t_8); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1281, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "slabbe/mult_cont_frac.pyx":1279
 *                 t = -.5 * R.u -.5 * R.v + R.w
 *                 image_right[R.branch].append((s,t))
 *             elif norm_uvw == 'sup':             # <<<<<<<<<<<<<<
 *                 domain_right[R.branch].append((P.u,P.v))
 *                 image_right[R.branch].append((R.u,R.v))
 */
    }
    __pyx_L11:;

    /* "slabbe/mult_cont_frac.pyx":1283
 *                 image_right[R.branch].append((R.u,R.v))
 * 
 *             P = R             # <<<<<<<<<<<<<<
 * 
 *         return domain_left, image_left, domain_right, image_right
 */
    __pyx_v_P = __pyx_v_R;
  }

  /* "slabbe/mult_cont_frac.pyx":1285
 *             P = R
 * 
 *         return domain_left, image_left, domain_right, image_right             # <<<<<<<<<<<<<<
 * 
 *     def lyapunov_exponents(self, start=None, int n_iterations=1000, verbose=False):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_domain_left);
  __Pyx_GIVEREF(__pyx_v_domain_left);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_domain_left);
  __Pyx_INCREF(__pyx_v_image_left);
  __Pyx_GIVEREF(__pyx_v_image_left);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_image_left);
  __Pyx_INCREF(__pyx_v_domain_right);
  __Pyx_GIVEREF(__pyx_v_domain_right);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_domain_right);
  __Pyx_INCREF(__pyx_v_image_right);
  __Pyx_GIVEREF(__pyx_v_image_right);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_v_image_right);
  __pyx_r = __pyx_t_8;
  __pyx_t_8 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":1159
 *         return D
 * 
 *     def _natural_extention_dict(self, int n_iterations, norm_xyz='sup',             # <<<<<<<<<<<<<<
 *             norm_uvw='1', verbose=False):
 *         r"""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm._natural_extention_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_collections);
  __Pyx_XDECREF(__pyx_v_domain_right);
  __Pyx_XDECREF(__pyx_v_image_right);
  __Pyx_XDECREF(__pyx_v_domain_left);
  __Pyx_XDECREF(__pyx_v_image_left);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1287
 *         return domain_left, image_left, domain_right, image_right
 * 
 *     def lyapunov_exponents(self, start=None, int n_iterations=1000, verbose=False):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the lyapunov exponents (theta1, theta2, 1-theta2/theta1)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_48lyapunov_exponents(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_47lyapunov_exponents[] = "\n        Return the lyapunov exponents (theta1, theta2, 1-theta2/theta1)\n\n        See also the module ``slabbe.lyapunov`` for parallel computations.\n\n        INPUT:\n\n        - ``start`` - initial vector (default: ``None``), if None, then\n          initial point is random\n        - ``n_iterations`` -- integer\n        - ``verbose`` -- bool (default: ``False``)\n\n        OUTPUT:\n\n            tuple of the first two liapounov exponents and the uniform\n            approximation exponent:\n\n            (theta1, theta2, 1-theta2/theta1)\n\n        .. NOTE:: \n        \n            the code of this method was translated from C to cython. The C\n            version is from Vincent Delecroix.\n\n        EXAMPLES:\n\n        Some benchmarks (on my machine)::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: Brun().lyapunov_exponents(n_iterations=1000000)  # 68.6 ms # tolerance 0.003\n            (0.3049429393152174, -0.1120652699014143, 1.367495867105725)\n\n        Cython code on liafa is as fast as C on my machine::\n\n            sage: Brun().lyapunov_exponents(n_iterations=67000000) # 3.71s # tolerance 0.001\n            (0.30452120021265766, -0.11212586210856369, 1.36820379674801734)\n\n        Cython code on my machine is almost as fast as C on my machine::\n\n            sage: Brun().lyapunov_exponents(n_iterations=67000000) # 4.58 s # tolerance 0.001\n            (0.30456433843239084, -0.1121770192467067, 1.36831961293987303)\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_48lyapunov_exponents(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_start = 0;
  int __pyx_v_n_iterations;
  PyObject *__pyx_v_verbose = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lyapunov_exponents (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start,&__pyx_n_s_n_iterations,&__pyx_n_s_verbose,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_verbose);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lyapunov_exponents") < 0)) __PYX_ERR(0, 1287, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_start = values[0];
    if (values[1]) {
      __pyx_v_n_iterations = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_n_iterations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1287, __pyx_L3_error)
    } else {
      __pyx_v_n_iterations = ((int)0x3E8);
    }
    __pyx_v_verbose = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("lyapunov_exponents", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1287, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.lyapunov_exponents", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_47lyapunov_exponents(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_start, __pyx_v_n_iterations, __pyx_v_verbose);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_47lyapunov_exponents(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_start, int __pyx_v_n_iterations, PyObject *__pyx_v_verbose) {
  PyObject *__pyx_v_log = NULL;
  double __pyx_v_theta1;
  double __pyx_v_theta2;
  double __pyx_v_theta1c;
  double __pyx_v_theta2c;
  double __pyx_v_x;
  double __pyx_v_y;
  double __pyx_v_z;
  double __pyx_v_u;
  double __pyx_v_v;
  double __pyx_v_w;
  double __pyx_v_p;
  double __pyx_v_s;
  double __pyx_v_t;
  CYTHON_UNUSED unsigned int __pyx_v_i;
  double __pyx_v_critical_value;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P;
  PyObject *__pyx_r = NULL;
  __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;
  double __pyx_t_6;
  double __pyx_t_7;
  double __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_RefNannySetupContext("lyapunov_exponents", 0);

  /* "slabbe/mult_cont_frac.pyx":1331
 * 
 *         """
 *         from math import log             # <<<<<<<<<<<<<<
 *         cdef double theta1=0, theta2=0    # values of Lyapunov exponents
 *         cdef double theta1c=0, theta2c=0  # compensation (for Kahan summation algorithm)
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_log);
  __Pyx_GIVEREF(__pyx_n_s_log);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_log);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_math, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_log = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1332
 *         """
 *         from math import log
 *         cdef double theta1=0, theta2=0    # values of Lyapunov exponents             # <<<<<<<<<<<<<<
 *         cdef double theta1c=0, theta2c=0  # compensation (for Kahan summation algorithm)
 *         cdef double x,y,z           # vector (x,y,z)
 */
  __pyx_v_theta1 = 0.0;
  __pyx_v_theta2 = 0.0;

  /* "slabbe/mult_cont_frac.pyx":1333
 *         from math import log
 *         cdef double theta1=0, theta2=0    # values of Lyapunov exponents
 *         cdef double theta1c=0, theta2c=0  # compensation (for Kahan summation algorithm)             # <<<<<<<<<<<<<<
 *         cdef double x,y,z           # vector (x,y,z)
 *         cdef double u,v,w           # vector (u,v,w)
 */
  __pyx_v_theta1c = 0.0;
  __pyx_v_theta2c = 0.0;

  /* "slabbe/mult_cont_frac.pyx":1338
 *         cdef double p,s,t           # temporary variables
 *         cdef unsigned int i         # loop counter
 *         cdef double critical_value=0.0001             # <<<<<<<<<<<<<<
 * 
 *         # initial values
 */
  __pyx_v_critical_value = 0.0001;

  /* "slabbe/mult_cont_frac.pyx":1341
 * 
 *         # initial values
 *         if start is None:             # <<<<<<<<<<<<<<
 *             x = random(); y = random(); z = random()
 *         else:
 */
  __pyx_t_3 = (__pyx_v_start == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":1342
 *         # initial values
 *         if start is None:
 *             x = random(); y = random(); z = random()             # <<<<<<<<<<<<<<
 *         else:
 *             x = start[0]; y = start[1]; z = start[2]
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1342, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1342, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1342, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1342, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_x = __pyx_t_6;
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1342, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1342, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1342, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1342, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_y = __pyx_t_6;
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1342, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1342, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1342, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1342, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_z = __pyx_t_6;

    /* "slabbe/mult_cont_frac.pyx":1341
 * 
 *         # initial values
 *         if start is None:             # <<<<<<<<<<<<<<
 *             x = random(); y = random(); z = random()
 *         else:
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":1344
 *             x = random(); y = random(); z = random()
 *         else:
 *             x = start[0]; y = start[1]; z = start[2]             # <<<<<<<<<<<<<<
 *         u = random() - .5; v = random() - .5; w = random() - .5;
 * 
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_start, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1344, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_x = __pyx_t_6;
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_start, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1344, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_y = __pyx_t_6;
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_start, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1344, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_z = __pyx_t_6;
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":1345
 *         else:
 *             x = start[0]; y = start[1]; z = start[2]
 *         u = random() - .5; v = random() - .5; w = random() - .5;             # <<<<<<<<<<<<<<
 * 
 *         # Order (x,y,z)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1345, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1345, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyFloat_SubtractObjC(__pyx_t_2, __pyx_float__5, .5, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_u = __pyx_t_6;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1345, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1345, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyFloat_SubtractObjC(__pyx_t_1, __pyx_float__5, .5, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_v = __pyx_t_6;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1345, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1345, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyFloat_SubtractObjC(__pyx_t_2, __pyx_float__5, .5, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1345, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_w = __pyx_t_6;

  /* "slabbe/mult_cont_frac.pyx":1348
 * 
 *         # Order (x,y,z)
 *         if y > z: z,y = y,z             # <<<<<<<<<<<<<<
 *         if x > z: x,y,z = y,z,x
 *         elif x > y: x,y = y,x
 */
  __pyx_t_4 = ((__pyx_v_y > __pyx_v_z) != 0);
  if (__pyx_t_4) {
    __pyx_t_6 = __pyx_v_y;
    __pyx_t_7 = __pyx_v_z;
    __pyx_v_z = __pyx_t_6;
    __pyx_v_y = __pyx_t_7;
  }

  /* "slabbe/mult_cont_frac.pyx":1349
 *         # Order (x,y,z)
 *         if y > z: z,y = y,z
 *         if x > z: x,y,z = y,z,x             # <<<<<<<<<<<<<<
 *         elif x > y: x,y = y,x
 * 
 */
  __pyx_t_4 = ((__pyx_v_x > __pyx_v_z) != 0);
  if (__pyx_t_4) {
    __pyx_t_7 = __pyx_v_y;
    __pyx_t_6 = __pyx_v_z;
    __pyx_t_8 = __pyx_v_x;
    __pyx_v_x = __pyx_t_7;
    __pyx_v_y = __pyx_t_6;
    __pyx_v_z = __pyx_t_8;
    goto __pyx_L5;
  }

  /* "slabbe/mult_cont_frac.pyx":1350
 *         if y > z: z,y = y,z
 *         if x > z: x,y,z = y,z,x
 *         elif x > y: x,y = y,x             # <<<<<<<<<<<<<<
 * 
 *         # Normalize (x,y,z)
 */
  __pyx_t_4 = ((__pyx_v_x > __pyx_v_y) != 0);
  if (__pyx_t_4) {
    __pyx_t_8 = __pyx_v_y;
    __pyx_t_6 = __pyx_v_x;
    __pyx_v_x = __pyx_t_8;
    __pyx_v_y = __pyx_t_6;
  }
  __pyx_L5:;

  /* "slabbe/mult_cont_frac.pyx":1353
 * 
 *         # Normalize (x,y,z)
 *         s = x + y + z             # <<<<<<<<<<<<<<
 *         x /= s; y /= s; z /= s
 * 
 */
  __pyx_v_s = ((__pyx_v_x + __pyx_v_y) + __pyx_v_z);

  /* "slabbe/mult_cont_frac.pyx":1354
 *         # Normalize (x,y,z)
 *         s = x + y + z
 *         x /= s; y /= s; z /= s             # <<<<<<<<<<<<<<
 * 
 *         # Gram Shmidtt on (u,v,w)
 */
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1354, __pyx_L1_error)
  }
  __pyx_v_x = (__pyx_v_x / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1354, __pyx_L1_error)
  }
  __pyx_v_y = (__pyx_v_y / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1354, __pyx_L1_error)
  }
  __pyx_v_z = (__pyx_v_z / __pyx_v_s);

  /* "slabbe/mult_cont_frac.pyx":1357
 * 
 *         # Gram Shmidtt on (u,v,w)
 *         p = x*u + y*v + z*w             # <<<<<<<<<<<<<<
 *         s = x*x + y*y + z*z
 *         u -= p*x/s; v -= p*y/s; w -= p*z/s
 */
  __pyx_v_p = (((__pyx_v_x * __pyx_v_u) + (__pyx_v_y * __pyx_v_v)) + (__pyx_v_z * __pyx_v_w));

  /* "slabbe/mult_cont_frac.pyx":1358
 *         # Gram Shmidtt on (u,v,w)
 *         p = x*u + y*v + z*w
 *         s = x*x + y*y + z*z             # <<<<<<<<<<<<<<
 *         u -= p*x/s; v -= p*y/s; w -= p*z/s
 * 
 */
  __pyx_v_s = (((__pyx_v_x * __pyx_v_x) + (__pyx_v_y * __pyx_v_y)) + (__pyx_v_z * __pyx_v_z));

  /* "slabbe/mult_cont_frac.pyx":1359
 *         p = x*u + y*v + z*w
 *         s = x*x + y*y + z*z
 *         u -= p*x/s; v -= p*y/s; w -= p*z/s             # <<<<<<<<<<<<<<
 * 
 *         # Normalize (u,v,w)
 */
  __pyx_t_6 = (__pyx_v_p * __pyx_v_x);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1359, __pyx_L1_error)
  }
  __pyx_v_u = (__pyx_v_u - (__pyx_t_6 / __pyx_v_s));
  __pyx_t_6 = (__pyx_v_p * __pyx_v_y);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1359, __pyx_L1_error)
  }
  __pyx_v_v = (__pyx_v_v - (__pyx_t_6 / __pyx_v_s));
  __pyx_t_6 = (__pyx_v_p * __pyx_v_z);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1359, __pyx_L1_error)
  }
  __pyx_v_w = (__pyx_v_w - (__pyx_t_6 / __pyx_v_s));

  /* "slabbe/mult_cont_frac.pyx":1362
 * 
 *         # Normalize (u,v,w)
 *         s = abs(u) + abs(v) + abs(w);             # <<<<<<<<<<<<<<
 *         u /= s; v /= s; w /= s
 * 
 */
  __pyx_v_s = ((fabs(__pyx_v_u) + fabs(__pyx_v_v)) + fabs(__pyx_v_w));

  /* "slabbe/mult_cont_frac.pyx":1363
 *         # Normalize (u,v,w)
 *         s = abs(u) + abs(v) + abs(w);
 *         u /= s; v /= s; w /= s             # <<<<<<<<<<<<<<
 * 
 *         if verbose:
 */
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1363, __pyx_L1_error)
  }
  __pyx_v_u = (__pyx_v_u / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1363, __pyx_L1_error)
  }
  __pyx_v_v = (__pyx_v_v / __pyx_v_s);
  if (unlikely(__pyx_v_s == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1363, __pyx_L1_error)
  }
  __pyx_v_w = (__pyx_v_w / __pyx_v_s);

  /* "slabbe/mult_cont_frac.pyx":1365
 *         u /= s; v /= s; w /= s
 * 
 *         if verbose:             # <<<<<<<<<<<<<<
 *             print("x=%f, y=%f, z=%f" % (x,y,z))
 *             print("u=%f, v=%f, w=%f" % (u,v,w))
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1365, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":1366
 * 
 *         if verbose:
 *             print("x=%f, y=%f, z=%f" % (x,y,z))             # <<<<<<<<<<<<<<
 *             print("u=%f, v=%f, w=%f" % (u,v,w))
 *             s = x*u + y*v + z*w
 */
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_z); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_x_f_y_f_z_f, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_5) < 0) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "slabbe/mult_cont_frac.pyx":1367
 *         if verbose:
 *             print("x=%f, y=%f, z=%f" % (x,y,z))
 *             print("u=%f, v=%f, w=%f" % (u,v,w))             # <<<<<<<<<<<<<<
 *             s = x*u + y*v + z*w
 *             print("scal prod <(x,y,z),(u,v,w)> = %f" % s)
 */
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_u); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1367, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = PyFloat_FromDouble(__pyx_v_v); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1367, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_2 = PyFloat_FromDouble(__pyx_v_w); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1367, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1367, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2);
    __pyx_t_5 = 0;
    __pyx_t_9 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_u_f_v_f_w_f, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1367, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_2) < 0) __PYX_ERR(0, 1367, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":1368
 *             print("x=%f, y=%f, z=%f" % (x,y,z))
 *             print("u=%f, v=%f, w=%f" % (u,v,w))
 *             s = x*u + y*v + z*w             # <<<<<<<<<<<<<<
 *             print("scal prod <(x,y,z),(u,v,w)> = %f" % s)
 * 
 */
    __pyx_v_s = (((__pyx_v_x * __pyx_v_u) + (__pyx_v_y * __pyx_v_v)) + (__pyx_v_z * __pyx_v_w));

    /* "slabbe/mult_cont_frac.pyx":1369
 *             print("u=%f, v=%f, w=%f" % (u,v,w))
 *             s = x*u + y*v + z*w
 *             print("scal prod <(x,y,z),(u,v,w)> = %f" % s)             # <<<<<<<<<<<<<<
 * 
 *         cdef PairPoint3d P
 */
    __pyx_t_2 = PyFloat_FromDouble(__pyx_v_s); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_scal_prod_x_y_z_u_v_w_f, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 1369, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "slabbe/mult_cont_frac.pyx":1365
 *         u /= s; v /= s; w /= s
 * 
 *         if verbose:             # <<<<<<<<<<<<<<
 *             print("x=%f, y=%f, z=%f" % (x,y,z))
 *             print("u=%f, v=%f, w=%f" % (u,v,w))
 */
  }

  /* "slabbe/mult_cont_frac.pyx":1372
 * 
 *         cdef PairPoint3d P
 *         P.x = x             # <<<<<<<<<<<<<<
 *         P.y = y
 *         P.z = z
 */
  __pyx_v_P.x = __pyx_v_x;

  /* "slabbe/mult_cont_frac.pyx":1373
 *         cdef PairPoint3d P
 *         P.x = x
 *         P.y = y             # <<<<<<<<<<<<<<
 *         P.z = z
 *         P.u = u
 */
  __pyx_v_P.y = __pyx_v_y;

  /* "slabbe/mult_cont_frac.pyx":1374
 *         P.x = x
 *         P.y = y
 *         P.z = z             # <<<<<<<<<<<<<<
 *         P.u = u
 *         P.v = v
 */
  __pyx_v_P.z = __pyx_v_z;

  /* "slabbe/mult_cont_frac.pyx":1375
 *         P.y = y
 *         P.z = z
 *         P.u = u             # <<<<<<<<<<<<<<
 *         P.v = v
 *         P.w = w
 */
  __pyx_v_P.u = __pyx_v_u;

  /* "slabbe/mult_cont_frac.pyx":1376
 *         P.z = z
 *         P.u = u
 *         P.v = v             # <<<<<<<<<<<<<<
 *         P.w = w
 * 
 */
  __pyx_v_P.v = __pyx_v_v;

  /* "slabbe/mult_cont_frac.pyx":1377
 *         P.u = u
 *         P.v = v
 *         P.w = w             # <<<<<<<<<<<<<<
 * 
 *         # Loop
 */
  __pyx_v_P.w = __pyx_v_w;

  /* "slabbe/mult_cont_frac.pyx":1380
 * 
 *         # Loop
 *         for i from 0 <= i < n_iterations:             # <<<<<<<<<<<<<<
 * 
 *             # Check for Keyboard interupt
 */
  __pyx_t_10 = __pyx_v_n_iterations;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "slabbe/mult_cont_frac.pyx":1383
 * 
 *             # Check for Keyboard interupt
 *             sig_check()             # <<<<<<<<<<<<<<
 * 
 *             # Apply Algo
 */
    __pyx_t_11 = sig_check(); if (unlikely(__pyx_t_11 == 0)) __PYX_ERR(0, 1383, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1386
 * 
 *             # Apply Algo
 *             P = self.call(P)             # <<<<<<<<<<<<<<
 * 
 *             if verbose:
 */
    __pyx_t_12 = ((struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self->__pyx_vtab)->call(__pyx_v_self, __pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1386, __pyx_L1_error)
    __pyx_v_P = __pyx_t_12;

    /* "slabbe/mult_cont_frac.pyx":1388
 *             P = self.call(P)
 * 
 *             if verbose:             # <<<<<<<<<<<<<<
 *                 print("x=%f, y=%f, z=%f" % (P.x,P.y,P.z))
 *                 print("u=%f, v=%f, w=%f" % (P.u,P.v,P.w))
 */
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1388, __pyx_L1_error)
    if (__pyx_t_4) {

      /* "slabbe/mult_cont_frac.pyx":1389
 * 
 *             if verbose:
 *                 print("x=%f, y=%f, z=%f" % (P.x,P.y,P.z))             # <<<<<<<<<<<<<<
 *                 print("u=%f, v=%f, w=%f" % (P.u,P.v,P.w))
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w
 */
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1389, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1389, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_P.z); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1389, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1389, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_9);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_x_f_y_f_z_f, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1389, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_9) < 0) __PYX_ERR(0, 1389, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "slabbe/mult_cont_frac.pyx":1390
 *             if verbose:
 *                 print("x=%f, y=%f, z=%f" % (P.x,P.y,P.z))
 *                 print("u=%f, v=%f, w=%f" % (P.u,P.v,P.w))             # <<<<<<<<<<<<<<
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w
 *                 print("scal prod <(x,y,z),(u,v,w)> = %f (after algo)" % s)
 */
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_P.u); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1390, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_P.v); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1390, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_P.w); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1390, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1390, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2);
      __pyx_t_9 = 0;
      __pyx_t_5 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_u_f_v_f_w_f, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1390, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_2) < 0) __PYX_ERR(0, 1390, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "slabbe/mult_cont_frac.pyx":1391
 *                 print("x=%f, y=%f, z=%f" % (P.x,P.y,P.z))
 *                 print("u=%f, v=%f, w=%f" % (P.u,P.v,P.w))
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w             # <<<<<<<<<<<<<<
 *                 print("scal prod <(x,y,z),(u,v,w)> = %f (after algo)" % s)
 * 
 */
      __pyx_v_s = (((__pyx_v_P.x * __pyx_v_P.u) + (__pyx_v_P.y * __pyx_v_P.v)) + (__pyx_v_P.z * __pyx_v_P.w));

      /* "slabbe/mult_cont_frac.pyx":1392
 *                 print("u=%f, v=%f, w=%f" % (P.u,P.v,P.w))
 *                 s = P.x*P.u + P.y*P.v + P.z*P.w
 *                 print("scal prod <(x,y,z),(u,v,w)> = %f (after algo)" % s)             # <<<<<<<<<<<<<<
 * 
 *             # Save some computations
 */
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_s); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1392, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_scal_prod_x_y_z_u_v_w_f_after_al, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1392, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 1392, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "slabbe/mult_cont_frac.pyx":1388
 *             P = self.call(P)
 * 
 *             if verbose:             # <<<<<<<<<<<<<<
 *                 print("x=%f, y=%f, z=%f" % (P.x,P.y,P.z))
 *                 print("u=%f, v=%f, w=%f" % (P.u,P.v,P.w))
 */
    }

    /* "slabbe/mult_cont_frac.pyx":1396
 *             # Save some computations
 *             #if i % step == 0:
 *             if P.x < critical_value:             # <<<<<<<<<<<<<<
 * 
 *                 # Sum the first lyapunov exponent
 */
    __pyx_t_4 = ((__pyx_v_P.x < __pyx_v_critical_value) != 0);
    if (__pyx_t_4) {

      /* "slabbe/mult_cont_frac.pyx":1399
 * 
 *                 # Sum the first lyapunov exponent
 *                 s = P.x + P.y + P.z             # <<<<<<<<<<<<<<
 *                 p = -log(s) - theta1c
 *                 t = theta1 + p
 */
      __pyx_v_s = ((__pyx_v_P.x + __pyx_v_P.y) + __pyx_v_P.z);

      /* "slabbe/mult_cont_frac.pyx":1400
 *                 # Sum the first lyapunov exponent
 *                 s = P.x + P.y + P.z
 *                 p = -log(s) - theta1c             # <<<<<<<<<<<<<<
 *                 t = theta1 + p
 *                 theta1c = (t-theta1) - p   # mathematically 0 but not for a computer!!
 */
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_s); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1400, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_log);
      __pyx_t_5 = __pyx_v_log; __pyx_t_9 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1400, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1400, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1400, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Negative(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1400, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_theta1c); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1400, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_13 = PyNumber_Subtract(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1400, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_13); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1400, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_v_p = __pyx_t_6;

      /* "slabbe/mult_cont_frac.pyx":1401
 *                 s = P.x + P.y + P.z
 *                 p = -log(s) - theta1c
 *                 t = theta1 + p             # <<<<<<<<<<<<<<
 *                 theta1c = (t-theta1) - p   # mathematically 0 but not for a computer!!
 *                 theta1 = t
 */
      __pyx_v_t = (__pyx_v_theta1 + __pyx_v_p);

      /* "slabbe/mult_cont_frac.pyx":1402
 *                 p = -log(s) - theta1c
 *                 t = theta1 + p
 *                 theta1c = (t-theta1) - p   # mathematically 0 but not for a computer!!             # <<<<<<<<<<<<<<
 *                 theta1 = t
 *                 P.x /= s; P.y /= s; P.z /= s;
 */
      __pyx_v_theta1c = ((__pyx_v_t - __pyx_v_theta1) - __pyx_v_p);

      /* "slabbe/mult_cont_frac.pyx":1403
 *                 t = theta1 + p
 *                 theta1c = (t-theta1) - p   # mathematically 0 but not for a computer!!
 *                 theta1 = t             # <<<<<<<<<<<<<<
 *                 P.x /= s; P.y /= s; P.z /= s;
 * 
 */
      __pyx_v_theta1 = __pyx_v_t;

      /* "slabbe/mult_cont_frac.pyx":1404
 *                 theta1c = (t-theta1) - p   # mathematically 0 but not for a computer!!
 *                 theta1 = t
 *                 P.x /= s; P.y /= s; P.z /= s;             # <<<<<<<<<<<<<<
 * 
 *                 # Sum the second lyapunov exponent
 */
      if (unlikely(__pyx_v_s == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 1404, __pyx_L1_error)
      }
      __pyx_v_P.x = (__pyx_v_P.x / __pyx_v_s);
      if (unlikely(__pyx_v_s == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 1404, __pyx_L1_error)
      }
      __pyx_v_P.y = (__pyx_v_P.y / __pyx_v_s);
      if (unlikely(__pyx_v_s == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 1404, __pyx_L1_error)
      }
      __pyx_v_P.z = (__pyx_v_P.z / __pyx_v_s);

      /* "slabbe/mult_cont_frac.pyx":1407
 * 
 *                 # Sum the second lyapunov exponent
 *                 s = abs(P.u) + abs(P.v) + abs(P.w)             # <<<<<<<<<<<<<<
 *                 p = log(s) - theta2c
 *                 t = theta2 + p
 */
      __pyx_v_s = ((fabs(__pyx_v_P.u) + fabs(__pyx_v_P.v)) + fabs(__pyx_v_P.w));

      /* "slabbe/mult_cont_frac.pyx":1408
 *                 # Sum the second lyapunov exponent
 *                 s = abs(P.u) + abs(P.v) + abs(P.w)
 *                 p = log(s) - theta2c             # <<<<<<<<<<<<<<
 *                 t = theta2 + p
 *                 theta2c = (t-theta2) - p   # mathematically 0 but not for a computer!!
 */
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_s); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1408, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_log);
      __pyx_t_5 = __pyx_v_log; __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (!__pyx_t_2) {
        __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1408, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_13);
      } else {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1408, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); __pyx_t_2 = NULL;
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1408, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_theta2c); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1408, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = PyNumber_Subtract(__pyx_t_13, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1408, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1408, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_p = __pyx_t_6;

      /* "slabbe/mult_cont_frac.pyx":1409
 *                 s = abs(P.u) + abs(P.v) + abs(P.w)
 *                 p = log(s) - theta2c
 *                 t = theta2 + p             # <<<<<<<<<<<<<<
 *                 theta2c = (t-theta2) - p   # mathematically 0 but not for a computer!!
 *                 theta2 = t
 */
      __pyx_v_t = (__pyx_v_theta2 + __pyx_v_p);

      /* "slabbe/mult_cont_frac.pyx":1410
 *                 p = log(s) - theta2c
 *                 t = theta2 + p
 *                 theta2c = (t-theta2) - p   # mathematically 0 but not for a computer!!             # <<<<<<<<<<<<<<
 *                 theta2 = t
 * 
 */
      __pyx_v_theta2c = ((__pyx_v_t - __pyx_v_theta2) - __pyx_v_p);

      /* "slabbe/mult_cont_frac.pyx":1411
 *                 t = theta2 + p
 *                 theta2c = (t-theta2) - p   # mathematically 0 but not for a computer!!
 *                 theta2 = t             # <<<<<<<<<<<<<<
 * 
 *                 # the following gramm shimdts seems to be useless, but it is not!!!
 */
      __pyx_v_theta2 = __pyx_v_t;

      /* "slabbe/mult_cont_frac.pyx":1414
 * 
 *                 # the following gramm shimdts seems to be useless, but it is not!!!
 *                 p = P.x*P.u + P.y*P.v + P.z*P.w             # <<<<<<<<<<<<<<
 *                 s = P.x*P.x + P.y*P.y + P.z*P.z
 *                 P.u -= p*P.x/s; P.v -= p*P.y/s; P.w -= p*P.z/s
 */
      __pyx_v_p = (((__pyx_v_P.x * __pyx_v_P.u) + (__pyx_v_P.y * __pyx_v_P.v)) + (__pyx_v_P.z * __pyx_v_P.w));

      /* "slabbe/mult_cont_frac.pyx":1415
 *                 # the following gramm shimdts seems to be useless, but it is not!!!
 *                 p = P.x*P.u + P.y*P.v + P.z*P.w
 *                 s = P.x*P.x + P.y*P.y + P.z*P.z             # <<<<<<<<<<<<<<
 *                 P.u -= p*P.x/s; P.v -= p*P.y/s; P.w -= p*P.z/s
 *                 s = abs(P.u) + abs(P.v) + abs(P.w)
 */
      __pyx_v_s = (((__pyx_v_P.x * __pyx_v_P.x) + (__pyx_v_P.y * __pyx_v_P.y)) + (__pyx_v_P.z * __pyx_v_P.z));

      /* "slabbe/mult_cont_frac.pyx":1416
 *                 p = P.x*P.u + P.y*P.v + P.z*P.w
 *                 s = P.x*P.x + P.y*P.y + P.z*P.z
 *                 P.u -= p*P.x/s; P.v -= p*P.y/s; P.w -= p*P.z/s             # <<<<<<<<<<<<<<
 *                 s = abs(P.u) + abs(P.v) + abs(P.w)
 *                 P.u /= s; P.v /= s; P.w /= s
 */
      __pyx_t_6 = (__pyx_v_p * __pyx_v_P.x);
      if (unlikely(__pyx_v_s == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 1416, __pyx_L1_error)
      }
      __pyx_v_P.u = (__pyx_v_P.u - (__pyx_t_6 / __pyx_v_s));
      __pyx_t_6 = (__pyx_v_p * __pyx_v_P.y);
      if (unlikely(__pyx_v_s == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 1416, __pyx_L1_error)
      }
      __pyx_v_P.v = (__pyx_v_P.v - (__pyx_t_6 / __pyx_v_s));
      __pyx_t_6 = (__pyx_v_p * __pyx_v_P.z);
      if (unlikely(__pyx_v_s == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 1416, __pyx_L1_error)
      }
      __pyx_v_P.w = (__pyx_v_P.w - (__pyx_t_6 / __pyx_v_s));

      /* "slabbe/mult_cont_frac.pyx":1417
 *                 s = P.x*P.x + P.y*P.y + P.z*P.z
 *                 P.u -= p*P.x/s; P.v -= p*P.y/s; P.w -= p*P.z/s
 *                 s = abs(P.u) + abs(P.v) + abs(P.w)             # <<<<<<<<<<<<<<
 *                 P.u /= s; P.v /= s; P.w /= s
 * 
 */
      __pyx_v_s = ((fabs(__pyx_v_P.u) + fabs(__pyx_v_P.v)) + fabs(__pyx_v_P.w));

      /* "slabbe/mult_cont_frac.pyx":1418
 *                 P.u -= p*P.x/s; P.v -= p*P.y/s; P.w -= p*P.z/s
 *                 s = abs(P.u) + abs(P.v) + abs(P.w)
 *                 P.u /= s; P.v /= s; P.w /= s             # <<<<<<<<<<<<<<
 * 
 *         return theta1/n_iterations, theta2/n_iterations, 1-theta2/theta1
 */
      if (unlikely(__pyx_v_s == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 1418, __pyx_L1_error)
      }
      __pyx_v_P.u = (__pyx_v_P.u / __pyx_v_s);
      if (unlikely(__pyx_v_s == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 1418, __pyx_L1_error)
      }
      __pyx_v_P.v = (__pyx_v_P.v / __pyx_v_s);
      if (unlikely(__pyx_v_s == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 1418, __pyx_L1_error)
      }
      __pyx_v_P.w = (__pyx_v_P.w / __pyx_v_s);

      /* "slabbe/mult_cont_frac.pyx":1396
 *             # Save some computations
 *             #if i % step == 0:
 *             if P.x < critical_value:             # <<<<<<<<<<<<<<
 * 
 *                 # Sum the first lyapunov exponent
 */
    }
  }

  /* "slabbe/mult_cont_frac.pyx":1420
 *                 P.u /= s; P.v /= s; P.w /= s
 * 
 *         return theta1/n_iterations, theta2/n_iterations, 1-theta2/theta1             # <<<<<<<<<<<<<<
 * 
 *     ######################
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_n_iterations == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1420, __pyx_L1_error)
  }
  __pyx_t_9 = PyFloat_FromDouble((__pyx_v_theta1 / __pyx_v_n_iterations)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (unlikely(__pyx_v_n_iterations == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1420, __pyx_L1_error)
  }
  __pyx_t_5 = PyFloat_FromDouble((__pyx_v_theta2 / __pyx_v_n_iterations)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (unlikely(__pyx_v_theta1 == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1420, __pyx_L1_error)
  }
  __pyx_t_13 = PyFloat_FromDouble((1.0 - (__pyx_v_theta2 / __pyx_v_theta1))); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_13);
  __pyx_t_9 = 0;
  __pyx_t_5 = 0;
  __pyx_t_13 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":1287
 *         return domain_left, image_left, domain_right, image_right
 * 
 *     def lyapunov_exponents(self, start=None, int n_iterations=1000, verbose=False):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the lyapunov exponents (theta1, theta2, 1-theta2/theta1)
 */

  /* 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_9);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.lyapunov_exponents", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_log);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1425
 *     # COMBINATORICS METHODS
 *     ######################
 *     def s_adic_word(self, v=None, n_iterations=100, nth_letter=1):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the s-adic word obtained from application of the MCF
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_50s_adic_word(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_49s_adic_word[] = "\n        Return the s-adic word obtained from application of the MCF\n        algorithm on the vector v.\n\n        INPUT:\n\n        - ``v`` - initial vector (default: ``None``), if None, then\n          initial point is random\n        - ``n_iterations`` - integer (default: ``100``), number of\n          iterations\n        - ``nth_letter`` - letter (default: ``1``)\n\n        OUTPUT:\n\n            word\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun, ARP, Cassaigne\n            sage: Brun().s_adic_word((.414578,.571324,.65513))\n            word: 1232312312323123123312323123123312323123...\n            sage: Brun().s_adic_word((1,e,pi))\n            word: 1232323123233231232332312323123232312323...\n            sage: ARP().s_adic_word((1,e,pi))\n            word: 1232323123233231232332312323123232312323...\n            sage: Cassaigne().s_adic_word((1,e,pi))\n            word: 2323213232323132323213232321323231323232...\n\n        On integer entries::\n\n            sage: w = Brun().s_adic_word((3,4,5))\n            sage: w\n            word: 123233123123\n            sage: w.abelian_vector()\n            [3, 4, 5]\n\n        When the gcd is not one::\n\n            sage: Brun().s_adic_word((2,4,10))\n            word: 1233323312333233\n\n        ::\n\n            sage: from slabbe.mult_cont_frac import FullySubtractive\n            sage: FullySubtractive().s_adic_word((1,2,5))\n            Traceback (most recent call last):\n            ...\n            ValueError: On input=(1, 2, 5), algorithm Fully Subtractive\n            loops on (1.0, 0.0, 3.0)\n\n        ::\n\n            sage: from slabbe.mult_cont_frac import Reverse\n            sage: algo = Reverse()\n            sage: algo.s_adic_word((18,1,1))\n            word: 31111111111211111111\n            sage: _.abelian_vector()\n            [18, 1, 1]\n\n        ::\n\n            sage: Reverse().s_adic_word((3,1,1))\n            Traceback (most recent call last):\n        ""    ...\n            ValueError: On input=(3, 1, 1), algorithm Reverse reaches non\n            integer entries (0.5, 0.5, 0.5)\n\n        TESTS::\n\n            sage: v = ARP().s_adic_word((1,e,pi))\n            sage: w = Brun().s_adic_word((1,e,pi))\n            sage: v.longest_common_prefix(w, 'finite').length()\n            212\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_50s_adic_word(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_v = 0;
  PyObject *__pyx_v_n_iterations = 0;
  PyObject *__pyx_v_nth_letter = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("s_adic_word (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_v,&__pyx_n_s_n_iterations,&__pyx_n_s_nth_letter,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)__pyx_int_100);
    values[2] = ((PyObject *)__pyx_int_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_v);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nth_letter);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "s_adic_word") < 0)) __PYX_ERR(0, 1425, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_v = values[0];
    __pyx_v_n_iterations = values[1];
    __pyx_v_nth_letter = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("s_adic_word", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1425, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.s_adic_word", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_49s_adic_word(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_v, __pyx_v_n_iterations, __pyx_v_nth_letter);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_2generator4(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "slabbe/mult_cont_frac.pyx":1505
 *             v = (random(), random(), random())
 *         D = self.substitutions()
 *         if all(a in ZZ for a in v):             # <<<<<<<<<<<<<<
 *             S = []
 *             it = self.cone_orbit_iterator(v)
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_2generator4, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_s_adic_word_locals_genexpr); if (unlikely(!gen)) __PYX_ERR(0, 1505, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.s_adic_word.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_2generator4(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *__pyx_cur_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1505, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_v)) { __Pyx_RaiseClosureNameError("v"); __PYX_ERR(0, 1505, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_v)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_v)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_v; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_v); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1505, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1505, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1505, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1505, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1505, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1505, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1505, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_a);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_a, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_ZZ)) { __Pyx_RaiseClosureNameError("ZZ"); __PYX_ERR(0, 1505, __pyx_L1_error) }
    __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_cur_scope->__pyx_v_a, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_ZZ, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1505, __pyx_L1_error)
    __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
    if (__pyx_t_6) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
  }
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_5generator5(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "slabbe/mult_cont_frac.pyx":1511
 *             for A,B,b in it:
 *                 sig_check()
 *                 if not all(a in ZZ for a in A):             # <<<<<<<<<<<<<<
 *                     raise ValueError("On input={}, algorithm {} reaches"
 *                             " non integer entries {}".format(v, self.name(), A))
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_3genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_5generator5, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_s_adic_word_locals_genexpr); if (unlikely(!gen)) __PYX_ERR(0, 1511, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.s_adic_word.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_5generator5(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *__pyx_cur_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1511, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_A)) { __Pyx_RaiseClosureNameError("A"); __PYX_ERR(0, 1511, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_A)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_A)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_A; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_A); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1511, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1511, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1511, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1511, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1511, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1511, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1511, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_a);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_a, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_ZZ)) { __Pyx_RaiseClosureNameError("ZZ"); __PYX_ERR(0, 1511, __pyx_L1_error) }
    __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_cur_scope->__pyx_v_a, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_ZZ, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1511, __pyx_L1_error)
    __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
    if (__pyx_t_6) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
  }
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1425
 *     # COMBINATORICS METHODS
 *     ######################
 *     def s_adic_word(self, v=None, n_iterations=100, nth_letter=1):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the s-adic word obtained from application of the MCF
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_49s_adic_word(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_v, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_nth_letter) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *__pyx_cur_scope;
  PyObject *__pyx_v_words = NULL;
  PyObject *__pyx_v_D = NULL;
  PyObject *__pyx_v_S = NULL;
  PyObject *__pyx_v_it = NULL;
  PyObject *__pyx_v_previousA = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_B = NULL;
  PyObject *__pyx_v_b = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_v_z = NULL;
  PyObject *__pyx_v_letter = NULL;
  PyObject *__pyx_v_the_gcd = NULL;
  PyObject *__pyx_v_L = NULL;
  PyObject *__pyx_v_key = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_r = NULL;
  __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;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  int __pyx_t_14;
  __Pyx_RefNannySetupContext("s_adic_word", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_v = __pyx_v_v;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_v);

  /* "slabbe/mult_cont_frac.pyx":1500
 *             212
 *         """
 *         from sage.combinat.words.word_generators import words             # <<<<<<<<<<<<<<
 *         from sage.rings.integer_ring import ZZ
 *         if v is None:
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_words);
  __Pyx_GIVEREF(__pyx_n_s_words);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_words);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_word_generat, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_words); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_words = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1501
 *         """
 *         from sage.combinat.words.word_generators import words
 *         from sage.rings.integer_ring import ZZ             # <<<<<<<<<<<<<<
 *         if v is None:
 *             v = (random(), random(), random())
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_ZZ);
  __Pyx_GIVEREF(__pyx_n_s_ZZ);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ZZ);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_sage_rings_integer_ring, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ZZ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_ZZ = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1502
 *         from sage.combinat.words.word_generators import words
 *         from sage.rings.integer_ring import ZZ
 *         if v is None:             # <<<<<<<<<<<<<<
 *             v = (random(), random(), random())
 *         D = self.substitutions()
 */
  __pyx_t_3 = (__pyx_cur_scope->__pyx_v_v == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":1503
 *         from sage.rings.integer_ring import ZZ
 *         if v is None:
 *             v = (random(), random(), random())             # <<<<<<<<<<<<<<
 *         D = self.substitutions()
 *         if all(a in ZZ for a in v):
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1503, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1503, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_6) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1503, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1503, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1503, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1503, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;

    /* "slabbe/mult_cont_frac.pyx":1502
 *         from sage.combinat.words.word_generators import words
 *         from sage.rings.integer_ring import ZZ
 *         if v is None:             # <<<<<<<<<<<<<<
 *             v = (random(), random(), random())
 *         D = self.substitutions()
 */
  }

  /* "slabbe/mult_cont_frac.pyx":1504
 *         if v is None:
 *             v = (random(), random(), random())
 *         D = self.substitutions()             # <<<<<<<<<<<<<<
 *         if all(a in ZZ for a in v):
 *             S = []
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_substitutions); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1504, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1504, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1504, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_D = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "slabbe/mult_cont_frac.pyx":1505
 *             v = (random(), random(), random())
 *         D = self.substitutions()
 *         if all(a in ZZ for a in v):             # <<<<<<<<<<<<<<
 *             S = []
 *             it = self.cone_orbit_iterator(v)
 */
  __pyx_t_6 = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_Generator_Next(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1505, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":1506
 *         D = self.substitutions()
 *         if all(a in ZZ for a in v):
 *             S = []             # <<<<<<<<<<<<<<
 *             it = self.cone_orbit_iterator(v)
 *             previousA = None
 */
    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1506, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_v_S = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "slabbe/mult_cont_frac.pyx":1507
 *         if all(a in ZZ for a in v):
 *             S = []
 *             it = self.cone_orbit_iterator(v)             # <<<<<<<<<<<<<<
 *             previousA = None
 *             for A,B,b in it:
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_cone_orbit_iterator); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_cur_scope->__pyx_v_v); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1507, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1507, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_cur_scope->__pyx_v_v);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1507, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_it = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "slabbe/mult_cont_frac.pyx":1508
 *             S = []
 *             it = self.cone_orbit_iterator(v)
 *             previousA = None             # <<<<<<<<<<<<<<
 *             for A,B,b in it:
 *                 sig_check()
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_previousA = Py_None;

    /* "slabbe/mult_cont_frac.pyx":1509
 *             it = self.cone_orbit_iterator(v)
 *             previousA = None
 *             for A,B,b in it:             # <<<<<<<<<<<<<<
 *                 sig_check()
 *                 if not all(a in ZZ for a in A):
 */
    if (likely(PyList_CheckExact(__pyx_v_it)) || PyTuple_CheckExact(__pyx_v_it)) {
      __pyx_t_5 = __pyx_v_it; __Pyx_INCREF(__pyx_t_5); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_it); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1509, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1509, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1509, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1509, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1509, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1509, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        }
      } else {
        __pyx_t_6 = __pyx_t_9(__pyx_t_5);
        if (unlikely(!__pyx_t_6)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1509, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
        PyObject* sequence = __pyx_t_6;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 1509, __pyx_L1_error)
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1509, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1509, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1509, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_10 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1509, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
        index = 0; __pyx_t_1 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        index = 1; __pyx_t_2 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 2; __pyx_t_7 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_7)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 3) < 0) __PYX_ERR(0, 1509, __pyx_L1_error)
        __pyx_t_11 = NULL;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_11 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 1509, __pyx_L1_error)
        __pyx_L8_unpacking_done:;
      }
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_A);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_A, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_B, __pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_XDECREF_SET(__pyx_v_b, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "slabbe/mult_cont_frac.pyx":1510
 *             previousA = None
 *             for A,B,b in it:
 *                 sig_check()             # <<<<<<<<<<<<<<
 *                 if not all(a in ZZ for a in A):
 *                     raise ValueError("On input={}, algorithm {} reaches"
 */
      __pyx_t_12 = sig_check(); if (unlikely(__pyx_t_12 == 0)) __PYX_ERR(0, 1510, __pyx_L1_error)

      /* "slabbe/mult_cont_frac.pyx":1511
 *             for A,B,b in it:
 *                 sig_check()
 *                 if not all(a in ZZ for a in A):             # <<<<<<<<<<<<<<
 *                     raise ValueError("On input={}, algorithm {} reaches"
 *                             " non integer entries {}".format(v, self.name(), A))
 */
      __pyx_t_6 = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_11s_adic_word_3genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1511, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_Generator_Next(__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1511, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1511, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_3 = ((!__pyx_t_4) != 0);
      if (__pyx_t_3) {

        /* "slabbe/mult_cont_frac.pyx":1513
 *                 if not all(a in ZZ for a in A):
 *                     raise ValueError("On input={}, algorithm {} reaches"
 *                             " non integer entries {}".format(v, self.name(), A))             # <<<<<<<<<<<<<<
 *                 if A == previousA:
 *                     break
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_On_input_algorithm_reaches_non_i, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1513, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1513, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_10 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        if (__pyx_t_10) {
          __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1513, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else {
          __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1513, __pyx_L1_error)
        }
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = NULL;
        __pyx_t_13 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
            __pyx_t_13 = 1;
          }
        }
        __pyx_t_10 = PyTuple_New(3+__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1513, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_1) {
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); __pyx_t_1 = NULL;
        }
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_v);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_13, __pyx_cur_scope->__pyx_v_v);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_13, __pyx_t_2);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_A);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_A);
        PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_13, __pyx_cur_scope->__pyx_v_A);
        __pyx_t_2 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1513, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "slabbe/mult_cont_frac.pyx":1512
 *                 sig_check()
 *                 if not all(a in ZZ for a in A):
 *                     raise ValueError("On input={}, algorithm {} reaches"             # <<<<<<<<<<<<<<
 *                             " non integer entries {}".format(v, self.name(), A))
 *                 if A == previousA:
 */
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1512, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1512, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(0, 1512, __pyx_L1_error)

        /* "slabbe/mult_cont_frac.pyx":1511
 *             for A,B,b in it:
 *                 sig_check()
 *                 if not all(a in ZZ for a in A):             # <<<<<<<<<<<<<<
 *                     raise ValueError("On input={}, algorithm {} reaches"
 *                             " non integer entries {}".format(v, self.name(), A))
 */
      }

      /* "slabbe/mult_cont_frac.pyx":1514
 *                     raise ValueError("On input={}, algorithm {} reaches"
 *                             " non integer entries {}".format(v, self.name(), A))
 *                 if A == previousA:             # <<<<<<<<<<<<<<
 *                     break
 *                 S.append(b)
 */
      __pyx_t_7 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_A, __pyx_v_previousA, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1514, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1514, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__pyx_t_3) {

        /* "slabbe/mult_cont_frac.pyx":1515
 *                             " non integer entries {}".format(v, self.name(), A))
 *                 if A == previousA:
 *                     break             # <<<<<<<<<<<<<<
 *                 S.append(b)
 *                 previousA = A
 */
        goto __pyx_L6_break;

        /* "slabbe/mult_cont_frac.pyx":1514
 *                     raise ValueError("On input={}, algorithm {} reaches"
 *                             " non integer entries {}".format(v, self.name(), A))
 *                 if A == previousA:             # <<<<<<<<<<<<<<
 *                     break
 *                 S.append(b)
 */
      }

      /* "slabbe/mult_cont_frac.pyx":1516
 *                 if A == previousA:
 *                     break
 *                 S.append(b)             # <<<<<<<<<<<<<<
 *                 previousA = A
 *             (x,y,z) = A
 */
      __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_S, __pyx_v_b); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 1516, __pyx_L1_error)

      /* "slabbe/mult_cont_frac.pyx":1517
 *                     break
 *                 S.append(b)
 *                 previousA = A             # <<<<<<<<<<<<<<
 *             (x,y,z) = A
 *             if x == 0 == y:
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_A);
      __Pyx_DECREF_SET(__pyx_v_previousA, __pyx_cur_scope->__pyx_v_A);

      /* "slabbe/mult_cont_frac.pyx":1509
 *             it = self.cone_orbit_iterator(v)
 *             previousA = None
 *             for A,B,b in it:             # <<<<<<<<<<<<<<
 *                 sig_check()
 *                 if not all(a in ZZ for a in A):
 */
    }
    __pyx_L6_break:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "slabbe/mult_cont_frac.pyx":1518
 *                 S.append(b)
 *                 previousA = A
 *             (x,y,z) = A             # <<<<<<<<<<<<<<
 *             if x == 0 == y:
 *                 letter = 3
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_A)) { __Pyx_RaiseUnboundLocalError("A"); __PYX_ERR(0, 1518, __pyx_L1_error) }
    if ((likely(PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_A))) || (PyList_CheckExact(__pyx_cur_scope->__pyx_v_A))) {
      PyObject* sequence = __pyx_cur_scope->__pyx_v_A;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 1518, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
    } else {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_A); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_7 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_7)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      index = 2; __pyx_t_6 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_6)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 3) < 0) __PYX_ERR(0, 1518, __pyx_L1_error)
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L12_unpacking_done;
      __pyx_L11_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 1518, __pyx_L1_error)
      __pyx_L12_unpacking_done:;
    }
    __pyx_v_x = __pyx_t_5;
    __pyx_t_5 = 0;
    __pyx_v_y = __pyx_t_7;
    __pyx_t_7 = 0;
    __pyx_v_z = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "slabbe/mult_cont_frac.pyx":1519
 *                 previousA = A
 *             (x,y,z) = A
 *             if x == 0 == y:             # <<<<<<<<<<<<<<
 *                 letter = 3
 *                 the_gcd = ZZ(z)
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_x, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1519, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_6)) {
      __Pyx_DECREF(__pyx_t_6);
      __pyx_t_6 = PyObject_RichCompare(__pyx_int_0, __pyx_v_y, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1519, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1519, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_3) {

      /* "slabbe/mult_cont_frac.pyx":1520
 *             (x,y,z) = A
 *             if x == 0 == y:
 *                 letter = 3             # <<<<<<<<<<<<<<
 *                 the_gcd = ZZ(z)
 *             elif x == 0 == z:
 */
      __Pyx_INCREF(__pyx_int_3);
      __pyx_v_letter = __pyx_int_3;

      /* "slabbe/mult_cont_frac.pyx":1521
 *             if x == 0 == y:
 *                 letter = 3
 *                 the_gcd = ZZ(z)             # <<<<<<<<<<<<<<
 *             elif x == 0 == z:
 *                 letter = 2
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_ZZ);
      __pyx_t_7 = __pyx_cur_scope->__pyx_v_ZZ; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_z); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1521, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1521, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_INCREF(__pyx_v_z);
        __Pyx_GIVEREF(__pyx_v_z);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_z);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1521, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_the_gcd = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "slabbe/mult_cont_frac.pyx":1519
 *                 previousA = A
 *             (x,y,z) = A
 *             if x == 0 == y:             # <<<<<<<<<<<<<<
 *                 letter = 3
 *                 the_gcd = ZZ(z)
 */
      goto __pyx_L13;
    }

    /* "slabbe/mult_cont_frac.pyx":1522
 *                 letter = 3
 *                 the_gcd = ZZ(z)
 *             elif x == 0 == z:             # <<<<<<<<<<<<<<
 *                 letter = 2
 *                 the_gcd = ZZ(y)
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_x, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1522, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_6)) {
      __Pyx_DECREF(__pyx_t_6);
      __pyx_t_6 = PyObject_RichCompare(__pyx_int_0, __pyx_v_z, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1522, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1522, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_3) {

      /* "slabbe/mult_cont_frac.pyx":1523
 *                 the_gcd = ZZ(z)
 *             elif x == 0 == z:
 *                 letter = 2             # <<<<<<<<<<<<<<
 *                 the_gcd = ZZ(y)
 *             elif y == 0 == z:
 */
      __Pyx_INCREF(__pyx_int_2);
      __pyx_v_letter = __pyx_int_2;

      /* "slabbe/mult_cont_frac.pyx":1524
 *             elif x == 0 == z:
 *                 letter = 2
 *                 the_gcd = ZZ(y)             # <<<<<<<<<<<<<<
 *             elif y == 0 == z:
 *                 letter = 1
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_ZZ);
      __pyx_t_7 = __pyx_cur_scope->__pyx_v_ZZ; __pyx_t_10 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_y); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1524, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1524, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_y);
        __Pyx_GIVEREF(__pyx_v_y);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_y);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1524, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_the_gcd = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "slabbe/mult_cont_frac.pyx":1522
 *                 letter = 3
 *                 the_gcd = ZZ(z)
 *             elif x == 0 == z:             # <<<<<<<<<<<<<<
 *                 letter = 2
 *                 the_gcd = ZZ(y)
 */
      goto __pyx_L13;
    }

    /* "slabbe/mult_cont_frac.pyx":1525
 *                 letter = 2
 *                 the_gcd = ZZ(y)
 *             elif y == 0 == z:             # <<<<<<<<<<<<<<
 *                 letter = 1
 *                 the_gcd = ZZ(x)
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_y, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1525, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_6)) {
      __Pyx_DECREF(__pyx_t_6);
      __pyx_t_6 = PyObject_RichCompare(__pyx_int_0, __pyx_v_z, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1525, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1525, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_3) {

      /* "slabbe/mult_cont_frac.pyx":1526
 *                 the_gcd = ZZ(y)
 *             elif y == 0 == z:
 *                 letter = 1             # <<<<<<<<<<<<<<
 *                 the_gcd = ZZ(x)
 *             else:
 */
      __Pyx_INCREF(__pyx_int_1);
      __pyx_v_letter = __pyx_int_1;

      /* "slabbe/mult_cont_frac.pyx":1527
 *             elif y == 0 == z:
 *                 letter = 1
 *                 the_gcd = ZZ(x)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("On input={}, algorithm {} loops"
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_ZZ);
      __pyx_t_7 = __pyx_cur_scope->__pyx_v_ZZ; __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_x); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1527, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1527, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_x);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1527, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_the_gcd = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "slabbe/mult_cont_frac.pyx":1525
 *                 letter = 2
 *                 the_gcd = ZZ(y)
 *             elif y == 0 == z:             # <<<<<<<<<<<<<<
 *                 letter = 1
 *                 the_gcd = ZZ(x)
 */
      goto __pyx_L13;
    }

    /* "slabbe/mult_cont_frac.pyx":1529
 *                 the_gcd = ZZ(x)
 *             else:
 *                 raise ValueError("On input={}, algorithm {} loops"             # <<<<<<<<<<<<<<
 *                                  " on {}".format(v, self.name(), A))
 *             return words.s_adic(S, [letter], D)**the_gcd
 */
    /*else*/ {

      /* "slabbe/mult_cont_frac.pyx":1530
 *             else:
 *                 raise ValueError("On input={}, algorithm {} loops"
 *                                  " on {}".format(v, self.name(), A))             # <<<<<<<<<<<<<<
 *             return words.s_adic(S, [letter], D)**the_gcd
 * 
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_On_input_algorithm_loops_on, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1530, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1530, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (__pyx_t_2) {
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1530, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1530, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_cur_scope->__pyx_v_A)) { __Pyx_RaiseUnboundLocalError("A"); __PYX_ERR(0, 1530, __pyx_L1_error) }
      __pyx_t_5 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_2 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1530, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_8, __pyx_cur_scope->__pyx_v_v);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_8, __pyx_t_10);
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_A);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_A);
      PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_8, __pyx_cur_scope->__pyx_v_A);
      __pyx_t_10 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1530, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "slabbe/mult_cont_frac.pyx":1529
 *                 the_gcd = ZZ(x)
 *             else:
 *                 raise ValueError("On input={}, algorithm {} loops"             # <<<<<<<<<<<<<<
 *                                  " on {}".format(v, self.name(), A))
 *             return words.s_adic(S, [letter], D)**the_gcd
 */
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1529, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1529, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(0, 1529, __pyx_L1_error)
    }
    __pyx_L13:;

    /* "slabbe/mult_cont_frac.pyx":1531
 *                 raise ValueError("On input={}, algorithm {} loops"
 *                                  " on {}".format(v, self.name(), A))
 *             return words.s_adic(S, [letter], D)**the_gcd             # <<<<<<<<<<<<<<
 * 
 *         else:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_words, __pyx_n_s_s_adic); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1531, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1531, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_letter);
    __Pyx_GIVEREF(__pyx_v_letter);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_letter);
    __pyx_t_10 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_5 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1531, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_INCREF(__pyx_v_S);
    __Pyx_GIVEREF(__pyx_v_S);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_v_S);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_D);
    __Pyx_GIVEREF(__pyx_v_D);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_8, __pyx_v_D);
    __pyx_t_2 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1531, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_Power(__pyx_t_6, __pyx_v_the_gcd, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1531, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":1505
 *             v = (random(), random(), random())
 *         D = self.substitutions()
 *         if all(a in ZZ for a in v):             # <<<<<<<<<<<<<<
 *             S = []
 *             it = self.cone_orbit_iterator(v)
 */
  }

  /* "slabbe/mult_cont_frac.pyx":1534
 * 
 *         else:
 *             it = self.coding_iterator(v)             # <<<<<<<<<<<<<<
 *             S = [next(it) for _ in range(n_iterations)]
 *             letter = nth_letter
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_coding_iterator); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_cur_scope->__pyx_v_v); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1534, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1534, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_cur_scope->__pyx_v_v);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1534, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_it = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "slabbe/mult_cont_frac.pyx":1535
 *         else:
 *             it = self.coding_iterator(v)
 *             S = [next(it) for _ in range(n_iterations)]             # <<<<<<<<<<<<<<
 *             letter = nth_letter
 *             L = [letter]
 */
    __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_n_iterations);
    __Pyx_GIVEREF(__pyx_v_n_iterations);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_n_iterations);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_6 = __pyx_t_2; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1535, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1535, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_6))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1535, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1535, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1535, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1535, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_9(__pyx_t_6);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1535, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyIter_Next(__pyx_v_it); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1535, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 1535, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_S = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "slabbe/mult_cont_frac.pyx":1536
 *             it = self.coding_iterator(v)
 *             S = [next(it) for _ in range(n_iterations)]
 *             letter = nth_letter             # <<<<<<<<<<<<<<
 *             L = [letter]
 *             for key in reversed(S):
 */
    __Pyx_INCREF(__pyx_v_nth_letter);
    __pyx_v_letter = __pyx_v_nth_letter;

    /* "slabbe/mult_cont_frac.pyx":1537
 *             S = [next(it) for _ in range(n_iterations)]
 *             letter = nth_letter
 *             L = [letter]             # <<<<<<<<<<<<<<
 *             for key in reversed(S):
 *                 letter = D[key](letter)[0]
 */
    __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1537, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_letter);
    __Pyx_GIVEREF(__pyx_v_letter);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_v_letter);
    __pyx_v_L = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "slabbe/mult_cont_frac.pyx":1538
 *             letter = nth_letter
 *             L = [letter]
 *             for key in reversed(S):             # <<<<<<<<<<<<<<
 *                 letter = D[key](letter)[0]
 *                 L.append(letter)
 */
    __pyx_t_7 = __pyx_v_S; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = PyList_GET_SIZE(__pyx_t_7) - 1;
    for (;;) {
      if (__pyx_t_8 < 0) break;
      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_7)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8--; if (unlikely(0 < 0)) __PYX_ERR(0, 1538, __pyx_L1_error)
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8--; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1538, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "slabbe/mult_cont_frac.pyx":1539
 *             L = [letter]
 *             for key in reversed(S):
 *                 letter = D[key](letter)[0]             # <<<<<<<<<<<<<<
 *                 L.append(letter)
 *             L.pop()
 */
      __pyx_t_2 = PyObject_GetItem(__pyx_v_D, __pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1539, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_letter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1539, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1539, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_INCREF(__pyx_v_letter);
        __Pyx_GIVEREF(__pyx_v_letter);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_letter);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1539, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1539, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF_SET(__pyx_v_letter, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "slabbe/mult_cont_frac.pyx":1540
 *             for key in reversed(S):
 *                 letter = D[key](letter)[0]
 *                 L.append(letter)             # <<<<<<<<<<<<<<
 *             L.pop()
 *             L.reverse()
 */
      __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_L, __pyx_v_letter); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 1540, __pyx_L1_error)

      /* "slabbe/mult_cont_frac.pyx":1538
 *             letter = nth_letter
 *             L = [letter]
 *             for key in reversed(S):             # <<<<<<<<<<<<<<
 *                 letter = D[key](letter)[0]
 *                 L.append(letter)
 */
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "slabbe/mult_cont_frac.pyx":1541
 *                 letter = D[key](letter)[0]
 *                 L.append(letter)
 *             L.pop()             # <<<<<<<<<<<<<<
 *             L.reverse()
 *             return words.s_adic(S, L, D)
 */
    __pyx_t_7 = __Pyx_PyList_Pop(__pyx_v_L); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1541, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "slabbe/mult_cont_frac.pyx":1542
 *                 L.append(letter)
 *             L.pop()
 *             L.reverse()             # <<<<<<<<<<<<<<
 *             return words.s_adic(S, L, D)
 * 
 */
    __pyx_t_14 = PyList_Reverse(__pyx_v_L); if (unlikely(__pyx_t_14 == -1)) __PYX_ERR(0, 1542, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1543
 *             L.pop()
 *             L.reverse()
 *             return words.s_adic(S, L, D)             # <<<<<<<<<<<<<<
 * 
 *     def discrepancy_statistics(self, length):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_words, __pyx_n_s_s_adic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_10 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_v_S);
    __Pyx_GIVEREF(__pyx_v_S);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_8, __pyx_v_S);
    __Pyx_INCREF(__pyx_v_L);
    __Pyx_GIVEREF(__pyx_v_L);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_8, __pyx_v_L);
    __Pyx_INCREF(__pyx_v_D);
    __Pyx_GIVEREF(__pyx_v_D);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_8, __pyx_v_D);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;
  }

  /* "slabbe/mult_cont_frac.pyx":1425
 *     # COMBINATORICS METHODS
 *     ######################
 *     def s_adic_word(self, v=None, n_iterations=100, nth_letter=1):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the s-adic word obtained from application of the MCF
 */

  /* 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_10);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.s_adic_word", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_words);
  __Pyx_XDECREF(__pyx_v_D);
  __Pyx_XDECREF(__pyx_v_S);
  __Pyx_XDECREF(__pyx_v_it);
  __Pyx_XDECREF(__pyx_v_previousA);
  __Pyx_XDECREF(__pyx_v_B);
  __Pyx_XDECREF(__pyx_v_b);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_z);
  __Pyx_XDECREF(__pyx_v_letter);
  __Pyx_XDECREF(__pyx_v_the_gcd);
  __Pyx_XDECREF(__pyx_v_L);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1545
 *             return words.s_adic(S, L, D)
 * 
 *     def discrepancy_statistics(self, length):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the discrepancy of words of given length.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_52discrepancy_statistics(PyObject *__pyx_v_self, PyObject *__pyx_v_length); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_51discrepancy_statistics[] = "\n        Return the discrepancy of words of given length.\n\n        INPUT:\n\n        - ``length`` -- integer\n\n        OUTPUT:\n\n            dict\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: Brun().discrepancy_statistics(5)\n            {[1, 1, 3]: 6/5,\n             [1, 2, 2]: 4/5,\n             [1, 3, 1]: 4/5,\n             [2, 1, 2]: 4/5,\n             [2, 2, 1]: 4/5,\n             [3, 1, 1]: 4/5}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_52discrepancy_statistics(PyObject *__pyx_v_self, PyObject *__pyx_v_length) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("discrepancy_statistics (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_51discrepancy_statistics(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_length));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_51discrepancy_statistics(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_length) {
  PyObject *__pyx_v_discrepancy = NULL;
  PyObject *__pyx_v_Compositions = NULL;
  PyObject *__pyx_v_D = NULL;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_v_w = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  __Pyx_RefNannySetupContext("discrepancy_statistics", 0);

  /* "slabbe/mult_cont_frac.pyx":1568
 *              [3, 1, 1]: 4/5}
 *         """
 *         from finite_word import discrepancy             # <<<<<<<<<<<<<<
 *         from sage.combinat.composition import Compositions
 *         D = {}
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_discrepancy);
  __Pyx_GIVEREF(__pyx_n_s_discrepancy);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_discrepancy);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_finite_word, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_discrepancy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_discrepancy = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1569
 *         """
 *         from finite_word import discrepancy
 *         from sage.combinat.composition import Compositions             # <<<<<<<<<<<<<<
 *         D = {}
 *         for c in Compositions(length, length=3, min_part=1):
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_Compositions);
  __Pyx_GIVEREF(__pyx_n_s_Compositions);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Compositions);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_sage_combinat_composition, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Compositions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_Compositions = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1570
 *         from finite_word import discrepancy
 *         from sage.combinat.composition import Compositions
 *         D = {}             # <<<<<<<<<<<<<<
 *         for c in Compositions(length, length=3, min_part=1):
 *             w = self.s_adic_word(c)
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1570, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_D = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1571
 *         from sage.combinat.composition import Compositions
 *         D = {}
 *         for c in Compositions(length, length=3, min_part=1):             # <<<<<<<<<<<<<<
 *             w = self.s_adic_word(c)
 *             if c != w.abelian_vector():
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_length);
  __Pyx_GIVEREF(__pyx_v_length);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_length);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_length, __pyx_int_3) < 0) __PYX_ERR(0, 1571, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_min_part, __pyx_int_1) < 0) __PYX_ERR(0, 1571, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_Compositions, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1571, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1571, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1571, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1571, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1571, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1571, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1571, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "slabbe/mult_cont_frac.pyx":1572
 *         D = {}
 *         for c in Compositions(length, length=3, min_part=1):
 *             w = self.s_adic_word(c)             # <<<<<<<<<<<<<<
 *             if c != w.abelian_vector():
 *                 raise ValueError("c={} but vector is"
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_s_adic_word); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_c); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1572, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1572, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_c);
      __Pyx_GIVEREF(__pyx_v_c);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_c);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1572, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_w, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "slabbe/mult_cont_frac.pyx":1573
 *         for c in Compositions(length, length=3, min_part=1):
 *             w = self.s_adic_word(c)
 *             if c != w.abelian_vector():             # <<<<<<<<<<<<<<
 *                 raise ValueError("c={} but vector is"
 *                       " {}".format(c,w.abelian_vector()))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_w, __pyx_n_s_abelian_vector); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1573, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1573, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_c, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1573, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1573, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {

      /* "slabbe/mult_cont_frac.pyx":1575
 *             if c != w.abelian_vector():
 *                 raise ValueError("c={} but vector is"
 *                       " {}".format(c,w.abelian_vector()))             # <<<<<<<<<<<<<<
 *             D[c] = discrepancy(w)
 *         return D
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_c_but_vector_is, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_w, __pyx_n_s_abelian_vector); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_9) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1575, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1575, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_10 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_c);
      __Pyx_GIVEREF(__pyx_v_c);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_10, __pyx_v_c);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_10, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "slabbe/mult_cont_frac.pyx":1574
 *             w = self.s_adic_word(c)
 *             if c != w.abelian_vector():
 *                 raise ValueError("c={} but vector is"             # <<<<<<<<<<<<<<
 *                       " {}".format(c,w.abelian_vector()))
 *             D[c] = discrepancy(w)
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1574, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1574, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 1574, __pyx_L1_error)

      /* "slabbe/mult_cont_frac.pyx":1573
 *         for c in Compositions(length, length=3, min_part=1):
 *             w = self.s_adic_word(c)
 *             if c != w.abelian_vector():             # <<<<<<<<<<<<<<
 *                 raise ValueError("c={} but vector is"
 *                       " {}".format(c,w.abelian_vector()))
 */
    }

    /* "slabbe/mult_cont_frac.pyx":1576
 *                 raise ValueError("c={} but vector is"
 *                       " {}".format(c,w.abelian_vector()))
 *             D[c] = discrepancy(w)             # <<<<<<<<<<<<<<
 *         return D
 * 
 */
    __Pyx_INCREF(__pyx_v_discrepancy);
    __pyx_t_3 = __pyx_v_discrepancy; __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_w); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1576, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1576, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL;
      __Pyx_INCREF(__pyx_v_w);
      __Pyx_GIVEREF(__pyx_v_w);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_w);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1576, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_D, __pyx_v_c, __pyx_t_1) < 0)) __PYX_ERR(0, 1576, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "slabbe/mult_cont_frac.pyx":1571
 *         from sage.combinat.composition import Compositions
 *         D = {}
 *         for c in Compositions(length, length=3, min_part=1):             # <<<<<<<<<<<<<<
 *             w = self.s_adic_word(c)
 *             if c != w.abelian_vector():
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1577
 *                       " {}".format(c,w.abelian_vector()))
 *             D[c] = discrepancy(w)
 *         return D             # <<<<<<<<<<<<<<
 * 
 *     def e_one_star_patch(self, v, n):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_D);
  __pyx_r = __pyx_v_D;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":1545
 *             return words.s_adic(S, L, D)
 * 
 *     def discrepancy_statistics(self, length):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the discrepancy of words of given length.
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.discrepancy_statistics", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_discrepancy);
  __Pyx_XDECREF(__pyx_v_Compositions);
  __Pyx_XDECREF(__pyx_v_D);
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XDECREF(__pyx_v_w);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1579
 *         return D
 * 
 *     def e_one_star_patch(self, v, n):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the n-th iterated patch of normal vector v.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_54e_one_star_patch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_53e_one_star_patch[] = "\n        Return the n-th iterated patch of normal vector v.\n\n        INPUT:\n\n        - ``v`` -- vector, the normal vector\n        - ``n`` -- integer\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import FullySubtractive\n            sage: FullySubtractive().e_one_star_patch((1,e,pi), 4)\n            Patch of 21 faces\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_54e_one_star_patch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_v = 0;
  PyObject *__pyx_v_n = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("e_one_star_patch (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_v,&__pyx_n_s_n,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("e_one_star_patch", 1, 2, 2, 1); __PYX_ERR(0, 1579, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "e_one_star_patch") < 0)) __PYX_ERR(0, 1579, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_v = values[0];
    __pyx_v_n = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("e_one_star_patch", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1579, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.e_one_star_patch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_53e_one_star_patch(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_v, __pyx_v_n);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_16e_one_star_patch_2generator6(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "slabbe/mult_cont_frac.pyx":1601
 *         keys = [next(it) for _ in range(n)]
 *         D = self.dual_substitutions()
 *         L = prod(D[key] for key in reversed(keys))             # <<<<<<<<<<<<<<
 *         dual_sub = E1Star(L)
 *         cube = Patch([Face((1,0,0),1), Face((0,1,0),2), Face((0,0,1),3)])
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_16e_one_star_patch_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_16e_one_star_patch_2generator6, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_e_one_star_patch_locals_genexpr); if (unlikely(!gen)) __PYX_ERR(0, 1601, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.e_one_star_patch.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_16e_one_star_patch_2generator6(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *__pyx_cur_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1601, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_keys)) { __Pyx_RaiseClosureNameError("keys"); __PYX_ERR(0, 1601, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_keys == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 1601, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_keys; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1) - 1;
  for (;;) {
    if (__pyx_t_2 < 0) break;
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2--; if (unlikely(0 < 0)) __PYX_ERR(0, 1601, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2--; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_D)) { __Pyx_RaiseClosureNameError("D"); __PYX_ERR(0, 1601, __pyx_L1_error) }
    __pyx_t_3 = PyObject_GetItem(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_D, __pyx_cur_scope->__pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1601, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1579
 *         return D
 * 
 *     def e_one_star_patch(self, v, n):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the n-th iterated patch of normal vector v.
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_53e_one_star_patch(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_v, PyObject *__pyx_v_n) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *__pyx_cur_scope;
  PyObject *__pyx_v_E1Star = NULL;
  PyObject *__pyx_v_Patch = NULL;
  PyObject *__pyx_v_Face = NULL;
  PyObject *__pyx_v_prod = NULL;
  PyObject *__pyx_v_it = NULL;
  PyObject *__pyx_v_L = NULL;
  PyObject *__pyx_v_dual_sub = NULL;
  PyObject *__pyx_v_cube = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_r = NULL;
  __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;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  __Pyx_RefNannySetupContext("e_one_star_patch", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __Pyx_INCREF(__pyx_v_v);

  /* "slabbe/mult_cont_frac.pyx":1594
 *             Patch of 21 faces
 *         """
 *         from sage.combinat.e_one_star import E1Star, Patch, Face             # <<<<<<<<<<<<<<
 *         from sage.misc.misc_c import prod
 *         if v is None:
 */
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_E1Star);
  __Pyx_GIVEREF(__pyx_n_s_E1Star);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_E1Star);
  __Pyx_INCREF(__pyx_n_s_Patch);
  __Pyx_GIVEREF(__pyx_n_s_Patch);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_Patch);
  __Pyx_INCREF(__pyx_n_s_Face);
  __Pyx_GIVEREF(__pyx_n_s_Face);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_Face);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_e_one_star, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_E1Star); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_E1Star = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Patch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_Patch = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Face); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_Face = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1595
 *         """
 *         from sage.combinat.e_one_star import E1Star, Patch, Face
 *         from sage.misc.misc_c import prod             # <<<<<<<<<<<<<<
 *         if v is None:
 *             v = (random(), random(), random())
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1595, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_prod);
  __Pyx_GIVEREF(__pyx_n_s_prod);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_prod);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_sage_misc_misc_c, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1595, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_prod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1595, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_prod = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1596
 *         from sage.combinat.e_one_star import E1Star, Patch, Face
 *         from sage.misc.misc_c import prod
 *         if v is None:             # <<<<<<<<<<<<<<
 *             v = (random(), random(), random())
 *         it = self.coding_iterator(v)
 */
  __pyx_t_3 = (__pyx_v_v == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":1597
 *         from sage.misc.misc_c import prod
 *         if v is None:
 *             v = (random(), random(), random())             # <<<<<<<<<<<<<<
 *         it = self.coding_iterator(v)
 *         keys = [next(it) for _ in range(n)]
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1597, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1597, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1597, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1597, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_6) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1597, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1597, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1597, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1597, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1597, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1597, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "slabbe/mult_cont_frac.pyx":1596
 *         from sage.combinat.e_one_star import E1Star, Patch, Face
 *         from sage.misc.misc_c import prod
 *         if v is None:             # <<<<<<<<<<<<<<
 *             v = (random(), random(), random())
 *         it = self.coding_iterator(v)
 */
  }

  /* "slabbe/mult_cont_frac.pyx":1598
 *         if v is None:
 *             v = (random(), random(), random())
 *         it = self.coding_iterator(v)             # <<<<<<<<<<<<<<
 *         keys = [next(it) for _ in range(n)]
 *         D = self.dual_substitutions()
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_coding_iterator); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_v); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_v);
    __Pyx_GIVEREF(__pyx_v_v);
    PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_v);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_it = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "slabbe/mult_cont_frac.pyx":1599
 *             v = (random(), random(), random())
 *         it = self.coding_iterator(v)
 *         keys = [next(it) for _ in range(n)]             # <<<<<<<<<<<<<<
 *         D = self.dual_substitutions()
 *         L = prod(D[key] for key in reversed(keys))
 */
  __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_n);
  __Pyx_GIVEREF(__pyx_v_n);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_n);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_5 = __pyx_t_1; __Pyx_INCREF(__pyx_t_5); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1599, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1599, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1599, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1599, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_9(__pyx_t_5);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1599, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyIter_Next(__pyx_v_it); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 1599, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_keys = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "slabbe/mult_cont_frac.pyx":1600
 *         it = self.coding_iterator(v)
 *         keys = [next(it) for _ in range(n)]
 *         D = self.dual_substitutions()             # <<<<<<<<<<<<<<
 *         L = prod(D[key] for key in reversed(keys))
 *         dual_sub = E1Star(L)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dual_substitutions); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1600, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1600, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1600, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_D = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "slabbe/mult_cont_frac.pyx":1601
 *         keys = [next(it) for _ in range(n)]
 *         D = self.dual_substitutions()
 *         L = prod(D[key] for key in reversed(keys))             # <<<<<<<<<<<<<<
 *         dual_sub = E1Star(L)
 *         cube = Patch([Face((1,0,0),1), Face((0,1,0),2), Face((0,0,1),3)])
 */
  __pyx_t_5 = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_16e_one_star_patch_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_prod);
  __pyx_t_1 = __pyx_v_prod; __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1601, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_L = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "slabbe/mult_cont_frac.pyx":1602
 *         D = self.dual_substitutions()
 *         L = prod(D[key] for key in reversed(keys))
 *         dual_sub = E1Star(L)             # <<<<<<<<<<<<<<
 *         cube = Patch([Face((1,0,0),1), Face((0,1,0),2), Face((0,0,1),3)])
 *         return dual_sub(cube)
 */
  __Pyx_INCREF(__pyx_v_E1Star);
  __pyx_t_1 = __pyx_v_E1Star; __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_L); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
    __Pyx_INCREF(__pyx_v_L);
    __Pyx_GIVEREF(__pyx_v_L);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_L);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dual_sub = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "slabbe/mult_cont_frac.pyx":1603
 *         L = prod(D[key] for key in reversed(keys))
 *         dual_sub = E1Star(L)
 *         cube = Patch([Face((1,0,0),1), Face((0,1,0),2), Face((0,0,1),3)])             # <<<<<<<<<<<<<<
 *         return dual_sub(cube)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_Face, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_v_Face, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_v_Face, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_7);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_7);
  __pyx_t_1 = 0;
  __pyx_t_5 = 0;
  __pyx_t_7 = 0;
  __Pyx_INCREF(__pyx_v_Patch);
  __pyx_t_7 = __pyx_v_Patch; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1603, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1603, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1603, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_cube = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "slabbe/mult_cont_frac.pyx":1604
 *         dual_sub = E1Star(L)
 *         cube = Patch([Face((1,0,0),1), Face((0,1,0),2), Face((0,0,1),3)])
 *         return dual_sub(cube)             # <<<<<<<<<<<<<<
 * 
 *     ######################
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_dual_sub);
  __pyx_t_7 = __pyx_v_dual_sub; __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_cube); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1604, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1604, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
    __Pyx_INCREF(__pyx_v_cube);
    __Pyx_GIVEREF(__pyx_v_cube);
    PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_cube);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1604, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":1579
 *         return D
 * 
 *     def e_one_star_patch(self, v, n):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the n-th iterated patch of normal vector 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_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.e_one_star_patch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_E1Star);
  __Pyx_XDECREF(__pyx_v_Patch);
  __Pyx_XDECREF(__pyx_v_Face);
  __Pyx_XDECREF(__pyx_v_prod);
  __Pyx_XDECREF(__pyx_v_it);
  __Pyx_XDECREF(__pyx_v_L);
  __Pyx_XDECREF(__pyx_v_dual_sub);
  __Pyx_XDECREF(__pyx_v_cube);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1609
 *     # DRAWINGS METHODS (python):
 *     ######################
 *     def invariant_measure_wireframe_plot(self, n_iterations, ndivs, norm='1'):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return a matplotlib graph of the invariant measure.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_56invariant_measure_wireframe_plot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_55invariant_measure_wireframe_plot[] = "\n        Return a matplotlib graph of the invariant measure.\n\n        INPUT:\n\n        - ``n_iterations`` - integer, number of iterations\n        - ``ndvis`` - integer, number of divisions per dimension\n        - ``norm`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit points\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Reverse, Brun\n            sage: Reverse().invariant_measure_wireframe_plot(1000000, 80)\n            <matplotlib.figure.Figure object at ...>\n            sage: Brun().invariant_measure_wireframe_plot(1000000, 40, norm='1')\n            <matplotlib.figure.Figure object at ...>\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_56invariant_measure_wireframe_plot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_n_iterations = 0;
  PyObject *__pyx_v_ndivs = 0;
  PyObject *__pyx_v_norm = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("invariant_measure_wireframe_plot (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,&__pyx_n_s_ndivs,&__pyx_n_s_norm,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_kp_s_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndivs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("invariant_measure_wireframe_plot", 0, 2, 3, 1); __PYX_ERR(0, 1609, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "invariant_measure_wireframe_plot") < 0)) __PYX_ERR(0, 1609, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_n_iterations = values[0];
    __pyx_v_ndivs = values[1];
    __pyx_v_norm = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("invariant_measure_wireframe_plot", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1609, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.invariant_measure_wireframe_plot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_55invariant_measure_wireframe_plot(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations, __pyx_v_ndivs, __pyx_v_norm);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_55invariant_measure_wireframe_plot(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_ndivs, PyObject *__pyx_v_norm) {
  PyObject *__pyx_v_D = NULL;
  PyObject *__pyx_v_the_mean = NULL;
  PyObject *__pyx_v_X = NULL;
  PyObject *__pyx_v_Y = NULL;
  PyObject *__pyx_v_Z = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_axes3d = NULL;
  PyObject *__pyx_v_plt = NULL;
  PyObject *__pyx_v_fig = NULL;
  PyObject *__pyx_v_ax = NULL;
  PyObject *__pyx_v_title = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_i = 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;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("invariant_measure_wireframe_plot", 0);

  /* "slabbe/mult_cont_frac.pyx":1629
 * 
 *         """
 *         D = self._invariant_measure_dict(n_iterations, ndivs, norm=norm)             # <<<<<<<<<<<<<<
 *         the_mean = n_iterations / float(len(D))
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_invariant_measure_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_n_iterations);
  __Pyx_GIVEREF(__pyx_v_n_iterations);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_n_iterations);
  __Pyx_INCREF(__pyx_v_ndivs);
  __Pyx_GIVEREF(__pyx_v_ndivs);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_ndivs);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_norm, __pyx_v_norm) < 0) __PYX_ERR(0, 1629, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_D = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "slabbe/mult_cont_frac.pyx":1630
 *         """
 *         D = self._invariant_measure_dict(n_iterations, ndivs, norm=norm)
 *         the_mean = n_iterations / float(len(D))             # <<<<<<<<<<<<<<
 * 
 *         X = [[i for i in range(ndivs+1)] for j in range(ndivs+1)]
 */
  __pyx_t_5 = PyObject_Length(__pyx_v_D); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 1630, __pyx_L1_error)
  __pyx_t_4 = PyFloat_FromDouble(((double)__pyx_t_5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_v_n_iterations, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_the_mean = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1632
 *         the_mean = n_iterations / float(len(D))
 * 
 *         X = [[i for i in range(ndivs+1)] for j in range(ndivs+1)]             # <<<<<<<<<<<<<<
 *         Y = [[j for i in range(ndivs+1)] for j in range(ndivs+1)]
 *         Z = [[D.get((i,j),0)/the_mean for i in range(ndivs+1)] for j in range(ndivs+1)]
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1632, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1632, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1632, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1632, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1632, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_6(__pyx_t_2);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1632, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_7 = __pyx_t_1; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1632, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1632, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1632, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1632, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1632, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1632, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_9(__pyx_t_7);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1632, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
      __pyx_t_1 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_v_i))) __PYX_ERR(0, 1632, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 1632, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_X = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1633
 * 
 *         X = [[i for i in range(ndivs+1)] for j in range(ndivs+1)]
 *         Y = [[j for i in range(ndivs+1)] for j in range(ndivs+1)]             # <<<<<<<<<<<<<<
 *         Z = [[D.get((i,j),0)/the_mean for i in range(ndivs+1)] for j in range(ndivs+1)]
 * 
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1633, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1633, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1633, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1633, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1633, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1633, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) {
      __pyx_t_1 = __pyx_t_7; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1633, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1633, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1633, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1633, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1633, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1633, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_9(__pyx_t_1);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1633, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_7);
      __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_v_j))) __PYX_ERR(0, 1633, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 1633, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_Y = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1634
 *         X = [[i for i in range(ndivs+1)] for j in range(ndivs+1)]
 *         Y = [[j for i in range(ndivs+1)] for j in range(ndivs+1)]
 *         Z = [[D.get((i,j),0)/the_mean for i in range(ndivs+1)] for j in range(ndivs+1)]             # <<<<<<<<<<<<<<
 * 
 *         from mpl_toolkits.mplot3d import axes3d
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1634, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1634, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1634, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1634, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1634, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_6(__pyx_t_2);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1634, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_7 = __pyx_t_1; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1634, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1634, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1634, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1634, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1634, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_9(__pyx_t_7);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1634, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_D, __pyx_n_s_get); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_v_i);
      __Pyx_GIVEREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_i);
      __Pyx_INCREF(__pyx_v_j);
      __Pyx_GIVEREF(__pyx_v_j);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_j);
      __pyx_t_12 = NULL;
      __pyx_t_13 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
          __pyx_t_13 = 1;
        }
      }
      __pyx_t_14 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      if (__pyx_t_12) {
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_t_11);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_int_0);
      __pyx_t_11 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_v_the_mean); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_10))) __PYX_ERR(0, 1634, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 1634, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_Z = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1636
 *         Z = [[D.get((i,j),0)/the_mean for i in range(ndivs+1)] for j in range(ndivs+1)]
 * 
 *         from mpl_toolkits.mplot3d import axes3d             # <<<<<<<<<<<<<<
 *         import matplotlib.pyplot as plt
 *         fig = plt.figure()
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_axes3d);
  __Pyx_GIVEREF(__pyx_n_s_axes3d);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_axes3d);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_mpl_toolkits_mplot3d, __pyx_t_3, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_axes3d); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_axes3d = __pyx_t_3;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1637
 * 
 *         from mpl_toolkits.mplot3d import axes3d
 *         import matplotlib.pyplot as plt             # <<<<<<<<<<<<<<
 *         fig = plt.figure()
 *         ax = fig.add_subplot(111, projection='3d')
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1637, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s__17);
  __Pyx_GIVEREF(__pyx_n_s__17);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s__17);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_matplotlib_pyplot, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1637, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_plt = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1638
 *         from mpl_toolkits.mplot3d import axes3d
 *         import matplotlib.pyplot as plt
 *         fig = plt.figure()             # <<<<<<<<<<<<<<
 *         ax = fig.add_subplot(111, projection='3d')
 *         ax.plot_wireframe(X, Y, Z, rstride=1, cstride=1)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_figure); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1638, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1638, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_fig = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1639
 *         import matplotlib.pyplot as plt
 *         fig = plt.figure()
 *         ax = fig.add_subplot(111, projection='3d')             # <<<<<<<<<<<<<<
 *         ax.plot_wireframe(X, Y, Z, rstride=1, cstride=1)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_fig, __pyx_n_s_add_subplot); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1639, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1639, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_projection, __pyx_kp_s_3d) < 0) __PYX_ERR(0, 1639, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__18, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1639, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_ax = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "slabbe/mult_cont_frac.pyx":1640
 *         fig = plt.figure()
 *         ax = fig.add_subplot(111, projection='3d')
 *         ax.plot_wireframe(X, Y, Z, rstride=1, cstride=1)             # <<<<<<<<<<<<<<
 * 
 *         ax.text(ndivs, 0, 0, "$(1,0,0)$", color='black', va='top', size=20)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_ax, __pyx_n_s_plot_wireframe); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1640, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1640, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_X);
  __Pyx_GIVEREF(__pyx_v_X);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_X);
  __Pyx_INCREF(__pyx_v_Y);
  __Pyx_GIVEREF(__pyx_v_Y);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_Y);
  __Pyx_INCREF(__pyx_v_Z);
  __Pyx_GIVEREF(__pyx_v_Z);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_Z);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1640, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rstride, __pyx_int_1) < 0) __PYX_ERR(0, 1640, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_cstride, __pyx_int_1) < 0) __PYX_ERR(0, 1640, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1640, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "slabbe/mult_cont_frac.pyx":1642
 *         ax.plot_wireframe(X, Y, Z, rstride=1, cstride=1)
 * 
 *         ax.text(ndivs, 0, 0, "$(1,0,0)$", color='black', va='top', size=20)             # <<<<<<<<<<<<<<
 *         ax.text(0, ndivs, 0, "$(0,1,0)$", color='black', ha='left', size=20)
 *         ax.text(0, 0, 0, "$(0,0,1)$", color='black', ha='right', size=20)
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_ax, __pyx_n_s_text); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_ndivs);
  __Pyx_GIVEREF(__pyx_v_ndivs);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ndivs);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_0);
  __Pyx_INCREF(__pyx_kp_s_1_0_0);
  __Pyx_GIVEREF(__pyx_kp_s_1_0_0);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_kp_s_1_0_0);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_color, __pyx_n_s_black) < 0) __PYX_ERR(0, 1642, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_va, __pyx_n_s_top) < 0) __PYX_ERR(0, 1642, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_size, __pyx_int_20) < 0) __PYX_ERR(0, 1642, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "slabbe/mult_cont_frac.pyx":1643
 * 
 *         ax.text(ndivs, 0, 0, "$(1,0,0)$", color='black', va='top', size=20)
 *         ax.text(0, ndivs, 0, "$(0,1,0)$", color='black', ha='left', size=20)             # <<<<<<<<<<<<<<
 *         ax.text(0, 0, 0, "$(0,0,1)$", color='black', ha='right', size=20)
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_ax, __pyx_n_s_text); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0);
  __Pyx_INCREF(__pyx_v_ndivs);
  __Pyx_GIVEREF(__pyx_v_ndivs);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_ndivs);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_0);
  __Pyx_INCREF(__pyx_kp_s_0_1_0);
  __Pyx_GIVEREF(__pyx_kp_s_0_1_0);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_kp_s_0_1_0);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_color, __pyx_n_s_black) < 0) __PYX_ERR(0, 1643, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ha, __pyx_n_s_left) < 0) __PYX_ERR(0, 1643, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_size, __pyx_int_20) < 0) __PYX_ERR(0, 1643, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "slabbe/mult_cont_frac.pyx":1644
 *         ax.text(ndivs, 0, 0, "$(1,0,0)$", color='black', va='top', size=20)
 *         ax.text(0, ndivs, 0, "$(0,1,0)$", color='black', ha='left', size=20)
 *         ax.text(0, 0, 0, "$(0,0,1)$", color='black', ha='right', size=20)             # <<<<<<<<<<<<<<
 * 
 *         ax.set_xticklabels([])
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_ax, __pyx_n_s_text); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_color, __pyx_n_s_black) < 0) __PYX_ERR(0, 1644, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ha, __pyx_n_s_right) < 0) __PYX_ERR(0, 1644, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_size, __pyx_int_20) < 0) __PYX_ERR(0, 1644, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__19, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1646
 *         ax.text(0, 0, 0, "$(0,0,1)$", color='black', ha='right', size=20)
 * 
 *         ax.set_xticklabels([])             # <<<<<<<<<<<<<<
 *         ax.set_yticklabels([])
 *         ax.set_zlabel('Frequency')
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_ax, __pyx_n_s_set_xticklabels); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1646, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1646, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1646, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1647
 * 
 *         ax.set_xticklabels([])
 *         ax.set_yticklabels([])             # <<<<<<<<<<<<<<
 *         ax.set_zlabel('Frequency')
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_ax, __pyx_n_s_set_yticklabels); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1647, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1647, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1647, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1647, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7); __pyx_t_7 = NULL;
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1647, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1648
 *         ax.set_xticklabels([])
 *         ax.set_yticklabels([])
 *         ax.set_zlabel('Frequency')             # <<<<<<<<<<<<<<
 * 
 *         title = "Density of an orbit for\n{} algorithm".format(self.name())
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ax, __pyx_n_s_set_zlabel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1648, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1648, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1650
 *         ax.set_zlabel('Frequency')
 * 
 *         title = "Density of an orbit for\n{} algorithm".format(self.name())             # <<<<<<<<<<<<<<
 *         ax.set_title(title)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Density_of_an_orbit_for_algorith, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1650, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1650, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (__pyx_t_7) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1650, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1650, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_10) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1650, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1650, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10); __pyx_t_10 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1650, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_title = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1651
 * 
 *         title = "Density of an orbit for\n{} algorithm".format(self.name())
 *         ax.set_title(title)             # <<<<<<<<<<<<<<
 * 
 *         return fig
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ax, __pyx_n_s_set_title); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1651, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_title); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7); __pyx_t_7 = NULL;
    __Pyx_INCREF(__pyx_v_title);
    __Pyx_GIVEREF(__pyx_v_title);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_title);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1653
 *         ax.set_title(title)
 * 
 *         return fig             # <<<<<<<<<<<<<<
 * 
 *     def invariant_measure_contour_plot(self, n_iterations, ndivs, norm='1'):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_fig);
  __pyx_r = __pyx_v_fig;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":1609
 *     # DRAWINGS METHODS (python):
 *     ######################
 *     def invariant_measure_wireframe_plot(self, n_iterations, ndivs, norm='1'):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return a matplotlib graph of the invariant measure.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.invariant_measure_wireframe_plot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_D);
  __Pyx_XDECREF(__pyx_v_the_mean);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XDECREF(__pyx_v_Y);
  __Pyx_XDECREF(__pyx_v_Z);
  __Pyx_XDECREF(__pyx_v_axes3d);
  __Pyx_XDECREF(__pyx_v_plt);
  __Pyx_XDECREF(__pyx_v_fig);
  __Pyx_XDECREF(__pyx_v_ax);
  __Pyx_XDECREF(__pyx_v_title);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1655
 *         return fig
 * 
 *     def invariant_measure_contour_plot(self, n_iterations, ndivs, norm='1'):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return a matplotlib graph of the invariant measure.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_58invariant_measure_contour_plot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_57invariant_measure_contour_plot[] = "\n        Return a matplotlib graph of the invariant measure.\n\n        INPUT:\n\n        - ``n_iterations`` - integer, number of iterations\n        - ``ndvis`` - integer, number of divisions per dimension\n        - ``norm`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit points\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Reverse, Brun\n            sage: Reverse().invariant_measure_contour_plot(1000000, 80)\n            <matplotlib.figure.Figure object at ...>\n            sage: Brun().invariant_measure_contour_plot(1000000, 40, norm='1')\n            <matplotlib.figure.Figure object at ...>\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_58invariant_measure_contour_plot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_n_iterations = 0;
  PyObject *__pyx_v_ndivs = 0;
  PyObject *__pyx_v_norm = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("invariant_measure_contour_plot (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,&__pyx_n_s_ndivs,&__pyx_n_s_norm,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_kp_s_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndivs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("invariant_measure_contour_plot", 0, 2, 3, 1); __PYX_ERR(0, 1655, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "invariant_measure_contour_plot") < 0)) __PYX_ERR(0, 1655, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_n_iterations = values[0];
    __pyx_v_ndivs = values[1];
    __pyx_v_norm = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("invariant_measure_contour_plot", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1655, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.invariant_measure_contour_plot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_57invariant_measure_contour_plot(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations, __pyx_v_ndivs, __pyx_v_norm);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_57invariant_measure_contour_plot(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_ndivs, PyObject *__pyx_v_norm) {
  PyObject *__pyx_v_D = NULL;
  PyObject *__pyx_v_the_mean = NULL;
  PyObject *__pyx_v_S = NULL;
  PyObject *__pyx_v_V = NULL;
  PyObject *__pyx_v_X = NULL;
  PyObject *__pyx_v_Y = NULL;
  PyObject *__pyx_v_Z = NULL;
  PyObject *__pyx_v_plt = NULL;
  PyObject *__pyx_v_fig = NULL;
  PyObject *__pyx_v_ax = NULL;
  PyObject *__pyx_v_CS = NULL;
  PyObject *__pyx_v_title = NULL;
  Py_ssize_t __pyx_v_k;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_i = 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;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  Py_ssize_t __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("invariant_measure_contour_plot", 0);

  /* "slabbe/mult_cont_frac.pyx":1675
 * 
 *         """
 *         D = self._invariant_measure_dict(n_iterations, ndivs, norm=norm)             # <<<<<<<<<<<<<<
 *         the_mean = n_iterations / float(len(D))
 *         S = sorted(D.values())
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_invariant_measure_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_n_iterations);
  __Pyx_GIVEREF(__pyx_v_n_iterations);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_n_iterations);
  __Pyx_INCREF(__pyx_v_ndivs);
  __Pyx_GIVEREF(__pyx_v_ndivs);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_ndivs);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_norm, __pyx_v_norm) < 0) __PYX_ERR(0, 1675, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_D = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "slabbe/mult_cont_frac.pyx":1676
 *         """
 *         D = self._invariant_measure_dict(n_iterations, ndivs, norm=norm)
 *         the_mean = n_iterations / float(len(D))             # <<<<<<<<<<<<<<
 *         S = sorted(D.values())
 *         V = [S[k]/the_mean for k in range(0, len(D), len(D)/10)]
 */
  __pyx_t_5 = PyObject_Length(__pyx_v_D); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 1676, __pyx_L1_error)
  __pyx_t_4 = PyFloat_FromDouble(((double)__pyx_t_5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1676, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_v_n_iterations, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1676, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_the_mean = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1677
 *         D = self._invariant_measure_dict(n_iterations, ndivs, norm=norm)
 *         the_mean = n_iterations / float(len(D))
 *         S = sorted(D.values())             # <<<<<<<<<<<<<<
 *         V = [S[k]/the_mean for k in range(0, len(D), len(D)/10)]
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_D, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1677, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1677, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1677, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1677, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_6 = PyList_Sort(__pyx_t_3); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 1677, __pyx_L1_error)
  __pyx_v_S = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1678
 *         the_mean = n_iterations / float(len(D))
 *         S = sorted(D.values())
 *         V = [S[k]/the_mean for k in range(0, len(D), len(D)/10)]             # <<<<<<<<<<<<<<
 * 
 *         X = [[i for i in range(ndivs+1)] for j in range(ndivs+1)]
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyObject_Length(__pyx_v_D); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 1678, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyObject_Length(__pyx_v_D); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 1678, __pyx_L1_error)
  __pyx_t_4 = PyInt_FromSsize_t(__Pyx_div_Py_ssize_t(__pyx_t_5, 10)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_1 = __pyx_t_4; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1678, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1678, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1678, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1678, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1678, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1678, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1678, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1678, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_k = __pyx_t_8;
    if (unlikely(__pyx_v_S == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1678, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_S, __pyx_v_k, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1678, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v_the_mean); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1678, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 1678, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_V = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1680
 *         V = [S[k]/the_mean for k in range(0, len(D), len(D)/10)]
 * 
 *         X = [[i for i in range(ndivs+1)] for j in range(ndivs+1)]             # <<<<<<<<<<<<<<
 *         Y = [[j for i in range(ndivs+1)] for j in range(ndivs+1)]
 *         Z = [[D.get((i,j),0)/the_mean for i in range(ndivs+1)] for j in range(ndivs+1)]
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1680, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1680, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1680, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1680, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1680, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_7(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1680, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1680, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
      __pyx_t_9 = __pyx_t_4; __Pyx_INCREF(__pyx_t_9); __pyx_t_8 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1680, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1680, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (likely(!__pyx_t_10)) {
        if (likely(PyList_CheckExact(__pyx_t_9))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_9)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1680, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_9, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1680, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1680, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_9, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1680, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_10(__pyx_t_9);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1680, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
      __pyx_t_4 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_i))) __PYX_ERR(0, 1680, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 1680, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_X = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1681
 * 
 *         X = [[i for i in range(ndivs+1)] for j in range(ndivs+1)]
 *         Y = [[j for i in range(ndivs+1)] for j in range(ndivs+1)]             # <<<<<<<<<<<<<<
 *         Z = [[D.get((i,j),0)/the_mean for i in range(ndivs+1)] for j in range(ndivs+1)]
 * 
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1681, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1681, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1681, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1681, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1681, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1681, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (likely(PyList_CheckExact(__pyx_t_9)) || PyTuple_CheckExact(__pyx_t_9)) {
      __pyx_t_4 = __pyx_t_9; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1681, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1681, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    for (;;) {
      if (likely(!__pyx_t_10)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_9); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1681, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1681, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_9); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1681, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1681, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_10(__pyx_t_4);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1681, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_9);
      __pyx_t_9 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_v_j))) __PYX_ERR(0, 1681, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 1681, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_Y = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1682
 *         X = [[i for i in range(ndivs+1)] for j in range(ndivs+1)]
 *         Y = [[j for i in range(ndivs+1)] for j in range(ndivs+1)]
 *         Z = [[D.get((i,j),0)/the_mean for i in range(ndivs+1)] for j in range(ndivs+1)]             # <<<<<<<<<<<<<<
 * 
 *         import matplotlib.pyplot as plt
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1682, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1682, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1682, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1682, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1682, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_7(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1682, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_ndivs, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
      __pyx_t_9 = __pyx_t_4; __Pyx_INCREF(__pyx_t_9); __pyx_t_8 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1682, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1682, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (likely(!__pyx_t_10)) {
        if (likely(PyList_CheckExact(__pyx_t_9))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_9)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1682, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_9, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1682, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1682, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_9, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1682, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_10(__pyx_t_9);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1682, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_D, __pyx_n_s_get); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1682, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1682, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_i);
      __Pyx_GIVEREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_i);
      __Pyx_INCREF(__pyx_v_j);
      __Pyx_GIVEREF(__pyx_v_j);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_j);
      __pyx_t_13 = NULL;
      __pyx_t_14 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
          __pyx_t_14 = 1;
        }
      }
      __pyx_t_15 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1682, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      if (__pyx_t_13) {
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_t_12);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_int_0);
      __pyx_t_12 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_15, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1682, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v_the_mean); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1682, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 1682, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_Z = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1684
 *         Z = [[D.get((i,j),0)/the_mean for i in range(ndivs+1)] for j in range(ndivs+1)]
 * 
 *         import matplotlib.pyplot as plt             # <<<<<<<<<<<<<<
 *         fig = plt.figure()
 *         ax = fig.add_subplot(111)
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s__17);
  __Pyx_GIVEREF(__pyx_n_s__17);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s__17);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_matplotlib_pyplot, __pyx_t_3, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_plt = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1685
 * 
 *         import matplotlib.pyplot as plt
 *         fig = plt.figure()             # <<<<<<<<<<<<<<
 *         ax = fig.add_subplot(111)
 *         CS = plt.contour(X, Y, Z, V)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_figure); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1685, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1685, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_fig = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1686
 *         import matplotlib.pyplot as plt
 *         fig = plt.figure()
 *         ax = fig.add_subplot(111)             # <<<<<<<<<<<<<<
 *         CS = plt.contour(X, Y, Z, V)
 *         plt.clabel(CS, inline=1, fontsize=10)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_fig, __pyx_n_s_add_subplot); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_ax = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1687
 *         fig = plt.figure()
 *         ax = fig.add_subplot(111)
 *         CS = plt.contour(X, Y, Z, V)             # <<<<<<<<<<<<<<
 *         plt.clabel(CS, inline=1, fontsize=10)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_contour); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1687, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_9 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1687, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (__pyx_t_1) {
    __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __pyx_t_1 = NULL;
  }
  __Pyx_INCREF(__pyx_v_X);
  __Pyx_GIVEREF(__pyx_v_X);
  PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_5, __pyx_v_X);
  __Pyx_INCREF(__pyx_v_Y);
  __Pyx_GIVEREF(__pyx_v_Y);
  PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_5, __pyx_v_Y);
  __Pyx_INCREF(__pyx_v_Z);
  __Pyx_GIVEREF(__pyx_v_Z);
  PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_5, __pyx_v_Z);
  __Pyx_INCREF(__pyx_v_V);
  __Pyx_GIVEREF(__pyx_v_V);
  PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_5, __pyx_v_V);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1687, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_CS = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1688
 *         ax = fig.add_subplot(111)
 *         CS = plt.contour(X, Y, Z, V)
 *         plt.clabel(CS, inline=1, fontsize=10)             # <<<<<<<<<<<<<<
 * 
 *         title = "Density of an orbit for\n{} algorithm".format(self.name())
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_clabel); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_CS);
  __Pyx_GIVEREF(__pyx_v_CS);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_CS);
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_inline, __pyx_int_1) < 0) __PYX_ERR(0, 1688, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_fontsize, __pyx_int_10) < 0) __PYX_ERR(0, 1688, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1690
 *         plt.clabel(CS, inline=1, fontsize=10)
 * 
 *         title = "Density of an orbit for\n{} algorithm".format(self.name())             # <<<<<<<<<<<<<<
 *         ax.set_title(title)
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Density_of_an_orbit_for_algorith, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1690, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1690, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_11 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_11) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1690, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1690, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1690, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1690, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1690, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_title = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1691
 * 
 *         title = "Density of an orbit for\n{} algorithm".format(self.name())
 *         ax.set_title(title)             # <<<<<<<<<<<<<<
 * 
 *         return fig
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_ax, __pyx_n_s_set_title); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1691, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_11 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_11) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_title); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_11); __pyx_t_11 = NULL;
    __Pyx_INCREF(__pyx_v_title);
    __Pyx_GIVEREF(__pyx_v_title);
    PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_title);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1693
 *         ax.set_title(title)
 * 
 *         return fig             # <<<<<<<<<<<<<<
 * 
 *     def natural_extension_plot(self, n_iterations, norm_xyz='1',
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_fig);
  __pyx_r = __pyx_v_fig;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":1655
 *         return fig
 * 
 *     def invariant_measure_contour_plot(self, n_iterations, ndivs, norm='1'):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return a matplotlib graph of the invariant measure.
 */

  /* 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_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.invariant_measure_contour_plot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_D);
  __Pyx_XDECREF(__pyx_v_the_mean);
  __Pyx_XDECREF(__pyx_v_S);
  __Pyx_XDECREF(__pyx_v_V);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XDECREF(__pyx_v_Y);
  __Pyx_XDECREF(__pyx_v_Z);
  __Pyx_XDECREF(__pyx_v_plt);
  __Pyx_XDECREF(__pyx_v_fig);
  __Pyx_XDECREF(__pyx_v_ax);
  __Pyx_XDECREF(__pyx_v_CS);
  __Pyx_XDECREF(__pyx_v_title);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1695
 *         return fig
 * 
 *     def natural_extension_plot(self, n_iterations, norm_xyz='1',             # <<<<<<<<<<<<<<
 *             norm_uvw='1', axis_off=False):
 *         r"""
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_60natural_extension_plot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_59natural_extension_plot[] = "\n        INPUT:\n\n        - ``n_iterations`` - integer, number of iterations\n        - ``norm_xyz`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit points\n        - ``norm_uvw`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the dual orbit points\n        - ``axis_off`` - boolean (default: ``False``), \n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Sorted_ARP\n            sage: Sorted_ARP().natural_extension_plot(1000)\n            <matplotlib.figure.Figure object at ...>\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_60natural_extension_plot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_n_iterations = 0;
  PyObject *__pyx_v_norm_xyz = 0;
  PyObject *__pyx_v_norm_uvw = 0;
  PyObject *__pyx_v_axis_off = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("natural_extension_plot (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,&__pyx_n_s_norm_xyz,&__pyx_n_s_norm_uvw,&__pyx_n_s_axis_off,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)__pyx_kp_s_1);
    values[2] = ((PyObject *)__pyx_kp_s_1);

    /* "slabbe/mult_cont_frac.pyx":1696
 * 
 *     def natural_extension_plot(self, n_iterations, norm_xyz='1',
 *             norm_uvw='1', axis_off=False):             # <<<<<<<<<<<<<<
 *         r"""
 *         INPUT:
 */
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_xyz);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_uvw);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axis_off);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "natural_extension_plot") < 0)) __PYX_ERR(0, 1695, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_n_iterations = values[0];
    __pyx_v_norm_xyz = values[1];
    __pyx_v_norm_uvw = values[2];
    __pyx_v_axis_off = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("natural_extension_plot", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1695, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_plot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_59natural_extension_plot(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations, __pyx_v_norm_xyz, __pyx_v_norm_uvw, __pyx_v_axis_off);

  /* "slabbe/mult_cont_frac.pyx":1695
 *         return fig
 * 
 *     def natural_extension_plot(self, n_iterations, norm_xyz='1',             # <<<<<<<<<<<<<<
 *             norm_uvw='1', axis_off=False):
 *         r"""
 */

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

/* "slabbe/mult_cont_frac.pyx":1720
 *         c = dict(zip(domain_left.keys(), ['b','r','g','c','m','y','k']))
 * 
 *         def create_sub_plot(axx, D, title, norm):             # <<<<<<<<<<<<<<
 *             for key, value in D.iteritems():
 *                 value = D[key]
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_22natural_extension_plot_1create_sub_plot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6slabbe_14mult_cont_frac_12MCFAlgorithm_22natural_extension_plot_1create_sub_plot = {"create_sub_plot", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_22natural_extension_plot_1create_sub_plot, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_22natural_extension_plot_1create_sub_plot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axx = 0;
  PyObject *__pyx_v_D = 0;
  PyObject *__pyx_v_title = 0;
  CYTHON_UNUSED PyObject *__pyx_v_norm = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_sub_plot (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_axx,&__pyx_n_s_D,&__pyx_n_s_title,&__pyx_n_s_norm,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_axx)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_D)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_sub_plot", 1, 4, 4, 1); __PYX_ERR(0, 1720, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_title)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_sub_plot", 1, 4, 4, 2); __PYX_ERR(0, 1720, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_sub_plot", 1, 4, 4, 3); __PYX_ERR(0, 1720, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_sub_plot") < 0)) __PYX_ERR(0, 1720, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_axx = values[0];
    __pyx_v_D = values[1];
    __pyx_v_title = values[2];
    __pyx_v_norm = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_sub_plot", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1720, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_plot.create_sub_plot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_22natural_extension_plot_create_sub_plot(__pyx_self, __pyx_v_axx, __pyx_v_D, __pyx_v_title, __pyx_v_norm);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_22natural_extension_plot_create_sub_plot(PyObject *__pyx_self, PyObject *__pyx_v_axx, PyObject *__pyx_v_D, PyObject *__pyx_v_title, CYTHON_UNUSED PyObject *__pyx_v_norm) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *__pyx_cur_scope;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *__pyx_outer_scope;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_X = NULL;
  PyObject *__pyx_v_Y = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_A = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  __Pyx_RefNannySetupContext("create_sub_plot", 0);
  __pyx_outer_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "slabbe/mult_cont_frac.pyx":1721
 * 
 *         def create_sub_plot(axx, D, title, norm):
 *             for key, value in D.iteritems():             # <<<<<<<<<<<<<<
 *                 value = D[key]
 *                 X,Y = zip(*value)
 */
  __pyx_t_2 = 0;
  if (unlikely(__pyx_v_D == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    __PYX_ERR(0, 1721, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_D, 0, __pyx_n_s_iteritems, (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1721, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "slabbe/mult_cont_frac.pyx":1722
 *         def create_sub_plot(axx, D, title, norm):
 *             for key, value in D.iteritems():
 *                 value = D[key]             # <<<<<<<<<<<<<<
 *                 X,Y = zip(*value)
 *                 A = axx.plot(X, Y, 'o', markersize=2, color=c[key], label=key)
 */
    __pyx_t_6 = PyObject_GetItem(__pyx_v_D, __pyx_v_key); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "slabbe/mult_cont_frac.pyx":1723
 *             for key, value in D.iteritems():
 *                 value = D[key]
 *                 X,Y = zip(*value)             # <<<<<<<<<<<<<<
 *                 A = axx.plot(X, Y, 'o', markersize=2, color=c[key], label=key)
 *             axx.legend(markerscale=3,fontsize="xx-small")
 */
    __pyx_t_6 = PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1723, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1723, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
      PyObject* sequence = __pyx_t_5;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 1723, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_8);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1723, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1723, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1723, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 1723, __pyx_L1_error)
      __pyx_t_10 = NULL;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 1723, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_Y, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "slabbe/mult_cont_frac.pyx":1724
 *                 value = D[key]
 *                 X,Y = zip(*value)
 *                 A = axx.plot(X, Y, 'o', markersize=2, color=c[key], label=key)             # <<<<<<<<<<<<<<
 *             axx.legend(markerscale=3,fontsize="xx-small")
 *             axx.set_title(title)
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_axx, __pyx_n_s_plot); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_X);
    __Pyx_GIVEREF(__pyx_v_X);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_X);
    __Pyx_INCREF(__pyx_v_Y);
    __Pyx_GIVEREF(__pyx_v_Y);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_Y);
    __Pyx_INCREF(__pyx_n_s_o);
    __Pyx_GIVEREF(__pyx_n_s_o);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_n_s_o);
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_markersize, __pyx_int_2) < 0) __PYX_ERR(0, 1724, __pyx_L1_error)
    if (unlikely(!__pyx_cur_scope->__pyx_v_c)) { __Pyx_RaiseClosureNameError("c"); __PYX_ERR(0, 1724, __pyx_L1_error) }
    if (unlikely(__pyx_cur_scope->__pyx_v_c == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1724, __pyx_L1_error)
    }
    __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_cur_scope->__pyx_v_c, __pyx_v_key); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_color, __pyx_t_9) < 0) __PYX_ERR(0, 1724, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_label, __pyx_v_key) < 0) __PYX_ERR(0, 1724, __pyx_L1_error)
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_A, __pyx_t_9);
    __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1725
 *                 X,Y = zip(*value)
 *                 A = axx.plot(X, Y, 'o', markersize=2, color=c[key], label=key)
 *             axx.legend(markerscale=3,fontsize="xx-small")             # <<<<<<<<<<<<<<
 *             axx.set_title(title)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_axx, __pyx_n_s_legend); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_markerscale, __pyx_int_3) < 0) __PYX_ERR(0, 1725, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_fontsize, __pyx_kp_s_xx_small) < 0) __PYX_ERR(0, 1725, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "slabbe/mult_cont_frac.pyx":1726
 *                 A = axx.plot(X, Y, 'o', markersize=2, color=c[key], label=key)
 *             axx.legend(markerscale=3,fontsize="xx-small")
 *             axx.set_title(title)             # <<<<<<<<<<<<<<
 * 
 *         fig, (ax,bx,cx,dx) = plt.subplots(1,4,sharex=True,sharey=True)
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_axx, __pyx_n_s_set_title); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_title); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1726, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1726, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __pyx_t_1 = NULL;
    __Pyx_INCREF(__pyx_v_title);
    __Pyx_GIVEREF(__pyx_v_title);
    PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_title);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1726, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "slabbe/mult_cont_frac.pyx":1720
 *         c = dict(zip(domain_left.keys(), ['b','r','g','c','m','y','k']))
 * 
 *         def create_sub_plot(axx, D, title, norm):             # <<<<<<<<<<<<<<
 *             for key, value in D.iteritems():
 *                 value = D[key]
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_plot.create_sub_plot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XDECREF(__pyx_v_Y);
  __Pyx_XDECREF(__pyx_v_A);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1695
 *         return fig
 * 
 *     def natural_extension_plot(self, n_iterations, norm_xyz='1',             # <<<<<<<<<<<<<<
 *             norm_uvw='1', axis_off=False):
 *         r"""
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_59natural_extension_plot(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_axis_off) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *__pyx_cur_scope;
  CYTHON_UNUSED PyObject *__pyx_v_matplotlib = NULL;
  PyObject *__pyx_v_plt = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_domain_left = NULL;
  PyObject *__pyx_v_image_left = NULL;
  PyObject *__pyx_v_domain_right = NULL;
  PyObject *__pyx_v_image_right = NULL;
  PyObject *__pyx_v_create_sub_plot = 0;
  PyObject *__pyx_v_fig = NULL;
  PyObject *__pyx_v_ax = NULL;
  PyObject *__pyx_v_bx = NULL;
  PyObject *__pyx_v_cx = NULL;
  PyObject *__pyx_v_dx = NULL;
  PyObject *__pyx_v_title = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("natural_extension_plot", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);

  /* "slabbe/mult_cont_frac.pyx":1713
 *             <matplotlib.figure.Figure object at ...>
 *         """
 *         import matplotlib             # <<<<<<<<<<<<<<
 *         import matplotlib.pyplot as plt
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_matplotlib, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_matplotlib = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1714
 *         """
 *         import matplotlib
 *         import matplotlib.pyplot as plt             # <<<<<<<<<<<<<<
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,
 *                 norm_uvw=norm_uvw)
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s__17);
  __Pyx_GIVEREF(__pyx_n_s__17);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s__17);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_matplotlib_pyplot, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_plt = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1715
 *         import matplotlib
 *         import matplotlib.pyplot as plt
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,             # <<<<<<<<<<<<<<
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_natural_extention_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_n_iterations);
  __Pyx_GIVEREF(__pyx_v_n_iterations);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_n_iterations);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_norm_xyz, __pyx_v_norm_xyz) < 0) __PYX_ERR(0, 1715, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1716
 *         import matplotlib.pyplot as plt
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,
 *                 norm_uvw=norm_uvw)             # <<<<<<<<<<<<<<
 *         domain_left, image_left, domain_right, image_right = t
 *         c = dict(zip(domain_left.keys(), ['b','r','g','c','m','y','k']))
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_norm_uvw, __pyx_v_norm_uvw) < 0) __PYX_ERR(0, 1715, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1715
 *         import matplotlib
 *         import matplotlib.pyplot as plt
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,             # <<<<<<<<<<<<<<
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_t = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "slabbe/mult_cont_frac.pyx":1717
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t             # <<<<<<<<<<<<<<
 *         c = dict(zip(domain_left.keys(), ['b','r','g','c','m','y','k']))
 * 
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_t))) || (PyList_CheckExact(__pyx_v_t))) {
    PyObject* sequence = __pyx_v_t;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1717, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_3,&__pyx_t_1,&__pyx_t_2};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 1717, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_3,&__pyx_t_1,&__pyx_t_2};
    __pyx_t_5 = PyObject_GetIter(__pyx_v_t); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1717, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_6(__pyx_t_5); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 4) < 0) __PYX_ERR(0, 1717, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1717, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_domain_left = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_image_left = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_domain_right = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_image_right = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1718
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t
 *         c = dict(zip(domain_left.keys(), ['b','r','g','c','m','y','k']))             # <<<<<<<<<<<<<<
 * 
 *         def create_sub_plot(axx, D, title, norm):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_domain_left, __pyx_n_s_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1718, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1718, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_b);
  __Pyx_GIVEREF(__pyx_n_s_b);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_b);
  __Pyx_INCREF(__pyx_n_s_r);
  __Pyx_GIVEREF(__pyx_n_s_r);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_r);
  __Pyx_INCREF(__pyx_n_s_g);
  __Pyx_GIVEREF(__pyx_n_s_g);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_g);
  __Pyx_INCREF(__pyx_n_s_c);
  __Pyx_GIVEREF(__pyx_n_s_c);
  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_c);
  __Pyx_INCREF(__pyx_n_s_m);
  __Pyx_GIVEREF(__pyx_n_s_m);
  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_m);
  __Pyx_INCREF(__pyx_n_s_y);
  __Pyx_GIVEREF(__pyx_n_s_y);
  PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_y);
  __Pyx_INCREF(__pyx_n_s_k);
  __Pyx_GIVEREF(__pyx_n_s_k);
  PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_s_k);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyDict_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_c = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1720
 *         c = dict(zip(domain_left.keys(), ['b','r','g','c','m','y','k']))
 * 
 *         def create_sub_plot(axx, D, title, norm):             # <<<<<<<<<<<<<<
 *             for key, value in D.iteritems():
 *                 value = D[key]
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6slabbe_14mult_cont_frac_12MCFAlgorithm_22natural_extension_plot_1create_sub_plot, 0, __pyx_n_s_natural_extension_plot_locals_cr, ((PyObject*)__pyx_cur_scope), __pyx_n_s_slabbe_mult_cont_frac, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_create_sub_plot = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1728
 *             axx.set_title(title)
 * 
 *         fig, (ax,bx,cx,dx) = plt.subplots(1,4,sharex=True,sharey=True)             # <<<<<<<<<<<<<<
 *         fig.set_figheight(2)
 *         fig.set_figwidth(12)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_subplots); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_sharex, Py_True) < 0) __PYX_ERR(0, 1728, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_sharey, Py_True) < 0) __PYX_ERR(0, 1728, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__24, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1728, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1728, __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_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_1 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_4), 2) < 0) __PYX_ERR(0, 1728, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1728, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  __pyx_v_fig = __pyx_t_3;
  __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1728, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_8 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_t_8);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_5,&__pyx_t_7,&__pyx_t_8};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 1728, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_5,&__pyx_t_7,&__pyx_t_8};
    __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_9)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_6(__pyx_t_9); if (unlikely(!item)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_9), 4) < 0) __PYX_ERR(0, 1728, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L8_unpacking_done;
    __pyx_L7_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1728, __pyx_L1_error)
    __pyx_L8_unpacking_done:;
  }
  __pyx_v_ax = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_bx = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_cx = __pyx_t_7;
  __pyx_t_7 = 0;
  __pyx_v_dx = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "slabbe/mult_cont_frac.pyx":1729
 * 
 *         fig, (ax,bx,cx,dx) = plt.subplots(1,4,sharex=True,sharey=True)
 *         fig.set_figheight(2)             # <<<<<<<<<<<<<<
 *         fig.set_figwidth(12)
 *         if axis_off:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_fig, __pyx_n_s_set_figheight); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1730
 *         fig, (ax,bx,cx,dx) = plt.subplots(1,4,sharex=True,sharey=True)
 *         fig.set_figheight(2)
 *         fig.set_figwidth(12)             # <<<<<<<<<<<<<<
 *         if axis_off:
 *             ax.set_axis_off()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_fig, __pyx_n_s_set_figwidth); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1731
 *         fig.set_figheight(2)
 *         fig.set_figwidth(12)
 *         if axis_off:             # <<<<<<<<<<<<<<
 *             ax.set_axis_off()
 *             bx.set_axis_off()
 */
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_axis_off); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1731, __pyx_L1_error)
  if (__pyx_t_10) {

    /* "slabbe/mult_cont_frac.pyx":1732
 *         fig.set_figwidth(12)
 *         if axis_off:
 *             ax.set_axis_off()             # <<<<<<<<<<<<<<
 *             bx.set_axis_off()
 *             cx.set_axis_off()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ax, __pyx_n_s_set_axis_off); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1732, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1732, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1732, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":1733
 *         if axis_off:
 *             ax.set_axis_off()
 *             bx.set_axis_off()             # <<<<<<<<<<<<<<
 *             cx.set_axis_off()
 *             dx.set_axis_off()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_bx, __pyx_n_s_set_axis_off); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1733, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1733, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1733, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":1734
 *             ax.set_axis_off()
 *             bx.set_axis_off()
 *             cx.set_axis_off()             # <<<<<<<<<<<<<<
 *             dx.set_axis_off()
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_cx, __pyx_n_s_set_axis_off); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1734, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1734, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1734, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":1735
 *             bx.set_axis_off()
 *             cx.set_axis_off()
 *             dx.set_axis_off()             # <<<<<<<<<<<<<<
 * 
 *         create_sub_plot(ax, domain_left,  "Algo IN",    norm=norm_xyz)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dx, __pyx_n_s_set_axis_off); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1735, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1735, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1735, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":1731
 *         fig.set_figheight(2)
 *         fig.set_figwidth(12)
 *         if axis_off:             # <<<<<<<<<<<<<<
 *             ax.set_axis_off()
 *             bx.set_axis_off()
 */
  }

  /* "slabbe/mult_cont_frac.pyx":1737
 *             dx.set_axis_off()
 * 
 *         create_sub_plot(ax, domain_left,  "Algo IN",    norm=norm_xyz)             # <<<<<<<<<<<<<<
 *         create_sub_plot(bx, domain_right,    "NatExt IN",  norm=norm_uvw)
 *         create_sub_plot(cx, image_left, "Algo OUT",   norm=norm_xyz)
 */
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1737, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_ax);
  __Pyx_GIVEREF(__pyx_v_ax);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_ax);
  __Pyx_INCREF(__pyx_v_domain_left);
  __Pyx_GIVEREF(__pyx_v_domain_left);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_domain_left);
  __Pyx_INCREF(__pyx_kp_s_Algo_IN);
  __Pyx_GIVEREF(__pyx_kp_s_Algo_IN);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_s_Algo_IN);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1737, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_norm, __pyx_v_norm_xyz) < 0) __PYX_ERR(0, 1737, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_create_sub_plot, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1737, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1738
 * 
 *         create_sub_plot(ax, domain_left,  "Algo IN",    norm=norm_xyz)
 *         create_sub_plot(bx, domain_right,    "NatExt IN",  norm=norm_uvw)             # <<<<<<<<<<<<<<
 *         create_sub_plot(cx, image_left, "Algo OUT",   norm=norm_xyz)
 *         create_sub_plot(dx, image_right,   "NatExt OUT", norm=norm_uvw)
 */
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_bx);
  __Pyx_GIVEREF(__pyx_v_bx);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_bx);
  __Pyx_INCREF(__pyx_v_domain_right);
  __Pyx_GIVEREF(__pyx_v_domain_right);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_domain_right);
  __Pyx_INCREF(__pyx_kp_s_NatExt_IN);
  __Pyx_GIVEREF(__pyx_kp_s_NatExt_IN);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_s_NatExt_IN);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_norm, __pyx_v_norm_uvw) < 0) __PYX_ERR(0, 1738, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_create_sub_plot, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1739
 *         create_sub_plot(ax, domain_left,  "Algo IN",    norm=norm_xyz)
 *         create_sub_plot(bx, domain_right,    "NatExt IN",  norm=norm_uvw)
 *         create_sub_plot(cx, image_left, "Algo OUT",   norm=norm_xyz)             # <<<<<<<<<<<<<<
 *         create_sub_plot(dx, image_right,   "NatExt OUT", norm=norm_uvw)
 * 
 */
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_cx);
  __Pyx_GIVEREF(__pyx_v_cx);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_cx);
  __Pyx_INCREF(__pyx_v_image_left);
  __Pyx_GIVEREF(__pyx_v_image_left);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_image_left);
  __Pyx_INCREF(__pyx_kp_s_Algo_OUT);
  __Pyx_GIVEREF(__pyx_kp_s_Algo_OUT);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_s_Algo_OUT);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_norm, __pyx_v_norm_xyz) < 0) __PYX_ERR(0, 1739, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_create_sub_plot, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1740
 *         create_sub_plot(bx, domain_right,    "NatExt IN",  norm=norm_uvw)
 *         create_sub_plot(cx, image_left, "Algo OUT",   norm=norm_xyz)
 *         create_sub_plot(dx, image_right,   "NatExt OUT", norm=norm_uvw)             # <<<<<<<<<<<<<<
 * 
 *         title = "Algo=%s, nbiter=%s" % (self.name(), n_iterations)
 */
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_dx);
  __Pyx_GIVEREF(__pyx_v_dx);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_dx);
  __Pyx_INCREF(__pyx_v_image_right);
  __Pyx_GIVEREF(__pyx_v_image_right);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_image_right);
  __Pyx_INCREF(__pyx_kp_s_NatExt_OUT);
  __Pyx_GIVEREF(__pyx_kp_s_NatExt_OUT);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_s_NatExt_OUT);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_norm, __pyx_v_norm_uvw) < 0) __PYX_ERR(0, 1740, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_create_sub_plot, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1742
 *         create_sub_plot(dx, image_right,   "NatExt OUT", norm=norm_uvw)
 * 
 *         title = "Algo=%s, nbiter=%s" % (self.name(), n_iterations)             # <<<<<<<<<<<<<<
 *         fig.suptitle(title)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1742, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1742, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_n_iterations);
  __Pyx_GIVEREF(__pyx_v_n_iterations);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_n_iterations);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Algo_s_nbiter_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_title = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1743
 * 
 *         title = "Algo=%s, nbiter=%s" % (self.name(), n_iterations)
 *         fig.suptitle(title)             # <<<<<<<<<<<<<<
 * 
 *         return fig
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_fig, __pyx_n_s_suptitle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1743, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_title); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_title);
    __Pyx_GIVEREF(__pyx_v_title);
    PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_title);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1745
 *         fig.suptitle(title)
 * 
 *         return fig             # <<<<<<<<<<<<<<
 * 
 *     def natural_extension_tikz(self, n_iterations, norm_xyz='1',
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_fig);
  __pyx_r = __pyx_v_fig;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":1695
 *         return fig
 * 
 *     def natural_extension_plot(self, n_iterations, norm_xyz='1',             # <<<<<<<<<<<<<<
 *             norm_uvw='1', axis_off=False):
 *         r"""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_plot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_matplotlib);
  __Pyx_XDECREF(__pyx_v_plt);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_domain_left);
  __Pyx_XDECREF(__pyx_v_image_left);
  __Pyx_XDECREF(__pyx_v_domain_right);
  __Pyx_XDECREF(__pyx_v_image_right);
  __Pyx_XDECREF(__pyx_v_create_sub_plot);
  __Pyx_XDECREF(__pyx_v_fig);
  __Pyx_XDECREF(__pyx_v_ax);
  __Pyx_XDECREF(__pyx_v_bx);
  __Pyx_XDECREF(__pyx_v_cx);
  __Pyx_XDECREF(__pyx_v_dx);
  __Pyx_XDECREF(__pyx_v_title);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1747
 *         return fig
 * 
 *     def natural_extension_tikz(self, n_iterations, norm_xyz='1',             # <<<<<<<<<<<<<<
 *             norm_uvw='1', marksize=0.2, legend_marksize=2,
 *             group_size="4 by 1"):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_62natural_extension_tikz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_61natural_extension_tikz[] = "\n\n        INPUT:\n\n        - ``n_iterations`` -- integer, number of iterations\n        - ``norm_xyz`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit points\n        - ``norm_uvw`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the dual orbit points\n        - ``marksize`` -- tikz marksize (default:``0.2``)\n        - ``legend_marksize`` -- tikz legend marksize (default:``2``)\n        - ``group_size`` -- string (default:``\"4 by 1\"``)\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: s = Brun().natural_extension_tikz(1000)\n            sage: s\n            \\documentclass[tikz]{standalone}\n            \\usepackage{pgfplots}\n            \\usetikzlibrary{pgfplots.groupplots}\n            \\begin{document}\n            \\begin{tikzpicture}[scale=.7]\n            \\begin{groupplot}\n            [group style={group size=4 by 1},\n            height=7cm,width=8cm,\n            xmin=-1.1,xmax=1.1,ymin=-.6,ymax=1.20,\n            ...\n            ... 4184 lines not printed (177644 characters in total) ...\n            ...\n            \\draw[draw=none] (group c2r1.center) --\n            node {$\\to$}     (group c3r1.center);\n            \\draw[draw=none] (group c3r1.center) --\n            node {$\\times$}  (group c4r1.center);\n            \\end{tikzpicture}\n            \\end{document}\n\n        ::\n\n            sage: from sage.misc.temporary_file import tmp_filename\n            sage: filename = tmp_filename('temp','.pdf')\n            sage: _ = s.pdf(filename)\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_62natural_extension_tikz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_n_iterations = 0;
  PyObject *__pyx_v_norm_xyz = 0;
  PyObject *__pyx_v_norm_uvw = 0;
  PyObject *__pyx_v_marksize = 0;
  PyObject *__pyx_v_legend_marksize = 0;
  PyObject *__pyx_v_group_size = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("natural_extension_tikz (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,&__pyx_n_s_norm_xyz,&__pyx_n_s_norm_uvw,&__pyx_n_s_marksize,&__pyx_n_s_legend_marksize,&__pyx_n_s_group_size,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[1] = ((PyObject *)__pyx_kp_s_1);
    values[2] = ((PyObject *)__pyx_kp_s_1);
    values[3] = ((PyObject *)__pyx_float_0_2);
    values[4] = ((PyObject *)__pyx_int_2);
    values[5] = ((PyObject *)__pyx_kp_s_4_by_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_xyz);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_uvw);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_marksize);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_legend_marksize);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_group_size);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "natural_extension_tikz") < 0)) __PYX_ERR(0, 1747, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_n_iterations = values[0];
    __pyx_v_norm_xyz = values[1];
    __pyx_v_norm_uvw = values[2];
    __pyx_v_marksize = values[3];
    __pyx_v_legend_marksize = values[4];
    __pyx_v_group_size = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("natural_extension_tikz", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1747, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_tikz", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_61natural_extension_tikz(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations, __pyx_v_norm_xyz, __pyx_v_norm_uvw, __pyx_v_marksize, __pyx_v_legend_marksize, __pyx_v_group_size);

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_61natural_extension_tikz(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_marksize, PyObject *__pyx_v_legend_marksize, PyObject *__pyx_v_group_size) {
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_domain_left = NULL;
  PyObject *__pyx_v_image_left = NULL;
  PyObject *__pyx_v_domain_right = NULL;
  PyObject *__pyx_v_image_right = NULL;
  double __pyx_v_sqrt3;
  double __pyx_v_r;
  PyObject *__pyx_v_color_dict = NULL;
  PyObject *__pyx_v_lines = NULL;
  PyObject *__pyx_v_datas = NULL;
  PyObject *__pyx_v_labels = NULL;
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_v_label = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_TikzPicture = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  __Pyx_RefNannySetupContext("natural_extension_tikz", 0);

  /* "slabbe/mult_cont_frac.pyx":1793
 *             sage: _ = s.pdf(filename)
 *         """
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,             # <<<<<<<<<<<<<<
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_natural_extention_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_n_iterations);
  __Pyx_GIVEREF(__pyx_v_n_iterations);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_n_iterations);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_norm_xyz, __pyx_v_norm_xyz) < 0) __PYX_ERR(0, 1793, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1794
 *         """
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,
 *                 norm_uvw=norm_uvw)             # <<<<<<<<<<<<<<
 *         domain_left, image_left, domain_right, image_right = t
 *         sqrt3 = 1.73205080756888
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_norm_uvw, __pyx_v_norm_uvw) < 0) __PYX_ERR(0, 1793, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1793
 *             sage: _ = s.pdf(filename)
 *         """
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,             # <<<<<<<<<<<<<<
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_t = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "slabbe/mult_cont_frac.pyx":1795
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t             # <<<<<<<<<<<<<<
 *         sqrt3 = 1.73205080756888
 *         r = 1.08
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_t))) || (PyList_CheckExact(__pyx_v_t))) {
    PyObject* sequence = __pyx_v_t;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1795, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_1);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_3,&__pyx_t_2,&__pyx_t_1};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 1795, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_3,&__pyx_t_2,&__pyx_t_1};
    __pyx_t_5 = PyObject_GetIter(__pyx_v_t); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_6(__pyx_t_5); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 4) < 0) __PYX_ERR(0, 1795, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1795, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_domain_left = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_image_left = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_domain_right = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_image_right = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1796
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t
 *         sqrt3 = 1.73205080756888             # <<<<<<<<<<<<<<
 *         r = 1.08
 *         color_dict = dict(zip(domain_left.keys(), PGF_COLORS))
 */
  __pyx_v_sqrt3 = 1.73205080756888;

  /* "slabbe/mult_cont_frac.pyx":1797
 *         domain_left, image_left, domain_right, image_right = t
 *         sqrt3 = 1.73205080756888
 *         r = 1.08             # <<<<<<<<<<<<<<
 *         color_dict = dict(zip(domain_left.keys(), PGF_COLORS))
 * 
 */
  __pyx_v_r = 1.08;

  /* "slabbe/mult_cont_frac.pyx":1798
 *         sqrt3 = 1.73205080756888
 *         r = 1.08
 *         color_dict = dict(zip(domain_left.keys(), PGF_COLORS))             # <<<<<<<<<<<<<<
 * 
 *         lines = []
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_domain_left, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1798, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1798, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PGF_COLORS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyDict_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_color_dict = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1800
 *         color_dict = dict(zip(domain_left.keys(), PGF_COLORS))
 * 
 *         lines = []             # <<<<<<<<<<<<<<
 *         lines.append(r"\begin{tikzpicture}[scale=.7]")
 *         lines.append(r"\begin{groupplot}")
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1800, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_lines = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1801
 * 
 *         lines = []
 *         lines.append(r"\begin{tikzpicture}[scale=.7]")             # <<<<<<<<<<<<<<
 *         lines.append(r"\begin{groupplot}")
 *         lines.append(r"[group style={group size=%s}," % group_size)
 */
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_begin_tikzpicture_scale_7); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1801, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1802
 *         lines = []
 *         lines.append(r"\begin{tikzpicture}[scale=.7]")
 *         lines.append(r"\begin{groupplot}")             # <<<<<<<<<<<<<<
 *         lines.append(r"[group style={group size=%s}," % group_size)
 *         lines.append(r"height=7cm,width=8cm,")
 */
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_begin_groupplot); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1802, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1803
 *         lines.append(r"\begin{tikzpicture}[scale=.7]")
 *         lines.append(r"\begin{groupplot}")
 *         lines.append(r"[group style={group size=%s}," % group_size)             # <<<<<<<<<<<<<<
 *         lines.append(r"height=7cm,width=8cm,")
 *         lines.append(r"xmin=-1.1,xmax=1.1,ymin=-.6,ymax=1.20,")
 */
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_group_style_group_size_s, __pyx_v_group_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_t_2); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1803, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1804
 *         lines.append(r"\begin{groupplot}")
 *         lines.append(r"[group style={group size=%s}," % group_size)
 *         lines.append(r"height=7cm,width=8cm,")             # <<<<<<<<<<<<<<
 *         lines.append(r"xmin=-1.1,xmax=1.1,ymin=-.6,ymax=1.20,")
 *         lines.append(r"hide axis]")
 */
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_height_7cm_width_8cm); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1804, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1805
 *         lines.append(r"[group style={group size=%s}," % group_size)
 *         lines.append(r"height=7cm,width=8cm,")
 *         lines.append(r"xmin=-1.1,xmax=1.1,ymin=-.6,ymax=1.20,")             # <<<<<<<<<<<<<<
 *         lines.append(r"hide axis]")
 *         datas = [domain_left, domain_right, image_left, image_right]
 */
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_xmin_1_1_xmax_1_1_ymin_6_ymax_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1805, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1806
 *         lines.append(r"height=7cm,width=8cm,")
 *         lines.append(r"xmin=-1.1,xmax=1.1,ymin=-.6,ymax=1.20,")
 *         lines.append(r"hide axis]")             # <<<<<<<<<<<<<<
 *         datas = [domain_left, domain_right, image_left, image_right]
 *         labels = [r"$\mathbf{x}_n$",r"$\mathbf{a}_n$",
 */
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_hide_axis); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1806, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1807
 *         lines.append(r"xmin=-1.1,xmax=1.1,ymin=-.6,ymax=1.20,")
 *         lines.append(r"hide axis]")
 *         datas = [domain_left, domain_right, image_left, image_right]             # <<<<<<<<<<<<<<
 *         labels = [r"$\mathbf{x}_n$",r"$\mathbf{a}_n$",
 *                   r"$\mathbf{x}_{n+1}$",r"$\mathbf{a}_{n+1}$"]
 */
  __pyx_t_2 = PyList_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1807, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_domain_left);
  __Pyx_GIVEREF(__pyx_v_domain_left);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_domain_left);
  __Pyx_INCREF(__pyx_v_domain_right);
  __Pyx_GIVEREF(__pyx_v_domain_right);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_v_domain_right);
  __Pyx_INCREF(__pyx_v_image_left);
  __Pyx_GIVEREF(__pyx_v_image_left);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_v_image_left);
  __Pyx_INCREF(__pyx_v_image_right);
  __Pyx_GIVEREF(__pyx_v_image_right);
  PyList_SET_ITEM(__pyx_t_2, 3, __pyx_v_image_right);
  __pyx_v_datas = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1808
 *         lines.append(r"hide axis]")
 *         datas = [domain_left, domain_right, image_left, image_right]
 *         labels = [r"$\mathbf{x}_n$",r"$\mathbf{a}_n$",             # <<<<<<<<<<<<<<
 *                   r"$\mathbf{x}_{n+1}$",r"$\mathbf{a}_{n+1}$"]
 *         for data,label in zip(datas, labels):
 */
  __pyx_t_2 = PyList_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1808, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_kp_s_mathbf_x__n);
  __Pyx_GIVEREF(__pyx_kp_s_mathbf_x__n);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_kp_s_mathbf_x__n);
  __Pyx_INCREF(__pyx_kp_s_mathbf_a__n);
  __Pyx_GIVEREF(__pyx_kp_s_mathbf_a__n);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_kp_s_mathbf_a__n);
  __Pyx_INCREF(__pyx_kp_s_mathbf_x___n_1);
  __Pyx_GIVEREF(__pyx_kp_s_mathbf_x___n_1);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_kp_s_mathbf_x___n_1);
  __Pyx_INCREF(__pyx_kp_s_mathbf_a___n_1);
  __Pyx_GIVEREF(__pyx_kp_s_mathbf_a___n_1);
  PyList_SET_ITEM(__pyx_t_2, 3, __pyx_kp_s_mathbf_a___n_1);
  __pyx_v_labels = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1810
 *         labels = [r"$\mathbf{x}_n$",r"$\mathbf{a}_n$",
 *                   r"$\mathbf{x}_{n+1}$",r"$\mathbf{a}_{n+1}$"]
 *         for data,label in zip(datas, labels):             # <<<<<<<<<<<<<<
 *             lines.append(r"\nextgroupplot")
 *             lines.append(r"\draw[dashed] ")
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_datas);
  __Pyx_GIVEREF(__pyx_v_datas);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_datas);
  __Pyx_INCREF(__pyx_v_labels);
  __Pyx_GIVEREF(__pyx_v_labels);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_labels);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1810, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1810, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1810, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1810, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1810, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1810, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_9(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1810, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 1810, __pyx_L1_error)
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1810, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1810, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1810, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 1810, __pyx_L1_error)
      __pyx_t_6 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L8_unpacking_done;
      __pyx_L7_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 1810, __pyx_L1_error)
      __pyx_L8_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_data, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_label, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "slabbe/mult_cont_frac.pyx":1811
 *                   r"$\mathbf{x}_{n+1}$",r"$\mathbf{a}_{n+1}$"]
 *         for data,label in zip(datas, labels):
 *             lines.append(r"\nextgroupplot")             # <<<<<<<<<<<<<<
 *             lines.append(r"\draw[dashed] ")
 *             lines.append(r"(axis cs:%s, %s)" % (-r*sqrt3/2,r*-.5))
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_nextgroupplot); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1811, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1812
 *         for data,label in zip(datas, labels):
 *             lines.append(r"\nextgroupplot")
 *             lines.append(r"\draw[dashed] ")             # <<<<<<<<<<<<<<
 *             lines.append(r"(axis cs:%s, %s)" % (-r*sqrt3/2,r*-.5))
 *             lines.append(r" node[left] {$\mathbf{e}_1$} -- ")
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_draw_dashed); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1812, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1813
 *             lines.append(r"\nextgroupplot")
 *             lines.append(r"\draw[dashed] ")
 *             lines.append(r"(axis cs:%s, %s)" % (-r*sqrt3/2,r*-.5))             # <<<<<<<<<<<<<<
 *             lines.append(r" node[left] {$\mathbf{e}_1$} -- ")
 *             lines.append("(axis cs:%s, %s)" % (r*sqrt3/2,r*-.5))
 */
    __pyx_t_3 = PyFloat_FromDouble((((-__pyx_v_r) * __pyx_v_sqrt3) / 2.0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1813, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyFloat_FromDouble((__pyx_v_r * -.5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1813, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1813, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_axis_cs_s_s, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1813, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1813, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "slabbe/mult_cont_frac.pyx":1814
 *             lines.append(r"\draw[dashed] ")
 *             lines.append(r"(axis cs:%s, %s)" % (-r*sqrt3/2,r*-.5))
 *             lines.append(r" node[left] {$\mathbf{e}_1$} -- ")             # <<<<<<<<<<<<<<
 *             lines.append("(axis cs:%s, %s)" % (r*sqrt3/2,r*-.5))
 *             lines.append(r" node[right] {$\mathbf{e}_2$} -- ")
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_node_left_mathbf_e__1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1814, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1815
 *             lines.append(r"(axis cs:%s, %s)" % (-r*sqrt3/2,r*-.5))
 *             lines.append(r" node[left] {$\mathbf{e}_1$} -- ")
 *             lines.append("(axis cs:%s, %s)" % (r*sqrt3/2,r*-.5))             # <<<<<<<<<<<<<<
 *             lines.append(r" node[right] {$\mathbf{e}_2$} -- ")
 *             lines.append("(axis cs:%s, %s)" % (0, r))
 */
    __pyx_t_4 = PyFloat_FromDouble(((__pyx_v_r * __pyx_v_sqrt3) / 2.0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1815, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyFloat_FromDouble((__pyx_v_r * -.5)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1815, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1815, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_axis_cs_s_s, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1815, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1815, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "slabbe/mult_cont_frac.pyx":1816
 *             lines.append(r" node[left] {$\mathbf{e}_1$} -- ")
 *             lines.append("(axis cs:%s, %s)" % (r*sqrt3/2,r*-.5))
 *             lines.append(r" node[right] {$\mathbf{e}_2$} -- ")             # <<<<<<<<<<<<<<
 *             lines.append("(axis cs:%s, %s)" % (0, r))
 *             lines.append(r" node[above] {$\mathbf{e}_3$} -- cycle;")
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_node_right_mathbf_e__2); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1816, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1817
 *             lines.append("(axis cs:%s, %s)" % (r*sqrt3/2,r*-.5))
 *             lines.append(r" node[right] {$\mathbf{e}_2$} -- ")
 *             lines.append("(axis cs:%s, %s)" % (0, r))             # <<<<<<<<<<<<<<
 *             lines.append(r" node[above] {$\mathbf{e}_3$} -- cycle;")
 *             lines.append(r"\node at (axis cs:%s, %s) {%s};" % (-.5,.8,label))
 */
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_r); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1817, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1817, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_axis_cs_s_s, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1817, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1817, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "slabbe/mult_cont_frac.pyx":1818
 *             lines.append(r" node[right] {$\mathbf{e}_2$} -- ")
 *             lines.append("(axis cs:%s, %s)" % (0, r))
 *             lines.append(r" node[above] {$\mathbf{e}_3$} -- cycle;")             # <<<<<<<<<<<<<<
 *             lines.append(r"\node at (axis cs:%s, %s) {%s};" % (-.5,.8,label))
 *             for key,value in data.iteritems():
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_node_above_mathbf_e__3_cycle); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1818, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1819
 *             lines.append("(axis cs:%s, %s)" % (0, r))
 *             lines.append(r" node[above] {$\mathbf{e}_3$} -- cycle;")
 *             lines.append(r"\node at (axis cs:%s, %s) {%s};" % (-.5,.8,label))             # <<<<<<<<<<<<<<
 *             for key,value in data.iteritems():
 *                 lines.append(r"\addplot+[")
 */
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1819, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_float_neg__5);
    __Pyx_GIVEREF(__pyx_float_neg__5);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_float_neg__5);
    __Pyx_INCREF(__pyx_float__8);
    __Pyx_GIVEREF(__pyx_float__8);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_float__8);
    __Pyx_INCREF(__pyx_v_label);
    __Pyx_GIVEREF(__pyx_v_label);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_label);
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_node_at_axis_cs_s_s_s, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1819, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_t_3); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1819, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "slabbe/mult_cont_frac.pyx":1820
 *             lines.append(r" node[above] {$\mathbf{e}_3$} -- cycle;")
 *             lines.append(r"\node at (axis cs:%s, %s) {%s};" % (-.5,.8,label))
 *             for key,value in data.iteritems():             # <<<<<<<<<<<<<<
 *                 lines.append(r"\addplot+[")
 *                 lines.append(r"legend image post style={mark size=%s}," % legend_marksize)
 */
    __pyx_t_10 = 0;
    if (unlikely(__pyx_v_data == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
      __PYX_ERR(0, 1820, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_dict_iterator(__pyx_v_data, 0, __pyx_n_s_iteritems, (&__pyx_t_11), (&__pyx_t_12)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_1;
    __pyx_t_1 = 0;
    while (1) {
      __pyx_t_13 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_11, &__pyx_t_10, &__pyx_t_1, &__pyx_t_4, NULL, __pyx_t_12);
      if (unlikely(__pyx_t_13 == 0)) break;
      if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1820, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "slabbe/mult_cont_frac.pyx":1821
 *             lines.append(r"\node at (axis cs:%s, %s) {%s};" % (-.5,.8,label))
 *             for key,value in data.iteritems():
 *                 lines.append(r"\addplot+[")             # <<<<<<<<<<<<<<
 *                 lines.append(r"legend image post style={mark size=%s}," % legend_marksize)
 *                 lines.append(r"only marks,mark=*,")
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_addplot); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1821, __pyx_L1_error)

      /* "slabbe/mult_cont_frac.pyx":1822
 *             for key,value in data.iteritems():
 *                 lines.append(r"\addplot+[")
 *                 lines.append(r"legend image post style={mark size=%s}," % legend_marksize)             # <<<<<<<<<<<<<<
 *                 lines.append(r"only marks,mark=*,")
 *                 lines.append(r"mark size=%s," % marksize)
 */
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_legend_image_post_style_mark_siz, __pyx_v_legend_marksize); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1822, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1822, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "slabbe/mult_cont_frac.pyx":1823
 *                 lines.append(r"\addplot+[")
 *                 lines.append(r"legend image post style={mark size=%s}," % legend_marksize)
 *                 lines.append(r"only marks,mark=*,")             # <<<<<<<<<<<<<<
 *                 lines.append(r"mark size=%s," % marksize)
 *                 lines.append(r"mark options={color=%s}] " % color_dict[key])
 */
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_only_marks_mark); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1823, __pyx_L1_error)

      /* "slabbe/mult_cont_frac.pyx":1824
 *                 lines.append(r"legend image post style={mark size=%s}," % legend_marksize)
 *                 lines.append(r"only marks,mark=*,")
 *                 lines.append(r"mark size=%s," % marksize)             # <<<<<<<<<<<<<<
 *                 lines.append(r"mark options={color=%s}] " % color_dict[key])
 *                 lines.append(r"coordinates {%s};" % '\n'.join(map(str, value)))
 */
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_mark_size_s, __pyx_v_marksize); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1824, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1824, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "slabbe/mult_cont_frac.pyx":1825
 *                 lines.append(r"only marks,mark=*,")
 *                 lines.append(r"mark size=%s," % marksize)
 *                 lines.append(r"mark options={color=%s}] " % color_dict[key])             # <<<<<<<<<<<<<<
 *                 lines.append(r"coordinates {%s};" % '\n'.join(map(str, value)))
 *                 lines.append(r"\addlegendentry{%s}" % key)
 */
      __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_color_dict, __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1825, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_mark_options_color_s, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1825, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1825, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "slabbe/mult_cont_frac.pyx":1826
 *                 lines.append(r"mark size=%s," % marksize)
 *                 lines.append(r"mark options={color=%s}] " % color_dict[key])
 *                 lines.append(r"coordinates {%s};" % '\n'.join(map(str, value)))             # <<<<<<<<<<<<<<
 *                 lines.append(r"\addlegendentry{%s}" % key)
 *         lines.append(r"\end{groupplot}")
 */
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1826, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)(&PyString_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)(&PyString_Type)));
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_value);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1826, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__27, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1826, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_coordinates_s, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1826, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1826, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "slabbe/mult_cont_frac.pyx":1827
 *                 lines.append(r"mark options={color=%s}] " % color_dict[key])
 *                 lines.append(r"coordinates {%s};" % '\n'.join(map(str, value)))
 *                 lines.append(r"\addlegendentry{%s}" % key)             # <<<<<<<<<<<<<<
 *         lines.append(r"\end{groupplot}")
 *         if group_size == "4 by 1":
 */
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_addlegendentry_s, __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1827, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1827, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "slabbe/mult_cont_frac.pyx":1810
 *         labels = [r"$\mathbf{x}_n$",r"$\mathbf{a}_n$",
 *                   r"$\mathbf{x}_{n+1}$",r"$\mathbf{a}_{n+1}$"]
 *         for data,label in zip(datas, labels):             # <<<<<<<<<<<<<<
 *             lines.append(r"\nextgroupplot")
 *             lines.append(r"\draw[dashed] ")
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1828
 *                 lines.append(r"coordinates {%s};" % '\n'.join(map(str, value)))
 *                 lines.append(r"\addlegendentry{%s}" % key)
 *         lines.append(r"\end{groupplot}")             # <<<<<<<<<<<<<<
 *         if group_size == "4 by 1":
 *             lines.append(r"\draw[draw=none] (group c1r1.center) -- ")
 */
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_end_groupplot); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1828, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1829
 *                 lines.append(r"\addlegendentry{%s}" % key)
 *         lines.append(r"\end{groupplot}")
 *         if group_size == "4 by 1":             # <<<<<<<<<<<<<<
 *             lines.append(r"\draw[draw=none] (group c1r1.center) -- ")
 *             lines.append(r"node {$\times$}  (group c2r1.center);")
 */
  __pyx_t_14 = (__Pyx_PyString_Equals(__pyx_v_group_size, __pyx_kp_s_4_by_1, Py_EQ)); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 1829, __pyx_L1_error)
  if (__pyx_t_14) {

    /* "slabbe/mult_cont_frac.pyx":1830
 *         lines.append(r"\end{groupplot}")
 *         if group_size == "4 by 1":
 *             lines.append(r"\draw[draw=none] (group c1r1.center) -- ")             # <<<<<<<<<<<<<<
 *             lines.append(r"node {$\times$}  (group c2r1.center);")
 *             lines.append(r"\draw[draw=none] (group c2r1.center) -- ")
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_draw_draw_none_group_c1r1_cente); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1830, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1831
 *         if group_size == "4 by 1":
 *             lines.append(r"\draw[draw=none] (group c1r1.center) -- ")
 *             lines.append(r"node {$\times$}  (group c2r1.center);")             # <<<<<<<<<<<<<<
 *             lines.append(r"\draw[draw=none] (group c2r1.center) -- ")
 *             lines.append(r"node {$\to$}     (group c3r1.center);")
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_node_times_group_c2r1_center); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1831, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1832
 *             lines.append(r"\draw[draw=none] (group c1r1.center) -- ")
 *             lines.append(r"node {$\times$}  (group c2r1.center);")
 *             lines.append(r"\draw[draw=none] (group c2r1.center) -- ")             # <<<<<<<<<<<<<<
 *             lines.append(r"node {$\to$}     (group c3r1.center);")
 *             lines.append(r"\draw[draw=none] (group c3r1.center) -- ")
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_draw_draw_none_group_c2r1_cente); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1832, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1833
 *             lines.append(r"node {$\times$}  (group c2r1.center);")
 *             lines.append(r"\draw[draw=none] (group c2r1.center) -- ")
 *             lines.append(r"node {$\to$}     (group c3r1.center);")             # <<<<<<<<<<<<<<
 *             lines.append(r"\draw[draw=none] (group c3r1.center) -- ")
 *             lines.append(r"node {$\times$}  (group c4r1.center);")
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_node_to_group_c3r1_center); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1833, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1834
 *             lines.append(r"\draw[draw=none] (group c2r1.center) -- ")
 *             lines.append(r"node {$\to$}     (group c3r1.center);")
 *             lines.append(r"\draw[draw=none] (group c3r1.center) -- ")             # <<<<<<<<<<<<<<
 *             lines.append(r"node {$\times$}  (group c4r1.center);")
 *         lines.append(r"\end{tikzpicture}")
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_draw_draw_none_group_c3r1_cente); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1834, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1835
 *             lines.append(r"node {$\to$}     (group c3r1.center);")
 *             lines.append(r"\draw[draw=none] (group c3r1.center) -- ")
 *             lines.append(r"node {$\times$}  (group c4r1.center);")             # <<<<<<<<<<<<<<
 *         lines.append(r"\end{tikzpicture}")
 *         from slabbe import TikzPicture
 */
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_node_times_group_c4r1_center); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1835, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":1829
 *                 lines.append(r"\addlegendentry{%s}" % key)
 *         lines.append(r"\end{groupplot}")
 *         if group_size == "4 by 1":             # <<<<<<<<<<<<<<
 *             lines.append(r"\draw[draw=none] (group c1r1.center) -- ")
 *             lines.append(r"node {$\times$}  (group c2r1.center);")
 */
  }

  /* "slabbe/mult_cont_frac.pyx":1836
 *             lines.append(r"\draw[draw=none] (group c3r1.center) -- ")
 *             lines.append(r"node {$\times$}  (group c4r1.center);")
 *         lines.append(r"\end{tikzpicture}")             # <<<<<<<<<<<<<<
 *         from slabbe import TikzPicture
 *         return TikzPicture('\n'.join(lines), packages=['pgfplots'],
 */
  __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_lines, __pyx_kp_s_end_tikzpicture); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1836, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1837
 *             lines.append(r"node {$\times$}  (group c4r1.center);")
 *         lines.append(r"\end{tikzpicture}")
 *         from slabbe import TikzPicture             # <<<<<<<<<<<<<<
 *         return TikzPicture('\n'.join(lines), packages=['pgfplots'],
 *                 tikzlibraries=['pgfplots.groupplots'])
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1837, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_TikzPicture);
  __Pyx_GIVEREF(__pyx_n_s_TikzPicture);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_TikzPicture);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_slabbe, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1837, __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_TikzPicture); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1837, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_TikzPicture = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1838
 *         lines.append(r"\end{tikzpicture}")
 *         from slabbe import TikzPicture
 *         return TikzPicture('\n'.join(lines), packages=['pgfplots'],             # <<<<<<<<<<<<<<
 *                 tikzlibraries=['pgfplots.groupplots'])
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__27, __pyx_v_lines); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_s_pgfplots);
  __Pyx_GIVEREF(__pyx_n_s_pgfplots);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_pgfplots);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_packages, __pyx_t_4) < 0) __PYX_ERR(0, 1838, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "slabbe/mult_cont_frac.pyx":1839
 *         from slabbe import TikzPicture
 *         return TikzPicture('\n'.join(lines), packages=['pgfplots'],
 *                 tikzlibraries=['pgfplots.groupplots'])             # <<<<<<<<<<<<<<
 * 
 *     def natural_extension_part_tikz(self, n_iterations, part=3,
 */
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1839, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_kp_s_pgfplots_groupplots);
  __Pyx_GIVEREF(__pyx_kp_s_pgfplots_groupplots);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_kp_s_pgfplots_groupplots);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_tikzlibraries, __pyx_t_4) < 0) __PYX_ERR(0, 1838, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "slabbe/mult_cont_frac.pyx":1838
 *         lines.append(r"\end{tikzpicture}")
 *         from slabbe import TikzPicture
 *         return TikzPicture('\n'.join(lines), packages=['pgfplots'],             # <<<<<<<<<<<<<<
 *                 tikzlibraries=['pgfplots.groupplots'])
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_v_TikzPicture, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":1747
 *         return fig
 * 
 *     def natural_extension_tikz(self, n_iterations, norm_xyz='1',             # <<<<<<<<<<<<<<
 *             norm_uvw='1', marksize=0.2, legend_marksize=2,
 *             group_size="4 by 1"):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_tikz", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_domain_left);
  __Pyx_XDECREF(__pyx_v_image_left);
  __Pyx_XDECREF(__pyx_v_domain_right);
  __Pyx_XDECREF(__pyx_v_image_right);
  __Pyx_XDECREF(__pyx_v_color_dict);
  __Pyx_XDECREF(__pyx_v_lines);
  __Pyx_XDECREF(__pyx_v_datas);
  __Pyx_XDECREF(__pyx_v_labels);
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_label);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_TikzPicture);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1841
 *                 tikzlibraries=['pgfplots.groupplots'])
 * 
 *     def natural_extension_part_tikz(self, n_iterations, part=3,             # <<<<<<<<<<<<<<
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     marksize='1pt', limit_nb_points=None,
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_64natural_extension_part_tikz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_63natural_extension_part_tikz[] = "\n        Return a pgfplots or some part of an orbit in the natural\n        extension.\n\n        INPUT:\n\n        - ``n_iterations`` - integer, number of iterations\n        - ``part`` - integer, taking value 0, 1, 2 or 3\n        - ``norm_xyz`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit points\n        - ``norm_uvw`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the dual orbit points\n        - ``marksize`` -- string (default: ``'1pt'``), pgfplots mark size value\n        - ``limit_nb_points`` -- None or integer (default: ``None``), limit\n          number of points per patch\n        - ``verbose`` -- string (default: ``False``)\n\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import ARP\n            sage: s = ARP().natural_extension_part_tikz(1000, part=3)\n            sage: view(s, tightpage=True)    # not tested\n\n        also ::\n\n            sage: s = ARP().natural_extension_part_tikz(1000, part=3, marksize='.2pt', limit_nb_points=1200, verbose=True)\n            Taking ... points for key 1\n            Taking ... points for key 2\n            Taking ... points for key 3\n            Taking ... points for key 132\n            Taking ... points for key 321\n            Taking ... points for key 231\n            Taking ... points for key 213\n            Taking ... points for key 312\n            Taking ... points for key 123\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_64natural_extension_part_tikz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_n_iterations = 0;
  PyObject *__pyx_v_part = 0;
  PyObject *__pyx_v_norm_xyz = 0;
  PyObject *__pyx_v_norm_uvw = 0;
  PyObject *__pyx_v_marksize = 0;
  PyObject *__pyx_v_limit_nb_points = 0;
  PyObject *__pyx_v_verbose = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("natural_extension_part_tikz (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,&__pyx_n_s_part,&__pyx_n_s_norm_xyz,&__pyx_n_s_norm_uvw,&__pyx_n_s_marksize,&__pyx_n_s_limit_nb_points,&__pyx_n_s_verbose,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[1] = ((PyObject *)__pyx_int_3);
    values[2] = ((PyObject *)__pyx_kp_s_1);
    values[3] = ((PyObject *)__pyx_kp_s_1);
    values[4] = ((PyObject *)__pyx_kp_s_1pt);

    /* "slabbe/mult_cont_frac.pyx":1843
 *     def natural_extension_part_tikz(self, n_iterations, part=3,
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     marksize='1pt', limit_nb_points=None,             # <<<<<<<<<<<<<<
 *                                     verbose=False):
 *         r"""
 */
    values[5] = ((PyObject *)Py_None);

    /* "slabbe/mult_cont_frac.pyx":1844
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     marksize='1pt', limit_nb_points=None,
 *                                     verbose=False):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return a pgfplots or some part of an orbit in the natural
 */
    values[6] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_part);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_xyz);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_uvw);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_marksize);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_limit_nb_points);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_verbose);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "natural_extension_part_tikz") < 0)) __PYX_ERR(0, 1841, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_n_iterations = values[0];
    __pyx_v_part = values[1];
    __pyx_v_norm_xyz = values[2];
    __pyx_v_norm_uvw = values[3];
    __pyx_v_marksize = values[4];
    __pyx_v_limit_nb_points = values[5];
    __pyx_v_verbose = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("natural_extension_part_tikz", 0, 1, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1841, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_part_tikz", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_63natural_extension_part_tikz(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations, __pyx_v_part, __pyx_v_norm_xyz, __pyx_v_norm_uvw, __pyx_v_marksize, __pyx_v_limit_nb_points, __pyx_v_verbose);

  /* "slabbe/mult_cont_frac.pyx":1841
 *                 tikzlibraries=['pgfplots.groupplots'])
 * 
 *     def natural_extension_part_tikz(self, n_iterations, part=3,             # <<<<<<<<<<<<<<
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     marksize='1pt', limit_nb_points=None,
 */

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_63natural_extension_part_tikz(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_part, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_marksize, PyObject *__pyx_v_limit_nb_points, PyObject *__pyx_v_verbose) {
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_domain_left = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_image_left = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_domain_right = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_image_right = NULL;
  double __pyx_v_sqrt3;
  double __pyx_v_r;
  PyObject *__pyx_v_color_dict = NULL;
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_TikzPicture = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  Py_ssize_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("natural_extension_part_tikz", 0);

  /* "slabbe/mult_cont_frac.pyx":1881
 *             Taking ... points for key 123
 *         """
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,             # <<<<<<<<<<<<<<
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_natural_extention_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_n_iterations);
  __Pyx_GIVEREF(__pyx_v_n_iterations);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_n_iterations);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_norm_xyz, __pyx_v_norm_xyz) < 0) __PYX_ERR(0, 1881, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1882
 *         """
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,
 *                 norm_uvw=norm_uvw)             # <<<<<<<<<<<<<<
 *         domain_left, image_left, domain_right, image_right = t
 *         sqrt3 = 1.73205080756888
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_norm_uvw, __pyx_v_norm_uvw) < 0) __PYX_ERR(0, 1881, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1881
 *             Taking ... points for key 123
 *         """
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,             # <<<<<<<<<<<<<<
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_t = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "slabbe/mult_cont_frac.pyx":1883
 *         t = self._natural_extention_dict(n_iterations, norm_xyz=norm_xyz,
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t             # <<<<<<<<<<<<<<
 *         sqrt3 = 1.73205080756888
 *         r = 1.08
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_t))) || (PyList_CheckExact(__pyx_v_t))) {
    PyObject* sequence = __pyx_v_t;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1883, __pyx_L1_error)
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_1);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_3,&__pyx_t_2,&__pyx_t_1};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 1883, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_3,&__pyx_t_2,&__pyx_t_1};
    __pyx_t_5 = PyObject_GetIter(__pyx_v_t); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1883, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_6(__pyx_t_5); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 4) < 0) __PYX_ERR(0, 1883, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1883, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_domain_left = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_image_left = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_domain_right = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_image_right = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1884
 *                 norm_uvw=norm_uvw)
 *         domain_left, image_left, domain_right, image_right = t
 *         sqrt3 = 1.73205080756888             # <<<<<<<<<<<<<<
 *         r = 1.08
 *         color_dict = dict(zip(domain_left.keys(), PGF_COLORS))
 */
  __pyx_v_sqrt3 = 1.73205080756888;

  /* "slabbe/mult_cont_frac.pyx":1885
 *         domain_left, image_left, domain_right, image_right = t
 *         sqrt3 = 1.73205080756888
 *         r = 1.08             # <<<<<<<<<<<<<<
 *         color_dict = dict(zip(domain_left.keys(), PGF_COLORS))
 *         data = t[part]
 */
  __pyx_v_r = 1.08;

  /* "slabbe/mult_cont_frac.pyx":1886
 *         sqrt3 = 1.73205080756888
 *         r = 1.08
 *         color_dict = dict(zip(domain_left.keys(), PGF_COLORS))             # <<<<<<<<<<<<<<
 *         data = t[part]
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_domain_left, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1886, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1886, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PGF_COLORS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyDict_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_color_dict = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1887
 *         r = 1.08
 *         color_dict = dict(zip(domain_left.keys(), PGF_COLORS))
 *         data = t[part]             # <<<<<<<<<<<<<<
 * 
 *         s = ''
 */
  __pyx_t_2 = PyObject_GetItem(__pyx_v_t, __pyx_v_part); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1887, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_data = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1889
 *         data = t[part]
 * 
 *         s = ''             # <<<<<<<<<<<<<<
 *         s += "\\begin{tikzpicture}[scale=.7]\n"
 *         s += ("\\begin{axis}[height=7cm,width=8cm,\n"
 */
  __Pyx_INCREF(__pyx_kp_s__28);
  __pyx_v_s = __pyx_kp_s__28;

  /* "slabbe/mult_cont_frac.pyx":1890
 * 
 *         s = ''
 *         s += "\\begin{tikzpicture}[scale=.7]\n"             # <<<<<<<<<<<<<<
 *         s += ("\\begin{axis}[height=7cm,width=8cm,\n"
 *                "xmin=-1.1,xmax=1.1,ymin=-.6,ymax=1.20,\n"
 */
  __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_kp_s_begin_tikzpicture_scale_7_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1891
 *         s = ''
 *         s += "\\begin{tikzpicture}[scale=.7]\n"
 *         s += ("\\begin{axis}[height=7cm,width=8cm,\n"             # <<<<<<<<<<<<<<
 *                "xmin=-1.1,xmax=1.1,ymin=-.6,ymax=1.20,\n"
 *                "hide axis]\n")
 */
  __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_kp_s_begin_axis_height_7cm_width_8cm); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1895
 *                "hide axis]\n")
 *         s += ("\\draw[dashed] \n"
 *               "(axis cs:%s, %s)" % (-r*sqrt3/2,r*-.5) +             # <<<<<<<<<<<<<<
 *               " node[left] {$\\mathbf{e}_1$} -- \n"
 *               "(axis cs:%s, %s)" % (r*sqrt3/2,r*-.5)  +
 */
  __pyx_t_2 = PyFloat_FromDouble((((-__pyx_v_r) * __pyx_v_sqrt3) / 2.0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble((__pyx_v_r * -.5)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_draw_dashed_axis_cs_s_s, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":1897
 *               "(axis cs:%s, %s)" % (-r*sqrt3/2,r*-.5) +
 *               " node[left] {$\\mathbf{e}_1$} -- \n"
 *               "(axis cs:%s, %s)" % (r*sqrt3/2,r*-.5)  +             # <<<<<<<<<<<<<<
 *               " node[right] {$\\mathbf{e}_2$} -- \n"
 *               "(axis cs:%s, %s)" % (0, r)             +
 */
  __pyx_t_1 = PyFloat_FromDouble(((__pyx_v_r * __pyx_v_sqrt3) / 2.0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble((__pyx_v_r * -.5)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_node_left_mathbf_e__1_axis_cs_s, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "slabbe/mult_cont_frac.pyx":1895
 *                "hide axis]\n")
 *         s += ("\\draw[dashed] \n"
 *               "(axis cs:%s, %s)" % (-r*sqrt3/2,r*-.5) +             # <<<<<<<<<<<<<<
 *               " node[left] {$\\mathbf{e}_1$} -- \n"
 *               "(axis cs:%s, %s)" % (r*sqrt3/2,r*-.5)  +
 */
  __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1899
 *               "(axis cs:%s, %s)" % (r*sqrt3/2,r*-.5)  +
 *               " node[right] {$\\mathbf{e}_2$} -- \n"
 *               "(axis cs:%s, %s)" % (0, r)             +             # <<<<<<<<<<<<<<
 *               " node[above] {$\\mathbf{e}_3$} -- cycle;\n")
 *         for key,value in data.iteritems():
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_r); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_node_right_mathbf_e__2_axis_cs, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1897
 *               "(axis cs:%s, %s)" % (-r*sqrt3/2,r*-.5) +
 *               " node[left] {$\\mathbf{e}_1$} -- \n"
 *               "(axis cs:%s, %s)" % (r*sqrt3/2,r*-.5)  +             # <<<<<<<<<<<<<<
 *               " node[right] {$\\mathbf{e}_2$} -- \n"
 *               "(axis cs:%s, %s)" % (0, r)             +
 */
  __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":1899
 *               "(axis cs:%s, %s)" % (r*sqrt3/2,r*-.5)  +
 *               " node[right] {$\\mathbf{e}_2$} -- \n"
 *               "(axis cs:%s, %s)" % (0, r)             +             # <<<<<<<<<<<<<<
 *               " node[above] {$\\mathbf{e}_3$} -- cycle;\n")
 *         for key,value in data.iteritems():
 */
  __pyx_t_2 = PyNumber_Add(__pyx_t_3, __pyx_kp_s_node_above_mathbf_e__3_cycle_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1894
 *                "xmin=-1.1,xmax=1.1,ymin=-.6,ymax=1.20,\n"
 *                "hide axis]\n")
 *         s += ("\\draw[dashed] \n"             # <<<<<<<<<<<<<<
 *               "(axis cs:%s, %s)" % (-r*sqrt3/2,r*-.5) +
 *               " node[left] {$\\mathbf{e}_1$} -- \n"
 */
  __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1894, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1901
 *               "(axis cs:%s, %s)" % (0, r)             +
 *               " node[above] {$\\mathbf{e}_3$} -- cycle;\n")
 *         for key,value in data.iteritems():             # <<<<<<<<<<<<<<
 *             if limit_nb_points and len(value) > limit_nb_points:
 *                 if verbose:
 */
  __pyx_t_7 = 0;
  if (unlikely(__pyx_v_data == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    __PYX_ERR(0, 1901, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_data, 0, __pyx_n_s_iteritems, (&__pyx_t_8), (&__pyx_t_9)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1901, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __pyx_t_3 = __pyx_t_2;
  __pyx_t_2 = 0;
  while (1) {
    __pyx_t_10 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_8, &__pyx_t_7, &__pyx_t_2, &__pyx_t_4, NULL, __pyx_t_9);
    if (unlikely(__pyx_t_10 == 0)) break;
    if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 1901, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "slabbe/mult_cont_frac.pyx":1902
 *               " node[above] {$\\mathbf{e}_3$} -- cycle;\n")
 *         for key,value in data.iteritems():
 *             if limit_nb_points and len(value) > limit_nb_points:             # <<<<<<<<<<<<<<
 *                 if verbose:
 *                     print "Taking only {} points instead of {} for key {}".format(
 */
    __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_limit_nb_points); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 1902, __pyx_L1_error)
    if (__pyx_t_12) {
    } else {
      __pyx_t_11 = __pyx_t_12;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_13 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1902, __pyx_L1_error)
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1902, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_v_limit_nb_points, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1902, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 1902, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_11 = __pyx_t_12;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_11) {

      /* "slabbe/mult_cont_frac.pyx":1903
 *         for key,value in data.iteritems():
 *             if limit_nb_points and len(value) > limit_nb_points:
 *                 if verbose:             # <<<<<<<<<<<<<<
 *                     print "Taking only {} points instead of {} for key {}".format(
 *                             limit_nb_points, len(value), key)
 */
      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1903, __pyx_L1_error)
      if (__pyx_t_11) {

        /* "slabbe/mult_cont_frac.pyx":1904
 *             if limit_nb_points and len(value) > limit_nb_points:
 *                 if verbose:
 *                     print "Taking only {} points instead of {} for key {}".format(             # <<<<<<<<<<<<<<
 *                             limit_nb_points, len(value), key)
 *                 value = value[:limit_nb_points]
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Taking_only_points_instead_of_fo, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1904, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);

        /* "slabbe/mult_cont_frac.pyx":1905
 *                 if verbose:
 *                     print "Taking only {} points instead of {} for key {}".format(
 *                             limit_nb_points, len(value), key)             # <<<<<<<<<<<<<<
 *                 value = value[:limit_nb_points]
 *             elif verbose:
 */
        __pyx_t_13 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1905, __pyx_L1_error)
        __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1905, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = NULL;
        __pyx_t_13 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_13 = 1;
          }
        }
        __pyx_t_14 = PyTuple_New(3+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1904, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_INCREF(__pyx_v_limit_nb_points);
        __Pyx_GIVEREF(__pyx_v_limit_nb_points);
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_v_limit_nb_points);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_t_1);
        __Pyx_INCREF(__pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_13, __pyx_v_key);
        __pyx_t_1 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_14, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1904, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (__Pyx_PrintOne(0, __pyx_t_2) < 0) __PYX_ERR(0, 1904, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "slabbe/mult_cont_frac.pyx":1903
 *         for key,value in data.iteritems():
 *             if limit_nb_points and len(value) > limit_nb_points:
 *                 if verbose:             # <<<<<<<<<<<<<<
 *                     print "Taking only {} points instead of {} for key {}".format(
 *                             limit_nb_points, len(value), key)
 */
      }

      /* "slabbe/mult_cont_frac.pyx":1906
 *                     print "Taking only {} points instead of {} for key {}".format(
 *                             limit_nb_points, len(value), key)
 *                 value = value[:limit_nb_points]             # <<<<<<<<<<<<<<
 *             elif verbose:
 *                 print "Taking {} points for key {}".format(len(value), key)
 */
      __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_value, 0, 0, NULL, &__pyx_v_limit_nb_points, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1906, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "slabbe/mult_cont_frac.pyx":1902
 *               " node[above] {$\\mathbf{e}_3$} -- cycle;\n")
 *         for key,value in data.iteritems():
 *             if limit_nb_points and len(value) > limit_nb_points:             # <<<<<<<<<<<<<<
 *                 if verbose:
 *                     print "Taking only {} points instead of {} for key {}".format(
 */
      goto __pyx_L7;
    }

    /* "slabbe/mult_cont_frac.pyx":1907
 *                             limit_nb_points, len(value), key)
 *                 value = value[:limit_nb_points]
 *             elif verbose:             # <<<<<<<<<<<<<<
 *                 print "Taking {} points for key {}".format(len(value), key)
 * 
 */
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1907, __pyx_L1_error)
    if (__pyx_t_11) {

      /* "slabbe/mult_cont_frac.pyx":1908
 *                 value = value[:limit_nb_points]
 *             elif verbose:
 *                 print "Taking {} points for key {}".format(len(value), key)             # <<<<<<<<<<<<<<
 * 
 *             s += "\\addplot+[only marks,mark=*,mark options={color=%s}," % color_dict[key]
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Taking_points_for_key, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1908, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_13 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1908, __pyx_L1_error)
      __pyx_t_14 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1908, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_1 = NULL;
      __pyx_t_13 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_13 = 1;
        }
      }
      __pyx_t_5 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1908, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_13, __pyx_t_14);
      __Pyx_INCREF(__pyx_v_key);
      __Pyx_GIVEREF(__pyx_v_key);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_13, __pyx_v_key);
      __pyx_t_14 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1908, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_2) < 0) __PYX_ERR(0, 1908, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "slabbe/mult_cont_frac.pyx":1907
 *                             limit_nb_points, len(value), key)
 *                 value = value[:limit_nb_points]
 *             elif verbose:             # <<<<<<<<<<<<<<
 *                 print "Taking {} points for key {}".format(len(value), key)
 * 
 */
    }
    __pyx_L7:;

    /* "slabbe/mult_cont_frac.pyx":1910
 *                 print "Taking {} points for key {}".format(len(value), key)
 * 
 *             s += "\\addplot+[only marks,mark=*,mark options={color=%s}," % color_dict[key]             # <<<<<<<<<<<<<<
 *             s += "mark size=%s]\n" % marksize
 *             s += "coordinates {\n"
 */
    __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_color_dict, __pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1910, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_addplot_only_marks_mark_mark_op, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1910, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1910, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":1911
 * 
 *             s += "\\addplot+[only marks,mark=*,mark options={color=%s}," % color_dict[key]
 *             s += "mark size=%s]\n" % marksize             # <<<<<<<<<<<<<<
 *             s += "coordinates {\n"
 *             s += '\n'.join(map(str, value))
 */
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_mark_size_s_2, __pyx_v_marksize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1911, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1911, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "slabbe/mult_cont_frac.pyx":1912
 *             s += "\\addplot+[only marks,mark=*,mark options={color=%s}," % color_dict[key]
 *             s += "mark size=%s]\n" % marksize
 *             s += "coordinates {\n"             # <<<<<<<<<<<<<<
 *             s += '\n'.join(map(str, value))
 *             s += "};\n"
 */
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_kp_s_coordinates); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1912, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "slabbe/mult_cont_frac.pyx":1913
 *             s += "mark size=%s]\n" % marksize
 *             s += "coordinates {\n"
 *             s += '\n'.join(map(str, value))             # <<<<<<<<<<<<<<
 *             s += "};\n"
 *             s += "\\addlegendentry{%s}\n " % key
 */
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1913, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)(&PyString_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyString_Type)));
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_value);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1913, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Join(__pyx_kp_s__27, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1913, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1913, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":1914
 *             s += "coordinates {\n"
 *             s += '\n'.join(map(str, value))
 *             s += "};\n"             # <<<<<<<<<<<<<<
 *             s += "\\addlegendentry{%s}\n " % key
 *         s += "\\end{axis}\n"
 */
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_kp_s__29); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1914, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":1915
 *             s += '\n'.join(map(str, value))
 *             s += "};\n"
 *             s += "\\addlegendentry{%s}\n " % key             # <<<<<<<<<<<<<<
 *         s += "\\end{axis}\n"
 *         s += "\\end{tikzpicture}\n"
 */
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_addlegendentry_s_2, __pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1915, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1915, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1916
 *             s += "};\n"
 *             s += "\\addlegendentry{%s}\n " % key
 *         s += "\\end{axis}\n"             # <<<<<<<<<<<<<<
 *         s += "\\end{tikzpicture}\n"
 *         from slabbe import TikzPicture
 */
  __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_kp_s_end_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1916, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1917
 *             s += "\\addlegendentry{%s}\n " % key
 *         s += "\\end{axis}\n"
 *         s += "\\end{tikzpicture}\n"             # <<<<<<<<<<<<<<
 *         from slabbe import TikzPicture
 *         return TikzPicture(s, packages=['pgfplots'])
 */
  __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_kp_s_end_tikzpicture_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1917, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1918
 *         s += "\\end{axis}\n"
 *         s += "\\end{tikzpicture}\n"
 *         from slabbe import TikzPicture             # <<<<<<<<<<<<<<
 *         return TikzPicture(s, packages=['pgfplots'])
 * 
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1918, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_TikzPicture);
  __Pyx_GIVEREF(__pyx_n_s_TikzPicture);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_TikzPicture);
  __pyx_t_4 = __Pyx_Import(__pyx_n_s_slabbe, __pyx_t_3, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1918, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_TikzPicture); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1918, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_TikzPicture = __pyx_t_3;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "slabbe/mult_cont_frac.pyx":1919
 *         s += "\\end{tikzpicture}\n"
 *         from slabbe import TikzPicture
 *         return TikzPicture(s, packages=['pgfplots'])             # <<<<<<<<<<<<<<
 * 
 *     def natural_extension_part_png(self, n_iterations, draw,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1919, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_s);
  __Pyx_GIVEREF(__pyx_v_s);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_s);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1919, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1919, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_pgfplots);
  __Pyx_GIVEREF(__pyx_n_s_pgfplots);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_pgfplots);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_packages, __pyx_t_2) < 0) __PYX_ERR(0, 1919, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_TikzPicture, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1919, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":1841
 *                 tikzlibraries=['pgfplots.groupplots'])
 * 
 *     def natural_extension_part_tikz(self, n_iterations, part=3,             # <<<<<<<<<<<<<<
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     marksize='1pt', limit_nb_points=None,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_part_tikz", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_domain_left);
  __Pyx_XDECREF(__pyx_v_image_left);
  __Pyx_XDECREF(__pyx_v_domain_right);
  __Pyx_XDECREF(__pyx_v_image_right);
  __Pyx_XDECREF(__pyx_v_color_dict);
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_TikzPicture);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1921
 *         return TikzPicture(s, packages=['pgfplots'])
 * 
 *     def natural_extension_part_png(self, n_iterations, draw,             # <<<<<<<<<<<<<<
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     xrange=(-.866, .866),
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_66natural_extension_part_png(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_65natural_extension_part_png[] = "\n        Return a png or some part of an orbit in the natural extension.\n\n        INPUT:\n\n        - ``n_iterations`` - integer, number of iterations\n        - ``draw`` -- string (default: ``'image_right'``), possible values\n          are:\n\n          - ``'domain_left'`` - use x and y ranges\n          - ``'domain_right'`` - use u and v ranges\n          - ``'image_left'`` - use x and y ranges\n          - ``'image_right'`` - use u and v ranges\n\n        - ``norm_xyz`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit points\n        - ``norm_uvw`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the dual orbit points\n        - ``xrange`` -- tuple (default: ``(-.866, .866)``), interval of\n          values for x\n        - ``yrange`` -- tuple (default: ``(-.5, 1.)``), interval of\n          values for y\n        - ``urange`` -- tuple (default: ``(-.866, .866)``), interval of\n          values for u\n        - ``vrange`` -- tuple (default: ``(-.5, 1.)``), interval of\n          values for v\n        - ``color_dict`` -- dict (default: ``None``), dict from branches\n          int to color (as RGB tuples)\n        - ``branch_order`` -- list (default: ``None``), list of branches int\n        - ``ndivs`` -- int (default: ``1024``), number of pixels\n        - ``verbose`` -- string (default: ``False``)\n\n        BENCHMARK:\n\n        A minute (1min 13s) for a picture with 10^7 points::\n\n            sage: from slabbe.mult_cont_frac import ARP\n            sage: c = {}\n            sage: c[1] = c[2] = c[3] = [0,0,0]\n            sage: c[12] = c[13] = c[23] = c[21] = c[31] = c[32] = [255,0,0]\n            sage: b = [1,2,3,12,13,21,23,31,32]\n            sage: P = ARP().natural_extension_part_png(10^7, draw='image_right',  # not tested\n            ....:   branch_order=b, color_dict=c, urange=(-.6,.6), vrange=(-.6,.6))  # not tested\n\n        Half a minute (27s) for a picture zo""omed in the orbit of 10^8\n        points::\n\n            sage: P = ARP().natural_extension_part_png(10^8, draw='image_right', # not tested\n            ....:   branch_order=b, color_dict=c, urange=(.2,.3), vrange=(.2,.3))   # not tested\n\n        EXAMPLES::\n\n            sage: c = {}\n            sage: c[1] = c[2] = c[3] = [0,0,0]\n            sage: c[123] = c[132] = c[231] = c[213] = c[312] = c[321] = [255,0,0]\n            sage: b = [1,2,3,123,132,213,231,312,321]\n            sage: opt = dict(urange=(-.6,.6), vrange=(-.6,.6), color_dict=c, branch_order=b)\n            sage: P = ARP().natural_extension_part_png(10^5, draw='domain_left', **opt)\n            sage: P = ARP().natural_extension_part_png(10^5, draw='domain_right', **opt)\n            sage: P = ARP().natural_extension_part_png(10^5, draw='image_left', **opt)\n            sage: P = ARP().natural_extension_part_png(10^5, draw='image_right', **opt)\n            sage: P.show() # not tested\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_66natural_extension_part_png(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_n_iterations = 0;
  PyObject *__pyx_v_draw = 0;
  PyObject *__pyx_v_norm_xyz = 0;
  PyObject *__pyx_v_norm_uvw = 0;
  PyObject *__pyx_v_xrange = 0;
  PyObject *__pyx_v_yrange = 0;
  PyObject *__pyx_v_urange = 0;
  PyObject *__pyx_v_vrange = 0;
  PyObject *__pyx_v_color_dict = 0;
  PyObject *__pyx_v_branch_order = 0;
  PyObject *__pyx_v_ndivs = 0;
  CYTHON_UNUSED PyObject *__pyx_v_verbose = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("natural_extension_part_png (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,&__pyx_n_s_draw,&__pyx_n_s_norm_xyz,&__pyx_n_s_norm_uvw,&__pyx_n_s_xrange,&__pyx_n_s_yrange,&__pyx_n_s_urange,&__pyx_n_s_vrange,&__pyx_n_s_color_dict,&__pyx_n_s_branch_order,&__pyx_n_s_ndivs,&__pyx_n_s_verbose,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
    values[2] = ((PyObject *)__pyx_kp_s_1);
    values[3] = ((PyObject *)__pyx_kp_s_1);

    /* "slabbe/mult_cont_frac.pyx":1923
 *     def natural_extension_part_png(self, n_iterations, draw,
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     xrange=(-.866, .866),             # <<<<<<<<<<<<<<
 *                                     yrange=(-.5, 1.),
 *                                     urange=(-.866, .866),
 */
    values[4] = ((PyObject *)__pyx_tuple__30);

    /* "slabbe/mult_cont_frac.pyx":1924
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     xrange=(-.866, .866),
 *                                     yrange=(-.5, 1.),             # <<<<<<<<<<<<<<
 *                                     urange=(-.866, .866),
 *                                     vrange=(-.5, 1.),
 */
    values[5] = ((PyObject *)__pyx_tuple__31);

    /* "slabbe/mult_cont_frac.pyx":1925
 *                                     xrange=(-.866, .866),
 *                                     yrange=(-.5, 1.),
 *                                     urange=(-.866, .866),             # <<<<<<<<<<<<<<
 *                                     vrange=(-.5, 1.),
 *                                     color_dict=None,
 */
    values[6] = ((PyObject *)__pyx_tuple__32);

    /* "slabbe/mult_cont_frac.pyx":1926
 *                                     yrange=(-.5, 1.),
 *                                     urange=(-.866, .866),
 *                                     vrange=(-.5, 1.),             # <<<<<<<<<<<<<<
 *                                     color_dict=None,
 *                                     branch_order=None,
 */
    values[7] = ((PyObject *)__pyx_tuple__33);

    /* "slabbe/mult_cont_frac.pyx":1927
 *                                     urange=(-.866, .866),
 *                                     vrange=(-.5, 1.),
 *                                     color_dict=None,             # <<<<<<<<<<<<<<
 *                                     branch_order=None,
 *                                     ndivs=1024,
 */
    values[8] = ((PyObject *)Py_None);

    /* "slabbe/mult_cont_frac.pyx":1928
 *                                     vrange=(-.5, 1.),
 *                                     color_dict=None,
 *                                     branch_order=None,             # <<<<<<<<<<<<<<
 *                                     ndivs=1024,
 *                                     verbose=False):
 */
    values[9] = ((PyObject *)Py_None);
    values[10] = ((PyObject *)__pyx_int_1024);

    /* "slabbe/mult_cont_frac.pyx":1930
 *                                     branch_order=None,
 *                                     ndivs=1024,
 *                                     verbose=False):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return a png or some part of an orbit in the natural extension.
 */
    values[11] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_draw)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("natural_extension_part_png", 0, 2, 12, 1); __PYX_ERR(0, 1921, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_xyz);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_uvw);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xrange);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_yrange);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_urange);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vrange);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_color_dict);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_branch_order);
          if (value) { values[9] = value; kw_args--; }
        }
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndivs);
          if (value) { values[10] = value; kw_args--; }
        }
        case 11:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_verbose);
          if (value) { values[11] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "natural_extension_part_png") < 0)) __PYX_ERR(0, 1921, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_n_iterations = values[0];
    __pyx_v_draw = values[1];
    __pyx_v_norm_xyz = values[2];
    __pyx_v_norm_uvw = values[3];
    __pyx_v_xrange = values[4];
    __pyx_v_yrange = values[5];
    __pyx_v_urange = values[6];
    __pyx_v_vrange = values[7];
    __pyx_v_color_dict = values[8];
    __pyx_v_branch_order = values[9];
    __pyx_v_ndivs = values[10];
    __pyx_v_verbose = values[11];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("natural_extension_part_png", 0, 2, 12, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1921, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_part_png", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_65natural_extension_part_png(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations, __pyx_v_draw, __pyx_v_norm_xyz, __pyx_v_norm_uvw, __pyx_v_xrange, __pyx_v_yrange, __pyx_v_urange, __pyx_v_vrange, __pyx_v_color_dict, __pyx_v_branch_order, __pyx_v_ndivs, __pyx_v_verbose);

  /* "slabbe/mult_cont_frac.pyx":1921
 *         return TikzPicture(s, packages=['pgfplots'])
 * 
 *     def natural_extension_part_png(self, n_iterations, draw,             # <<<<<<<<<<<<<<
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     xrange=(-.866, .866),
 */

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

/* "slabbe/mult_cont_frac.pyx":2020
 * 
 *         if draw.startswith('domain'):
 *             L.sort(key=lambda a:branch_order.index(a[5]))             # <<<<<<<<<<<<<<
 *         elif draw.startswith('image'):
 *             L.sort(key=lambda a:branch_order.index(a[4]))
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_26natural_extension_part_png_lambda4(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static PyMethodDef __pyx_mdef_6slabbe_14mult_cont_frac_12MCFAlgorithm_26natural_extension_part_png_lambda4 = {"lambda4", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_26natural_extension_part_png_lambda4, METH_O, 0};
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_26natural_extension_part_png_lambda4(PyObject *__pyx_self, PyObject *__pyx_v_a) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda4 (wrapper)", 0);
  __pyx_r = __pyx_lambda_funcdef_lambda4(__pyx_self, ((PyObject *)__pyx_v_a));

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

static PyObject *__pyx_lambda_funcdef_lambda4(PyObject *__pyx_self, PyObject *__pyx_v_a) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *__pyx_cur_scope;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("lambda4", 0);
  __pyx_outer_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_branch_order)) { __Pyx_RaiseClosureNameError("branch_order"); __PYX_ERR(0, 2020, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_branch_order, __pyx_n_s_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2020, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_a, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2020, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2020, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2020, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2020, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_part_png.lambda4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2022
 *             L.sort(key=lambda a:branch_order.index(a[5]))
 *         elif draw.startswith('image'):
 *             L.sort(key=lambda a:branch_order.index(a[4]))             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Unkown value for draw(={})".format(draw))
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_26natural_extension_part_png_1lambda5(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static PyMethodDef __pyx_mdef_6slabbe_14mult_cont_frac_12MCFAlgorithm_26natural_extension_part_png_1lambda5 = {"lambda5", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_26natural_extension_part_png_1lambda5, METH_O, 0};
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_26natural_extension_part_png_1lambda5(PyObject *__pyx_self, PyObject *__pyx_v_a) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda5 (wrapper)", 0);
  __pyx_r = __pyx_lambda_funcdef_lambda5(__pyx_self, ((PyObject *)__pyx_v_a));

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

static PyObject *__pyx_lambda_funcdef_lambda5(PyObject *__pyx_self, PyObject *__pyx_v_a) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *__pyx_cur_scope;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("lambda5", 0);
  __pyx_outer_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_branch_order)) { __Pyx_RaiseClosureNameError("branch_order"); __PYX_ERR(0, 2022, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_branch_order, __pyx_n_s_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2022, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_a, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2022, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2022, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2022, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2022, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_part_png.lambda5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":1921
 *         return TikzPicture(s, packages=['pgfplots'])
 * 
 *     def natural_extension_part_png(self, n_iterations, draw,             # <<<<<<<<<<<<<<
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     xrange=(-.866, .866),
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_65natural_extension_part_png(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_draw, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_xrange, PyObject *__pyx_v_yrange, PyObject *__pyx_v_urange, PyObject *__pyx_v_vrange, PyObject *__pyx_v_color_dict, PyObject *__pyx_v_branch_order, PyObject *__pyx_v_ndivs, CYTHON_UNUSED PyObject *__pyx_v_verbose) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *__pyx_cur_scope;
  PyObject *__pyx_v_L = NULL;
  PyObject *__pyx_v_randint = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_np = NULL;
  PyObject *__pyx_v_smp = NULL;
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_v_u = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_v_prev_br = NULL;
  PyObject *__pyx_v_next_br = NULL;
  PyObject *__pyx_v_img = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  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)(PyObject *);
  __Pyx_RefNannySetupContext("natural_extension_part_png", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_branch_order = __pyx_v_branch_order;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_branch_order);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_branch_order);
  __Pyx_INCREF(__pyx_v_color_dict);

  /* "slabbe/mult_cont_frac.pyx":1995
 * 
 *         """
 *         L = self.simplex_orbit_filtered_list(n_iterations=n_iterations,             # <<<<<<<<<<<<<<
 *             norm_xyz=norm_xyz, norm_uvw=norm_uvw,
 *             xmin=xrange[0], xmax=xrange[1],
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_simplex_orbit_filtered_list); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_n_iterations, __pyx_v_n_iterations) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1996
 *         """
 *         L = self.simplex_orbit_filtered_list(n_iterations=n_iterations,
 *             norm_xyz=norm_xyz, norm_uvw=norm_uvw,             # <<<<<<<<<<<<<<
 *             xmin=xrange[0], xmax=xrange[1],
 *             ymin=yrange[0], ymax=yrange[1],
 */
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_norm_xyz, __pyx_v_norm_xyz) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_norm_uvw, __pyx_v_norm_uvw) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1997
 *         L = self.simplex_orbit_filtered_list(n_iterations=n_iterations,
 *             norm_xyz=norm_xyz, norm_uvw=norm_uvw,
 *             xmin=xrange[0], xmax=xrange[1],             # <<<<<<<<<<<<<<
 *             ymin=yrange[0], ymax=yrange[1],
 *             umin=urange[0], umax=urange[1],
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_xrange, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_xmin, __pyx_t_3) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_xrange, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_xmax, __pyx_t_3) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1998
 *             norm_xyz=norm_xyz, norm_uvw=norm_uvw,
 *             xmin=xrange[0], xmax=xrange[1],
 *             ymin=yrange[0], ymax=yrange[1],             # <<<<<<<<<<<<<<
 *             umin=urange[0], umax=urange[1],
 *             vmin=vrange[0], vmax=vrange[1],
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_yrange, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1998, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_ymin, __pyx_t_3) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_yrange, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1998, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_ymax, __pyx_t_3) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":1999
 *             xmin=xrange[0], xmax=xrange[1],
 *             ymin=yrange[0], ymax=yrange[1],
 *             umin=urange[0], umax=urange[1],             # <<<<<<<<<<<<<<
 *             vmin=vrange[0], vmax=vrange[1],
 *             ndivs=ndivs)
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_urange, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1999, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_umin, __pyx_t_3) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_urange, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1999, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_umax, __pyx_t_3) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":2000
 *             ymin=yrange[0], ymax=yrange[1],
 *             umin=urange[0], umax=urange[1],
 *             vmin=vrange[0], vmax=vrange[1],             # <<<<<<<<<<<<<<
 *             ndivs=ndivs)
 *         if branch_order is None:
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_vrange, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2000, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_vmin, __pyx_t_3) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_vrange, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2000, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_vmax, __pyx_t_3) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":2001
 *             umin=urange[0], umax=urange[1],
 *             vmin=vrange[0], vmax=vrange[1],
 *             ndivs=ndivs)             # <<<<<<<<<<<<<<
 *         if branch_order is None:
 *             branch_order = []
 */
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_ndivs, __pyx_v_ndivs) < 0) __PYX_ERR(0, 1995, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1995
 * 
 *         """
 *         L = self.simplex_orbit_filtered_list(n_iterations=n_iterations,             # <<<<<<<<<<<<<<
 *             norm_xyz=norm_xyz, norm_uvw=norm_uvw,
 *             xmin=xrange[0], xmax=xrange[1],
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_L = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":2002
 *             vmin=vrange[0], vmax=vrange[1],
 *             ndivs=ndivs)
 *         if branch_order is None:             # <<<<<<<<<<<<<<
 *             branch_order = []
 *             raise NotImplementedError
 */
  __pyx_t_4 = (__pyx_cur_scope->__pyx_v_branch_order == Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "slabbe/mult_cont_frac.pyx":2003
 *             ndivs=ndivs)
 *         if branch_order is None:
 *             branch_order = []             # <<<<<<<<<<<<<<
 *             raise NotImplementedError
 *         if color_dict is None:
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2003, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_branch_order);
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_branch_order, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "slabbe/mult_cont_frac.pyx":2004
 *         if branch_order is None:
 *             branch_order = []
 *             raise NotImplementedError             # <<<<<<<<<<<<<<
 *         if color_dict is None:
 *             from random import randint
 */
    __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
    __PYX_ERR(0, 2004, __pyx_L1_error)

    /* "slabbe/mult_cont_frac.pyx":2002
 *             vmin=vrange[0], vmax=vrange[1],
 *             ndivs=ndivs)
 *         if branch_order is None:             # <<<<<<<<<<<<<<
 *             branch_order = []
 *             raise NotImplementedError
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2005
 *             branch_order = []
 *             raise NotImplementedError
 *         if color_dict is None:             # <<<<<<<<<<<<<<
 *             from random import randint
 *             color_dict = {}
 */
  __pyx_t_5 = (__pyx_v_color_dict == Py_None);
  __pyx_t_4 = (__pyx_t_5 != 0);
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":2006
 *             raise NotImplementedError
 *         if color_dict is None:
 *             from random import randint             # <<<<<<<<<<<<<<
 *             color_dict = {}
 *             for key in branch_order:
 */
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2006, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_n_s_randint);
    __Pyx_GIVEREF(__pyx_n_s_randint);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_randint);
    __pyx_t_2 = __Pyx_Import(__pyx_n_s_random, __pyx_t_3, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2006, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_randint); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2006, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_randint = __pyx_t_3;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":2007
 *         if color_dict is None:
 *             from random import randint
 *             color_dict = {}             # <<<<<<<<<<<<<<
 *             for key in branch_order:
 *                 color_dict[key] = [randint(0,255),randint(0,255),randint(0,255)]
 */
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2007, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_color_dict, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":2008
 *             from random import randint
 *             color_dict = {}
 *             for key in branch_order:             # <<<<<<<<<<<<<<
 *                 color_dict[key] = [randint(0,255),randint(0,255),randint(0,255)]
 * 
 */
    if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_branch_order)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_branch_order)) {
      __pyx_t_2 = __pyx_cur_scope->__pyx_v_branch_order; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_branch_order); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2008, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2008, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2008, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2008, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2008, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2008, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_7(__pyx_t_2);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2008, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "slabbe/mult_cont_frac.pyx":2009
 *             color_dict = {}
 *             for key in branch_order:
 *                 color_dict[key] = [randint(0,255),randint(0,255),randint(0,255)]             # <<<<<<<<<<<<<<
 * 
 *         #http://stackoverflow.com/questions/434583/what-is-the-fastest-way-to-draw-an-image-from-discrete-pixel-values-in-python
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_randint, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2009, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_randint, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2009, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_v_randint, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2009, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyList_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2009, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyList_SET_ITEM(__pyx_t_9, 1, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_8);
      PyList_SET_ITEM(__pyx_t_9, 2, __pyx_t_8);
      __pyx_t_3 = 0;
      __pyx_t_1 = 0;
      __pyx_t_8 = 0;
      if (unlikely(PyObject_SetItem(__pyx_v_color_dict, __pyx_v_key, __pyx_t_9) < 0)) __PYX_ERR(0, 2009, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "slabbe/mult_cont_frac.pyx":2008
 *             from random import randint
 *             color_dict = {}
 *             for key in branch_order:             # <<<<<<<<<<<<<<
 *                 color_dict[key] = [randint(0,255),randint(0,255),randint(0,255)]
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":2005
 *             branch_order = []
 *             raise NotImplementedError
 *         if color_dict is None:             # <<<<<<<<<<<<<<
 *             from random import randint
 *             color_dict = {}
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2012
 * 
 *         #http://stackoverflow.com/questions/434583/what-is-the-fastest-way-to-draw-an-image-from-discrete-pixel-values-in-python
 *         import numpy as np             # <<<<<<<<<<<<<<
 *         import scipy.misc as smp
 * 
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2012, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_np = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2013
 *         #http://stackoverflow.com/questions/434583/what-is-the-fastest-way-to-draw-an-image-from-discrete-pixel-values-in-python
 *         import numpy as np
 *         import scipy.misc as smp             # <<<<<<<<<<<<<<
 * 
 *         # Create a 1024x1024x3 array of 8 bit unsigned integers
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s__17);
  __Pyx_GIVEREF(__pyx_n_s__17);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s__17);
  __pyx_t_9 = __Pyx_Import(__pyx_n_s_scipy_misc, __pyx_t_2, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_smp = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "slabbe/mult_cont_frac.pyx":2016
 * 
 *         # Create a 1024x1024x3 array of 8 bit unsigned integers
 *         data = np.zeros( (ndivs,ndivs,3), dtype=np.uint8 )             # <<<<<<<<<<<<<<
 *         data += 255   # white as default color
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_np, __pyx_n_s_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_ndivs);
  __Pyx_GIVEREF(__pyx_v_ndivs);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_ndivs);
  __Pyx_INCREF(__pyx_v_ndivs);
  __Pyx_GIVEREF(__pyx_v_ndivs);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_ndivs);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_3);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_np, __pyx_n_s_uint8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 2016, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_data = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2017
 *         # Create a 1024x1024x3 array of 8 bit unsigned integers
 *         data = np.zeros( (ndivs,ndivs,3), dtype=np.uint8 )
 *         data += 255   # white as default color             # <<<<<<<<<<<<<<
 * 
 *         if draw.startswith('domain'):
 */
  __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_data, __pyx_int_255, 0xFF, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2017, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2019
 *         data += 255   # white as default color
 * 
 *         if draw.startswith('domain'):             # <<<<<<<<<<<<<<
 *             L.sort(key=lambda a:branch_order.index(a[5]))
 *         elif draw.startswith('image'):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_draw, __pyx_n_s_startswith); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2019, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2019, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2019, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":2020
 * 
 *         if draw.startswith('domain'):
 *             L.sort(key=lambda a:branch_order.index(a[5]))             # <<<<<<<<<<<<<<
 *         elif draw.startswith('image'):
 *             L.sort(key=lambda a:branch_order.index(a[4]))
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_L, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2020, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2020, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6slabbe_14mult_cont_frac_12MCFAlgorithm_26natural_extension_part_png_lambda4, 0, __pyx_n_s_natural_extension_part_png_local, ((PyObject*)__pyx_cur_scope), __pyx_n_s_slabbe_mult_cont_frac, __pyx_d, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2020, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_key, __pyx_t_8) < 0) __PYX_ERR(0, 2020, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2020, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "slabbe/mult_cont_frac.pyx":2019
 *         data += 255   # white as default color
 * 
 *         if draw.startswith('domain'):             # <<<<<<<<<<<<<<
 *             L.sort(key=lambda a:branch_order.index(a[5]))
 *         elif draw.startswith('image'):
 */
    goto __pyx_L7;
  }

  /* "slabbe/mult_cont_frac.pyx":2021
 *         if draw.startswith('domain'):
 *             L.sort(key=lambda a:branch_order.index(a[5]))
 *         elif draw.startswith('image'):             # <<<<<<<<<<<<<<
 *             L.sort(key=lambda a:branch_order.index(a[4]))
 *         else:
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_draw, __pyx_n_s_startswith); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2021, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":2022
 *             L.sort(key=lambda a:branch_order.index(a[5]))
 *         elif draw.startswith('image'):
 *             L.sort(key=lambda a:branch_order.index(a[4]))             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Unkown value for draw(={})".format(draw))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_L, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2022, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2022, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6slabbe_14mult_cont_frac_12MCFAlgorithm_26natural_extension_part_png_1lambda5, 0, __pyx_n_s_natural_extension_part_png_local, ((PyObject*)__pyx_cur_scope), __pyx_n_s_slabbe_mult_cont_frac, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2022, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_key, __pyx_t_2) < 0) __PYX_ERR(0, 2022, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2022, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":2021
 *         if draw.startswith('domain'):
 *             L.sort(key=lambda a:branch_order.index(a[5]))
 *         elif draw.startswith('image'):             # <<<<<<<<<<<<<<
 *             L.sort(key=lambda a:branch_order.index(a[4]))
 *         else:
 */
    goto __pyx_L7;
  }

  /* "slabbe/mult_cont_frac.pyx":2024
 *             L.sort(key=lambda a:branch_order.index(a[4]))
 *         else:
 *             raise ValueError("Unkown value for draw(={})".format(draw))             # <<<<<<<<<<<<<<
 * 
 *         if draw == 'domain_left':
 */
  /*else*/ {
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unkown_value_for_draw, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2024, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_draw); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2024, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2024, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_INCREF(__pyx_v_draw);
      __Pyx_GIVEREF(__pyx_v_draw);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_draw);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2024, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2024, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2024, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 2024, __pyx_L1_error)
  }
  __pyx_L7:;

  /* "slabbe/mult_cont_frac.pyx":2026
 *             raise ValueError("Unkown value for draw(={})".format(draw))
 * 
 *         if draw == 'domain_left':             # <<<<<<<<<<<<<<
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[y,x] = color_dict[next_br]
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_draw, __pyx_n_s_domain_left, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2026, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":2027
 * 
 *         if draw == 'domain_left':
 *             for x,y,u,v,prev_br,next_br in L:             # <<<<<<<<<<<<<<
 *                 data[y,x] = color_dict[next_br]
 *         elif draw == 'domain_right':
 */
    if (likely(PyList_CheckExact(__pyx_v_L)) || PyTuple_CheckExact(__pyx_v_L)) {
      __pyx_t_2 = __pyx_v_L; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_L); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2027, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2027, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2027, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2027, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2027, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2027, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        }
      } else {
        __pyx_t_8 = __pyx_t_7(__pyx_t_2);
        if (unlikely(!__pyx_t_8)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2027, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_8);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
        PyObject* sequence = __pyx_t_8;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 6)) {
          if (size > 6) __Pyx_RaiseTooManyValuesError(6);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 2027, __pyx_L1_error)
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3); 
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 4); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 5); 
        } else {
          __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 3); 
          __pyx_t_11 = PyList_GET_ITEM(sequence, 4); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 5); 
        }
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_12);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[6] = {&__pyx_t_9,&__pyx_t_1,&__pyx_t_3,&__pyx_t_10,&__pyx_t_11,&__pyx_t_12};
          for (i=0; i < 6; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 2027, __pyx_L1_error)
            __Pyx_GOTREF(item);
            *(temps[i]) = item;
          }
        }
        #endif
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        Py_ssize_t index = -1;
        PyObject** temps[6] = {&__pyx_t_9,&__pyx_t_1,&__pyx_t_3,&__pyx_t_10,&__pyx_t_11,&__pyx_t_12};
        __pyx_t_13 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2027, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
        for (index=0; index < 6; index++) {
          PyObject* item = __pyx_t_14(__pyx_t_13); if (unlikely(!item)) goto __pyx_L11_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 6) < 0) __PYX_ERR(0, 2027, __pyx_L1_error)
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L12_unpacking_done;
        __pyx_L11_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 2027, __pyx_L1_error)
        __pyx_L12_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_9);
      __pyx_t_9 = 0;
      __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_u, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_10);
      __pyx_t_10 = 0;
      __Pyx_XDECREF_SET(__pyx_v_prev_br, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_XDECREF_SET(__pyx_v_next_br, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "slabbe/mult_cont_frac.pyx":2028
 *         if draw == 'domain_left':
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[y,x] = color_dict[next_br]             # <<<<<<<<<<<<<<
 *         elif draw == 'domain_right':
 *             for x,y,u,v,prev_br,next_br in L:
 */
      __pyx_t_8 = PyObject_GetItem(__pyx_v_color_dict, __pyx_v_next_br); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2028, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2028, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_y);
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_x);
      if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_t_12, __pyx_t_8) < 0)) __PYX_ERR(0, 2028, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "slabbe/mult_cont_frac.pyx":2027
 * 
 *         if draw == 'domain_left':
 *             for x,y,u,v,prev_br,next_br in L:             # <<<<<<<<<<<<<<
 *                 data[y,x] = color_dict[next_br]
 *         elif draw == 'domain_right':
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":2026
 *             raise ValueError("Unkown value for draw(={})".format(draw))
 * 
 *         if draw == 'domain_left':             # <<<<<<<<<<<<<<
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[y,x] = color_dict[next_br]
 */
    goto __pyx_L8;
  }

  /* "slabbe/mult_cont_frac.pyx":2029
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[y,x] = color_dict[next_br]
 *         elif draw == 'domain_right':             # <<<<<<<<<<<<<<
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[v,u] = color_dict[next_br]
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_draw, __pyx_n_s_domain_right, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2029, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":2030
 *                 data[y,x] = color_dict[next_br]
 *         elif draw == 'domain_right':
 *             for x,y,u,v,prev_br,next_br in L:             # <<<<<<<<<<<<<<
 *                 data[v,u] = color_dict[next_br]
 *         elif draw == 'image_left':
 */
    if (likely(PyList_CheckExact(__pyx_v_L)) || PyTuple_CheckExact(__pyx_v_L)) {
      __pyx_t_2 = __pyx_v_L; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_L); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2030, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2030, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2030, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2030, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2030, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2030, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        }
      } else {
        __pyx_t_8 = __pyx_t_7(__pyx_t_2);
        if (unlikely(!__pyx_t_8)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2030, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_8);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
        PyObject* sequence = __pyx_t_8;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 6)) {
          if (size > 6) __Pyx_RaiseTooManyValuesError(6);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 2030, __pyx_L1_error)
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 3); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 4); 
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 5); 
        } else {
          __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 3); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 4); 
          __pyx_t_9 = PyList_GET_ITEM(sequence, 5); 
        }
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_9);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[6] = {&__pyx_t_12,&__pyx_t_11,&__pyx_t_10,&__pyx_t_3,&__pyx_t_1,&__pyx_t_9};
          for (i=0; i < 6; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 2030, __pyx_L1_error)
            __Pyx_GOTREF(item);
            *(temps[i]) = item;
          }
        }
        #endif
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        Py_ssize_t index = -1;
        PyObject** temps[6] = {&__pyx_t_12,&__pyx_t_11,&__pyx_t_10,&__pyx_t_3,&__pyx_t_1,&__pyx_t_9};
        __pyx_t_13 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2030, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
        for (index=0; index < 6; index++) {
          PyObject* item = __pyx_t_14(__pyx_t_13); if (unlikely(!item)) goto __pyx_L15_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 6) < 0) __PYX_ERR(0, 2030, __pyx_L1_error)
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 2030, __pyx_L1_error)
        __pyx_L16_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_12);
      __pyx_t_12 = 0;
      __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_XDECREF_SET(__pyx_v_u, __pyx_t_10);
      __pyx_t_10 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_prev_br, __pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_next_br, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "slabbe/mult_cont_frac.pyx":2031
 *         elif draw == 'domain_right':
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[v,u] = color_dict[next_br]             # <<<<<<<<<<<<<<
 *         elif draw == 'image_left':
 *             for x,y,u,v,prev_br,next_br in L:
 */
      __pyx_t_8 = PyObject_GetItem(__pyx_v_color_dict, __pyx_v_next_br); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2031, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2031, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_v);
      __Pyx_INCREF(__pyx_v_u);
      __Pyx_GIVEREF(__pyx_v_u);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_u);
      if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_t_9, __pyx_t_8) < 0)) __PYX_ERR(0, 2031, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "slabbe/mult_cont_frac.pyx":2030
 *                 data[y,x] = color_dict[next_br]
 *         elif draw == 'domain_right':
 *             for x,y,u,v,prev_br,next_br in L:             # <<<<<<<<<<<<<<
 *                 data[v,u] = color_dict[next_br]
 *         elif draw == 'image_left':
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":2029
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[y,x] = color_dict[next_br]
 *         elif draw == 'domain_right':             # <<<<<<<<<<<<<<
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[v,u] = color_dict[next_br]
 */
    goto __pyx_L8;
  }

  /* "slabbe/mult_cont_frac.pyx":2032
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[v,u] = color_dict[next_br]
 *         elif draw == 'image_left':             # <<<<<<<<<<<<<<
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[y,x] = color_dict[prev_br]
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_draw, __pyx_n_s_image_left, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2032, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":2033
 *                 data[v,u] = color_dict[next_br]
 *         elif draw == 'image_left':
 *             for x,y,u,v,prev_br,next_br in L:             # <<<<<<<<<<<<<<
 *                 data[y,x] = color_dict[prev_br]
 *         elif draw == 'image_right':
 */
    if (likely(PyList_CheckExact(__pyx_v_L)) || PyTuple_CheckExact(__pyx_v_L)) {
      __pyx_t_2 = __pyx_v_L; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_L); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2033, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2033, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2033, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2033, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2033, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2033, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        }
      } else {
        __pyx_t_8 = __pyx_t_7(__pyx_t_2);
        if (unlikely(!__pyx_t_8)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2033, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_8);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
        PyObject* sequence = __pyx_t_8;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 6)) {
          if (size > 6) __Pyx_RaiseTooManyValuesError(6);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 2033, __pyx_L1_error)
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3); 
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 4); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 5); 
        } else {
          __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 3); 
          __pyx_t_11 = PyList_GET_ITEM(sequence, 4); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 5); 
        }
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_12);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[6] = {&__pyx_t_9,&__pyx_t_1,&__pyx_t_3,&__pyx_t_10,&__pyx_t_11,&__pyx_t_12};
          for (i=0; i < 6; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 2033, __pyx_L1_error)
            __Pyx_GOTREF(item);
            *(temps[i]) = item;
          }
        }
        #endif
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        Py_ssize_t index = -1;
        PyObject** temps[6] = {&__pyx_t_9,&__pyx_t_1,&__pyx_t_3,&__pyx_t_10,&__pyx_t_11,&__pyx_t_12};
        __pyx_t_13 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2033, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
        for (index=0; index < 6; index++) {
          PyObject* item = __pyx_t_14(__pyx_t_13); if (unlikely(!item)) goto __pyx_L19_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 6) < 0) __PYX_ERR(0, 2033, __pyx_L1_error)
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L20_unpacking_done;
        __pyx_L19_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 2033, __pyx_L1_error)
        __pyx_L20_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_9);
      __pyx_t_9 = 0;
      __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_u, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_10);
      __pyx_t_10 = 0;
      __Pyx_XDECREF_SET(__pyx_v_prev_br, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_XDECREF_SET(__pyx_v_next_br, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "slabbe/mult_cont_frac.pyx":2034
 *         elif draw == 'image_left':
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[y,x] = color_dict[prev_br]             # <<<<<<<<<<<<<<
 *         elif draw == 'image_right':
 *             for x,y,u,v,prev_br,next_br in L:
 */
      __pyx_t_8 = PyObject_GetItem(__pyx_v_color_dict, __pyx_v_prev_br); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2034, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2034, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_y);
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_x);
      if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_t_12, __pyx_t_8) < 0)) __PYX_ERR(0, 2034, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "slabbe/mult_cont_frac.pyx":2033
 *                 data[v,u] = color_dict[next_br]
 *         elif draw == 'image_left':
 *             for x,y,u,v,prev_br,next_br in L:             # <<<<<<<<<<<<<<
 *                 data[y,x] = color_dict[prev_br]
 *         elif draw == 'image_right':
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":2032
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[v,u] = color_dict[next_br]
 *         elif draw == 'image_left':             # <<<<<<<<<<<<<<
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[y,x] = color_dict[prev_br]
 */
    goto __pyx_L8;
  }

  /* "slabbe/mult_cont_frac.pyx":2035
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[y,x] = color_dict[prev_br]
 *         elif draw == 'image_right':             # <<<<<<<<<<<<<<
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[v,u] = color_dict[prev_br]
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_draw, __pyx_n_s_image_right, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2035, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":2036
 *                 data[y,x] = color_dict[prev_br]
 *         elif draw == 'image_right':
 *             for x,y,u,v,prev_br,next_br in L:             # <<<<<<<<<<<<<<
 *                 data[v,u] = color_dict[prev_br]
 *         else:
 */
    if (likely(PyList_CheckExact(__pyx_v_L)) || PyTuple_CheckExact(__pyx_v_L)) {
      __pyx_t_2 = __pyx_v_L; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_L); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2036, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2036, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2036, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2036, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 2036, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2036, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        }
      } else {
        __pyx_t_8 = __pyx_t_7(__pyx_t_2);
        if (unlikely(!__pyx_t_8)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 2036, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_8);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
        PyObject* sequence = __pyx_t_8;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 6)) {
          if (size > 6) __Pyx_RaiseTooManyValuesError(6);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 2036, __pyx_L1_error)
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 3); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 4); 
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 5); 
        } else {
          __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 3); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 4); 
          __pyx_t_9 = PyList_GET_ITEM(sequence, 5); 
        }
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_9);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[6] = {&__pyx_t_12,&__pyx_t_11,&__pyx_t_10,&__pyx_t_3,&__pyx_t_1,&__pyx_t_9};
          for (i=0; i < 6; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 2036, __pyx_L1_error)
            __Pyx_GOTREF(item);
            *(temps[i]) = item;
          }
        }
        #endif
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        Py_ssize_t index = -1;
        PyObject** temps[6] = {&__pyx_t_12,&__pyx_t_11,&__pyx_t_10,&__pyx_t_3,&__pyx_t_1,&__pyx_t_9};
        __pyx_t_13 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2036, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
        for (index=0; index < 6; index++) {
          PyObject* item = __pyx_t_14(__pyx_t_13); if (unlikely(!item)) goto __pyx_L23_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 6) < 0) __PYX_ERR(0, 2036, __pyx_L1_error)
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L24_unpacking_done;
        __pyx_L23_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 2036, __pyx_L1_error)
        __pyx_L24_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_12);
      __pyx_t_12 = 0;
      __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_XDECREF_SET(__pyx_v_u, __pyx_t_10);
      __pyx_t_10 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_prev_br, __pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_next_br, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "slabbe/mult_cont_frac.pyx":2037
 *         elif draw == 'image_right':
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[v,u] = color_dict[prev_br]             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Unkown value for draw(={})".format(draw))
 */
      __pyx_t_8 = PyObject_GetItem(__pyx_v_color_dict, __pyx_v_prev_br); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2037, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2037, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_v);
      __Pyx_INCREF(__pyx_v_u);
      __Pyx_GIVEREF(__pyx_v_u);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_u);
      if (unlikely(PyObject_SetItem(__pyx_v_data, __pyx_t_9, __pyx_t_8) < 0)) __PYX_ERR(0, 2037, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "slabbe/mult_cont_frac.pyx":2036
 *                 data[y,x] = color_dict[prev_br]
 *         elif draw == 'image_right':
 *             for x,y,u,v,prev_br,next_br in L:             # <<<<<<<<<<<<<<
 *                 data[v,u] = color_dict[prev_br]
 *         else:
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":2035
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[y,x] = color_dict[prev_br]
 *         elif draw == 'image_right':             # <<<<<<<<<<<<<<
 *             for x,y,u,v,prev_br,next_br in L:
 *                 data[v,u] = color_dict[prev_br]
 */
    goto __pyx_L8;
  }

  /* "slabbe/mult_cont_frac.pyx":2039
 *                 data[v,u] = color_dict[prev_br]
 *         else:
 *             raise ValueError("Unkown value for draw(={})".format(draw))             # <<<<<<<<<<<<<<
 * 
 *         img = smp.toimage( data )       # Create a PIL image
 */
  /*else*/ {
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unkown_value_for_draw, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_draw); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2039, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2039, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); __pyx_t_9 = NULL;
      __Pyx_INCREF(__pyx_v_draw);
      __Pyx_GIVEREF(__pyx_v_draw);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_draw);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2039, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 2039, __pyx_L1_error)
  }
  __pyx_L8:;

  /* "slabbe/mult_cont_frac.pyx":2041
 *             raise ValueError("Unkown value for draw(={})".format(draw))
 * 
 *         img = smp.toimage( data )       # Create a PIL image             # <<<<<<<<<<<<<<
 *         #img.show()                      # View in default viewer
 *         return img
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_smp, __pyx_n_s_toimage); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2041, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2041, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2041, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __pyx_t_1 = NULL;
    __Pyx_INCREF(__pyx_v_data);
    __Pyx_GIVEREF(__pyx_v_data);
    PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_data);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2041, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_img = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2043
 *         img = smp.toimage( data )       # Create a PIL image
 *         #img.show()                      # View in default viewer
 *         return img             # <<<<<<<<<<<<<<
 * 
 *     def measure_evaluation(self, n_iterations, draw,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_img);
  __pyx_r = __pyx_v_img;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":1921
 *         return TikzPicture(s, packages=['pgfplots'])
 * 
 *     def natural_extension_part_png(self, n_iterations, draw,             # <<<<<<<<<<<<<<
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     xrange=(-.866, .866),
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.natural_extension_part_png", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_L);
  __Pyx_XDECREF(__pyx_v_randint);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_np);
  __Pyx_XDECREF(__pyx_v_smp);
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_u);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_prev_br);
  __Pyx_XDECREF(__pyx_v_next_br);
  __Pyx_XDECREF(__pyx_v_img);
  __Pyx_XDECREF(__pyx_v_color_dict);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2045
 *         return img
 * 
 *     def measure_evaluation(self, n_iterations, draw,             # <<<<<<<<<<<<<<
 *                                 norm_xyz='1', norm_uvw='1',
 *                                 xrange=(-.866, .866),
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_68measure_evaluation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_67measure_evaluation[] = "\n        Return the measure of a box according to an orbit.\n\n        INPUT:\n\n        - ``n_iterations`` - integer, number of iterations\n        - ``draw`` -- string (default: ``'image_right'``), possible values\n          are:\n\n          - ``'domain_left'`` - use x and y ranges\n          - ``'domain_right'`` - use u and v ranges\n          - ``'image_left'`` - use x and y ranges\n          - ``'image_right'`` - use u and v ranges\n\n        - ``norm_xyz`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the orbit points\n        - ``norm_uvw`` -- string (default: ``'1'``), either ``'sup'`` or\n          ``'1'``, the norm used for the dual orbit points\n        - ``xrange`` -- tuple (default: ``(-.866, .866)``), interval of\n          values for x\n        - ``yrange`` -- tuple (default: ``(-.5, 1.)``), interval of\n          values for y\n        - ``urange`` -- tuple (default: ``(-.866, .866)``), interval of\n          values for u\n        - ``vrange`` -- tuple (default: ``(-.5, 1.)``), interval of\n          values for v\n        - ``ndivs`` -- int (default: ``1024``), number of pixels\n        - ``verbose`` -- string (default: ``False``)\n\n        BENCHMARK::\n\n            sage: from slabbe.mult_cont_frac import ARP\n            sage: opt = dict(urange=(-.15,.25), vrange=(-.05,.05))\n            sage: ARP().measure_evaluation(10^8, draw='right', ndivs=100, **opt) # optional long\n            0.435...\n            sage: ARP().measure_evaluation(10^8, draw='right', ndivs=1000, **opt) # optional long\n            0.357...\n            sage: ARP().measure_evaluation(10^8, draw='right', ndivs=2000, **opt) # optional long\n            0.293...\n            sage: ARP().measure_evaluation(10^8, draw='right', ndivs=4000, **opt) # optional long\n            0.177...\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_68measure_evaluation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_n_iterations = 0;
  PyObject *__pyx_v_draw = 0;
  PyObject *__pyx_v_norm_xyz = 0;
  PyObject *__pyx_v_norm_uvw = 0;
  PyObject *__pyx_v_xrange = 0;
  PyObject *__pyx_v_yrange = 0;
  PyObject *__pyx_v_urange = 0;
  PyObject *__pyx_v_vrange = 0;
  PyObject *__pyx_v_ndivs = 0;
  PyObject *__pyx_v_verbose = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("measure_evaluation (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_iterations,&__pyx_n_s_draw,&__pyx_n_s_norm_xyz,&__pyx_n_s_norm_uvw,&__pyx_n_s_xrange,&__pyx_n_s_yrange,&__pyx_n_s_urange,&__pyx_n_s_vrange,&__pyx_n_s_ndivs,&__pyx_n_s_verbose,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    values[2] = ((PyObject *)__pyx_kp_s_1);
    values[3] = ((PyObject *)__pyx_kp_s_1);

    /* "slabbe/mult_cont_frac.pyx":2047
 *     def measure_evaluation(self, n_iterations, draw,
 *                                 norm_xyz='1', norm_uvw='1',
 *                                 xrange=(-.866, .866),             # <<<<<<<<<<<<<<
 *                                 yrange=(-.5, 1.),
 *                                 urange=(-.866, .866),
 */
    values[4] = ((PyObject *)__pyx_tuple__39);

    /* "slabbe/mult_cont_frac.pyx":2048
 *                                 norm_xyz='1', norm_uvw='1',
 *                                 xrange=(-.866, .866),
 *                                 yrange=(-.5, 1.),             # <<<<<<<<<<<<<<
 *                                 urange=(-.866, .866),
 *                                 vrange=(-.5, 1.),
 */
    values[5] = ((PyObject *)__pyx_tuple__40);

    /* "slabbe/mult_cont_frac.pyx":2049
 *                                 xrange=(-.866, .866),
 *                                 yrange=(-.5, 1.),
 *                                 urange=(-.866, .866),             # <<<<<<<<<<<<<<
 *                                 vrange=(-.5, 1.),
 *                                 ndivs=1024,
 */
    values[6] = ((PyObject *)__pyx_tuple__41);

    /* "slabbe/mult_cont_frac.pyx":2050
 *                                 yrange=(-.5, 1.),
 *                                 urange=(-.866, .866),
 *                                 vrange=(-.5, 1.),             # <<<<<<<<<<<<<<
 *                                 ndivs=1024,
 *                                 verbose=False):
 */
    values[7] = ((PyObject *)__pyx_tuple__42);
    values[8] = ((PyObject *)__pyx_int_1024);

    /* "slabbe/mult_cont_frac.pyx":2052
 *                                 vrange=(-.5, 1.),
 *                                 ndivs=1024,
 *                                 verbose=False):             # <<<<<<<<<<<<<<
 *         r"""
 *         Return the measure of a box according to an orbit.
 */
    values[9] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_iterations)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_draw)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("measure_evaluation", 0, 2, 10, 1); __PYX_ERR(0, 2045, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_xyz);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_norm_uvw);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_xrange);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_yrange);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_urange);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_vrange);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndivs);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_verbose);
          if (value) { values[9] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "measure_evaluation") < 0)) __PYX_ERR(0, 2045, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_n_iterations = values[0];
    __pyx_v_draw = values[1];
    __pyx_v_norm_xyz = values[2];
    __pyx_v_norm_uvw = values[3];
    __pyx_v_xrange = values[4];
    __pyx_v_yrange = values[5];
    __pyx_v_urange = values[6];
    __pyx_v_vrange = values[7];
    __pyx_v_ndivs = values[8];
    __pyx_v_verbose = values[9];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("measure_evaluation", 0, 2, 10, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2045, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.measure_evaluation", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_67measure_evaluation(((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)__pyx_v_self), __pyx_v_n_iterations, __pyx_v_draw, __pyx_v_norm_xyz, __pyx_v_norm_uvw, __pyx_v_xrange, __pyx_v_yrange, __pyx_v_urange, __pyx_v_vrange, __pyx_v_ndivs, __pyx_v_verbose);

  /* "slabbe/mult_cont_frac.pyx":2045
 *         return img
 * 
 *     def measure_evaluation(self, n_iterations, draw,             # <<<<<<<<<<<<<<
 *                                 norm_xyz='1', norm_uvw='1',
 *                                 xrange=(-.866, .866),
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_2generator7(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "slabbe/mult_cont_frac.pyx":2105
 * 
 *         if draw.endswith('left'):
 *             S = set((p[0],p[1]) for p in L)             # <<<<<<<<<<<<<<
 *         elif draw.endswith('right'):
 *             S = set((p[2],p[3]) for p in L)
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_2generator7, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_measure_evaluation_locals_genexp); if (unlikely(!gen)) __PYX_ERR(0, 2105, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.measure_evaluation.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_2generator7(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *__pyx_cur_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2105, __pyx_L1_error)
  __pyx_r = PySet_New(NULL); if (unlikely(!__pyx_r)) __PYX_ERR(0, 2105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_L)) { __Pyx_RaiseClosureNameError("L"); __PYX_ERR(0, 2105, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_L)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_L)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_L; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_L); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2105, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2105, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2105, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2105, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2105, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2105, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2105, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_p);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_p, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_p, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2105, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_p, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2105, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2105, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    if (unlikely(PySet_Add(__pyx_r, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 2105, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_5generator8(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "slabbe/mult_cont_frac.pyx":2107
 *             S = set((p[0],p[1]) for p in L)
 *         elif draw.endswith('right'):
 *             S = set((p[2],p[3]) for p in L)             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Unkown value for draw(={})".format(draw))
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_3genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_5generator8, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_measure_evaluation_locals_genexp); if (unlikely(!gen)) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.measure_evaluation.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_5generator8(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *__pyx_cur_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __pyx_r = PySet_New(NULL); if (unlikely(!__pyx_r)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_L)) { __Pyx_RaiseClosureNameError("L"); __PYX_ERR(0, 2107, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_L)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_L)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_L; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_L); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2107, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2107, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2107, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 2107, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2107, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2107, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_p);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_p, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_p, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_p, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    if (unlikely(PySet_Add(__pyx_r, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2045
 *         return img
 * 
 *     def measure_evaluation(self, n_iterations, draw,             # <<<<<<<<<<<<<<
 *                                 norm_xyz='1', norm_uvw='1',
 *                                 xrange=(-.866, .866),
 */

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_67measure_evaluation(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *__pyx_v_self, PyObject *__pyx_v_n_iterations, PyObject *__pyx_v_draw, PyObject *__pyx_v_norm_xyz, PyObject *__pyx_v_norm_uvw, PyObject *__pyx_v_xrange, PyObject *__pyx_v_yrange, PyObject *__pyx_v_urange, PyObject *__pyx_v_vrange, PyObject *__pyx_v_ndivs, PyObject *__pyx_v_verbose) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *__pyx_cur_scope;
  PyObject *__pyx_v_S = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("measure_evaluation", 0);
  __pyx_cur_scope = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *)__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation(__pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);

  /* "slabbe/mult_cont_frac.pyx":2096
 * 
 *         """
 *         L = self.simplex_orbit_filtered_list(n_iterations=n_iterations,             # <<<<<<<<<<<<<<
 *             norm_xyz=norm_xyz, norm_uvw=norm_uvw,
 *             xmin=xrange[0], xmax=xrange[1],
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_simplex_orbit_filtered_list); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_n_iterations, __pyx_v_n_iterations) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":2097
 *         """
 *         L = self.simplex_orbit_filtered_list(n_iterations=n_iterations,
 *             norm_xyz=norm_xyz, norm_uvw=norm_uvw,             # <<<<<<<<<<<<<<
 *             xmin=xrange[0], xmax=xrange[1],
 *             ymin=yrange[0], ymax=yrange[1],
 */
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_norm_xyz, __pyx_v_norm_xyz) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_norm_uvw, __pyx_v_norm_uvw) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":2098
 *         L = self.simplex_orbit_filtered_list(n_iterations=n_iterations,
 *             norm_xyz=norm_xyz, norm_uvw=norm_uvw,
 *             xmin=xrange[0], xmax=xrange[1],             # <<<<<<<<<<<<<<
 *             ymin=yrange[0], ymax=yrange[1],
 *             umin=urange[0], umax=urange[1],
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_xrange, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2098, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_xmin, __pyx_t_3) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_xrange, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2098, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_xmax, __pyx_t_3) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":2099
 *             norm_xyz=norm_xyz, norm_uvw=norm_uvw,
 *             xmin=xrange[0], xmax=xrange[1],
 *             ymin=yrange[0], ymax=yrange[1],             # <<<<<<<<<<<<<<
 *             umin=urange[0], umax=urange[1],
 *             vmin=vrange[0], vmax=vrange[1],
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_yrange, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2099, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_ymin, __pyx_t_3) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_yrange, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2099, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_ymax, __pyx_t_3) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":2100
 *             xmin=xrange[0], xmax=xrange[1],
 *             ymin=yrange[0], ymax=yrange[1],
 *             umin=urange[0], umax=urange[1],             # <<<<<<<<<<<<<<
 *             vmin=vrange[0], vmax=vrange[1],
 *             ndivs=ndivs)
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_urange, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_umin, __pyx_t_3) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_urange, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_umax, __pyx_t_3) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":2101
 *             ymin=yrange[0], ymax=yrange[1],
 *             umin=urange[0], umax=urange[1],
 *             vmin=vrange[0], vmax=vrange[1],             # <<<<<<<<<<<<<<
 *             ndivs=ndivs)
 * 
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_vrange, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_vmin, __pyx_t_3) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_vrange, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_vmax, __pyx_t_3) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":2102
 *             umin=urange[0], umax=urange[1],
 *             vmin=vrange[0], vmax=vrange[1],
 *             ndivs=ndivs)             # <<<<<<<<<<<<<<
 * 
 *         if draw.endswith('left'):
 */
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_ndivs, __pyx_v_ndivs) < 0) __PYX_ERR(0, 2096, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":2096
 * 
 *         """
 *         L = self.simplex_orbit_filtered_list(n_iterations=n_iterations,             # <<<<<<<<<<<<<<
 *             norm_xyz=norm_xyz, norm_uvw=norm_uvw,
 *             xmin=xrange[0], xmax=xrange[1],
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2096, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_L = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":2104
 *             ndivs=ndivs)
 * 
 *         if draw.endswith('left'):             # <<<<<<<<<<<<<<
 *             S = set((p[0],p[1]) for p in L)
 *         elif draw.endswith('right'):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_draw, __pyx_n_s_endswith); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2104, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":2105
 * 
 *         if draw.endswith('left'):
 *             S = set((p[0],p[1]) for p in L)             # <<<<<<<<<<<<<<
 *         elif draw.endswith('right'):
 *             S = set((p[2],p[3]) for p in L)
 */
    __pyx_t_2 = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2105, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2105, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_S = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "slabbe/mult_cont_frac.pyx":2104
 *             ndivs=ndivs)
 * 
 *         if draw.endswith('left'):             # <<<<<<<<<<<<<<
 *             S = set((p[0],p[1]) for p in L)
 *         elif draw.endswith('right'):
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2106
 *         if draw.endswith('left'):
 *             S = set((p[0],p[1]) for p in L)
 *         elif draw.endswith('right'):             # <<<<<<<<<<<<<<
 *             S = set((p[2],p[3]) for p in L)
 *         else:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_draw, __pyx_n_s_endswith); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2106, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":2107
 *             S = set((p[0],p[1]) for p in L)
 *         elif draw.endswith('right'):
 *             S = set((p[2],p[3]) for p in L)             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Unkown value for draw(={})".format(draw))
 */
    __pyx_t_2 = __pyx_pf_6slabbe_14mult_cont_frac_12MCFAlgorithm_18measure_evaluation_3genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_S = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "slabbe/mult_cont_frac.pyx":2106
 *         if draw.endswith('left'):
 *             S = set((p[0],p[1]) for p in L)
 *         elif draw.endswith('right'):             # <<<<<<<<<<<<<<
 *             S = set((p[2],p[3]) for p in L)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2109
 *             S = set((p[2],p[3]) for p in L)
 *         else:
 *             raise ValueError("Unkown value for draw(={})".format(draw))             # <<<<<<<<<<<<<<
 * 
 *         if verbose:
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unkown_value_for_draw, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2109, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_draw); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2109, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2109, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_INCREF(__pyx_v_draw);
      __Pyx_GIVEREF(__pyx_v_draw);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_draw);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2109, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2109, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2109, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2109, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":2111
 *             raise ValueError("Unkown value for draw(={})".format(draw))
 * 
 *         if verbose:             # <<<<<<<<<<<<<<
 *             print "nombre diterations dans la fenetre : ", len(L)
 *             print "{} pixels touchs parmi limage {}^2 ".format(len(S), ndivs)
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2111, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "slabbe/mult_cont_frac.pyx":2112
 * 
 *         if verbose:
 *             print "nombre diterations dans la fenetre : ", len(L)             # <<<<<<<<<<<<<<
 *             print "{} pixels touchs parmi limage {}^2 ".format(len(S), ndivs)
 * 
 */
    __pyx_t_3 = __pyx_cur_scope->__pyx_v_L;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_6 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 2112, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_kp_s_nombre_diterations_dans_la_fenet);
    __Pyx_GIVEREF(__pyx_kp_s_nombre_diterations_dans_la_fenet);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_s_nombre_diterations_dans_la_fenet);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_3 = 0;
    if (__Pyx_Print(0, __pyx_t_2, 1) < 0) __PYX_ERR(0, 2112, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":2113
 *         if verbose:
 *             print "nombre diterations dans la fenetre : ", len(L)
 *             print "{} pixels touchs parmi limage {}^2 ".format(len(S), ndivs)             # <<<<<<<<<<<<<<
 * 
 *         print float(len(S) / ndivs**2)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_pixels_touchs_parmi_limage_2, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_S == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(0, 2113, __pyx_L1_error)
    }
    __pyx_t_6 = PySet_GET_SIZE(__pyx_v_S); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 2113, __pyx_L1_error)
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_ndivs);
    __Pyx_GIVEREF(__pyx_v_ndivs);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_ndivs);
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_2) < 0) __PYX_ERR(0, 2113, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "slabbe/mult_cont_frac.pyx":2111
 *             raise ValueError("Unkown value for draw(={})".format(draw))
 * 
 *         if verbose:             # <<<<<<<<<<<<<<
 *             print "nombre diterations dans la fenetre : ", len(L)
 *             print "{} pixels touchs parmi limage {}^2 ".format(len(S), ndivs)
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2115
 *             print "{} pixels touchs parmi limage {}^2 ".format(len(S), ndivs)
 * 
 *         print float(len(S) / ndivs**2)             # <<<<<<<<<<<<<<
 * 
 * cdef class Brun(MCFAlgorithm):
 */
  if (unlikely(__pyx_v_S == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 2115, __pyx_L1_error)
  }
  __pyx_t_6 = PySet_GET_SIZE(__pyx_v_S); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 2115, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Power(__pyx_v_ndivs, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyNumber_Float(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_PrintOne(0, __pyx_t_3) < 0) __PYX_ERR(0, 2115, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":2045
 *         return img
 * 
 *     def measure_evaluation(self, n_iterations, draw,             # <<<<<<<<<<<<<<
 *                                 norm_xyz='1', norm_uvw='1',
 *                                 xrange=(-.866, .866),
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.MCFAlgorithm.measure_evaluation", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_S);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2128
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_4Brun_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Brun *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __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;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2144
 *              ('z', 0.20000000000000007)]
 *         """
 *         if P.x <= P.y <= P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.y
 *             P.v += P.w
 */
  __pyx_t_1 = (__pyx_v_P.x <= __pyx_v_P.y);
  if (__pyx_t_1) {
    __pyx_t_1 = (__pyx_v_P.y <= __pyx_v_P.z);
  }
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":2145
 *         """
 *         if P.x <= P.y <= P.z:
 *             P.z -= P.y             # <<<<<<<<<<<<<<
 *             P.v += P.w
 *             P.branch = 123
 */
    __pyx_v_P.z = (__pyx_v_P.z - __pyx_v_P.y);

    /* "slabbe/mult_cont_frac.pyx":2146
 *         if P.x <= P.y <= P.z:
 *             P.z -= P.y
 *             P.v += P.w             # <<<<<<<<<<<<<<
 *             P.branch = 123
 *         elif P.x <= P.z <= P.y:
 */
    __pyx_v_P.v = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2147
 *             P.z -= P.y
 *             P.v += P.w
 *             P.branch = 123             # <<<<<<<<<<<<<<
 *         elif P.x <= P.z <= P.y:
 *             P.y -= P.z
 */
    __pyx_v_P.branch = 0x7B;

    /* "slabbe/mult_cont_frac.pyx":2144
 *              ('z', 0.20000000000000007)]
 *         """
 *         if P.x <= P.y <= P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.y
 *             P.v += P.w
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2148
 *             P.v += P.w
 *             P.branch = 123
 *         elif P.x <= P.z <= P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.z
 *             P.w += P.v
 */
  __pyx_t_2 = (__pyx_v_P.x <= __pyx_v_P.z);
  if (__pyx_t_2) {
    __pyx_t_2 = (__pyx_v_P.z <= __pyx_v_P.y);
  }
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2149
 *             P.branch = 123
 *         elif P.x <= P.z <= P.y:
 *             P.y -= P.z             # <<<<<<<<<<<<<<
 *             P.w += P.v
 *             P.branch = 132
 */
    __pyx_v_P.y = (__pyx_v_P.y - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":2150
 *         elif P.x <= P.z <= P.y:
 *             P.y -= P.z
 *             P.w += P.v             # <<<<<<<<<<<<<<
 *             P.branch = 132
 *         elif P.y <= P.z <= P.x:
 */
    __pyx_v_P.w = (__pyx_v_P.w + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":2151
 *             P.y -= P.z
 *             P.w += P.v
 *             P.branch = 132             # <<<<<<<<<<<<<<
 *         elif P.y <= P.z <= P.x:
 *             P.x -= P.z
 */
    __pyx_v_P.branch = 0x84;

    /* "slabbe/mult_cont_frac.pyx":2148
 *             P.v += P.w
 *             P.branch = 123
 *         elif P.x <= P.z <= P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.z
 *             P.w += P.v
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2152
 *             P.w += P.v
 *             P.branch = 132
 *         elif P.y <= P.z <= P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.z
 *             P.w += P.u
 */
  __pyx_t_1 = (__pyx_v_P.y <= __pyx_v_P.z);
  if (__pyx_t_1) {
    __pyx_t_1 = (__pyx_v_P.z <= __pyx_v_P.x);
  }
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":2153
 *             P.branch = 132
 *         elif P.y <= P.z <= P.x:
 *             P.x -= P.z             # <<<<<<<<<<<<<<
 *             P.w += P.u
 *             P.branch = 231
 */
    __pyx_v_P.x = (__pyx_v_P.x - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":2154
 *         elif P.y <= P.z <= P.x:
 *             P.x -= P.z
 *             P.w += P.u             # <<<<<<<<<<<<<<
 *             P.branch = 231
 *         elif P.y <= P.x <= P.z:
 */
    __pyx_v_P.w = (__pyx_v_P.w + __pyx_v_P.u);

    /* "slabbe/mult_cont_frac.pyx":2155
 *             P.x -= P.z
 *             P.w += P.u
 *             P.branch = 231             # <<<<<<<<<<<<<<
 *         elif P.y <= P.x <= P.z:
 *             P.z -= P.x
 */
    __pyx_v_P.branch = 0xE7;

    /* "slabbe/mult_cont_frac.pyx":2152
 *             P.w += P.v
 *             P.branch = 132
 *         elif P.y <= P.z <= P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.z
 *             P.w += P.u
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2156
 *             P.w += P.u
 *             P.branch = 231
 *         elif P.y <= P.x <= P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.x
 *             P.u += P.w
 */
  __pyx_t_2 = (__pyx_v_P.y <= __pyx_v_P.x);
  if (__pyx_t_2) {
    __pyx_t_2 = (__pyx_v_P.x <= __pyx_v_P.z);
  }
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2157
 *             P.branch = 231
 *         elif P.y <= P.x <= P.z:
 *             P.z -= P.x             # <<<<<<<<<<<<<<
 *             P.u += P.w
 *             P.branch = 213
 */
    __pyx_v_P.z = (__pyx_v_P.z - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":2158
 *         elif P.y <= P.x <= P.z:
 *             P.z -= P.x
 *             P.u += P.w             # <<<<<<<<<<<<<<
 *             P.branch = 213
 *         elif P.z <= P.x <= P.y:
 */
    __pyx_v_P.u = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2159
 *             P.z -= P.x
 *             P.u += P.w
 *             P.branch = 213             # <<<<<<<<<<<<<<
 *         elif P.z <= P.x <= P.y:
 *             P.y -= P.x
 */
    __pyx_v_P.branch = 0xD5;

    /* "slabbe/mult_cont_frac.pyx":2156
 *             P.w += P.u
 *             P.branch = 231
 *         elif P.y <= P.x <= P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.x
 *             P.u += P.w
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2160
 *             P.u += P.w
 *             P.branch = 213
 *         elif P.z <= P.x <= P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.x
 *             P.u += P.v
 */
  __pyx_t_1 = (__pyx_v_P.z <= __pyx_v_P.x);
  if (__pyx_t_1) {
    __pyx_t_1 = (__pyx_v_P.x <= __pyx_v_P.y);
  }
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":2161
 *             P.branch = 213
 *         elif P.z <= P.x <= P.y:
 *             P.y -= P.x             # <<<<<<<<<<<<<<
 *             P.u += P.v
 *             P.branch = 312
 */
    __pyx_v_P.y = (__pyx_v_P.y - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":2162
 *         elif P.z <= P.x <= P.y:
 *             P.y -= P.x
 *             P.u += P.v             # <<<<<<<<<<<<<<
 *             P.branch = 312
 *         elif P.z <= P.y <= P.x:
 */
    __pyx_v_P.u = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":2163
 *             P.y -= P.x
 *             P.u += P.v
 *             P.branch = 312             # <<<<<<<<<<<<<<
 *         elif P.z <= P.y <= P.x:
 *             P.x -= P.y
 */
    __pyx_v_P.branch = 0x138;

    /* "slabbe/mult_cont_frac.pyx":2160
 *             P.u += P.w
 *             P.branch = 213
 *         elif P.z <= P.x <= P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.x
 *             P.u += P.v
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2164
 *             P.u += P.v
 *             P.branch = 312
 *         elif P.z <= P.y <= P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.y
 *             P.v += P.u
 */
  __pyx_t_2 = (__pyx_v_P.z <= __pyx_v_P.y);
  if (__pyx_t_2) {
    __pyx_t_2 = (__pyx_v_P.y <= __pyx_v_P.x);
  }
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2165
 *             P.branch = 312
 *         elif P.z <= P.y <= P.x:
 *             P.x -= P.y             # <<<<<<<<<<<<<<
 *             P.v += P.u
 *             P.branch = 321
 */
    __pyx_v_P.x = (__pyx_v_P.x - __pyx_v_P.y);

    /* "slabbe/mult_cont_frac.pyx":2166
 *         elif P.z <= P.y <= P.x:
 *             P.x -= P.y
 *             P.v += P.u             # <<<<<<<<<<<<<<
 *             P.branch = 321
 *         else:
 */
    __pyx_v_P.v = (__pyx_v_P.v + __pyx_v_P.u);

    /* "slabbe/mult_cont_frac.pyx":2167
 *             P.x -= P.y
 *             P.v += P.u
 *             P.branch = 321             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))
 */
    __pyx_v_P.branch = 0x141;

    /* "slabbe/mult_cont_frac.pyx":2164
 *             P.u += P.v
 *             P.branch = 312
 *         elif P.z <= P.y <= P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.y
 *             P.v += P.u
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2169
 *             P.branch = 321
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))             # <<<<<<<<<<<<<<
 *         return P
 * 
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_limit_case_reach_set_of_measure, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2169, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __pyx_convert__to_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(__pyx_v_P); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2169, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2169, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2169, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2169, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2169, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":2170
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))
 *         return P             # <<<<<<<<<<<<<<
 * 
 *     def substitutions(self):
 */
  __pyx_r = __pyx_v_P;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2128
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.Brun.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2172
 *         return P
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_4Brun_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_4Brun_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: Brun().substitutions()\n            {123: WordMorphism: 1->1, 2->23, 3->3,\n             132: WordMorphism: 1->1, 2->2, 3->32,\n             213: WordMorphism: 1->13, 2->2, 3->3,\n             231: WordMorphism: 1->1, 2->2, 3->31,\n             312: WordMorphism: 1->12, 2->2, 3->3,\n             321: WordMorphism: 1->1, 2->21, 3->3}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_4Brun_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_4Brun_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_Brun *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_4Brun_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Brun *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2185
 *              321: WordMorphism: 1->1, 2->21, 3->3}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {312: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2186
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {312: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 213: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2186, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_312, __pyx_t_1) < 0) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2187
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {312: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 213: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2187, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2187, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2187, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2187, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2187, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2187, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_321, __pyx_t_1) < 0) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2188
 *         return {312: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 213: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 231: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 123: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2188, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2188, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2188, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_213, __pyx_t_1) < 0) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2189
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 213: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 123: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2189, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2189, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2189, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2189, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2189, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2189, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_231, __pyx_t_1) < 0) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2190
 *                 213: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 123: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 132: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2190, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2190, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2190, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2190, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_123, __pyx_t_1) < 0) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2191
 *                 231: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 123: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}             # <<<<<<<<<<<<<<
 * 
 *     def dual_substitutions(self):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2191, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2191, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2191, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2191, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2191, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2191, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_132, __pyx_t_1) < 0) __PYX_ERR(0, 2186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2172
 *         return P
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.Brun.substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2193
 *                 132: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_4Brun_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_4Brun_2dual_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Brun\n            sage: Brun().dual_substitutions()\n            {123: WordMorphism: 1->1, 2->2, 3->32,\n             132: WordMorphism: 1->1, 2->23, 3->3,\n             213: WordMorphism: 1->1, 2->2, 3->31,\n             231: WordMorphism: 1->13, 2->2, 3->3,\n             312: WordMorphism: 1->1, 2->21, 3->3,\n             321: WordMorphism: 1->12, 2->2, 3->3}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_4Brun_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dual_substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_4Brun_2dual_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_Brun *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_4Brun_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Brun *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("dual_substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2206
 *              321: WordMorphism: 1->12, 2->2, 3->3}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {321: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 312: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2207
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {321: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 312: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 231: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2207, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2207, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2207, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_321, __pyx_t_1) < 0) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2208
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {321: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 312: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 231: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 213: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2208, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2208, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2208, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2208, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2208, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2208, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_312, __pyx_t_1) < 0) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2209
 *         return {321: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 312: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 231: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 213: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 132: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2209, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2209, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2209, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2209, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2209, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2209, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_231, __pyx_t_1) < 0) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2210
 *                 312: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 231: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 213: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 132: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 *                 123: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2210, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2210, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2210, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2210, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2210, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2210, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_213, __pyx_t_1) < 0) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2211
 *                 231: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 213: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 132: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 123: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2211, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2211, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2211, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2211, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2211, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2211, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_132, __pyx_t_1) < 0) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2212
 *                 213: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 132: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 *                 123: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}             # <<<<<<<<<<<<<<
 * 
 * cdef class Reverse(MCFAlgorithm):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2212, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2212, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2212, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2212, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2212, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2212, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_123, __pyx_t_1) < 0) __PYX_ERR(0, 2207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2193
 *                 132: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.Brun.dual_substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2225
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_7Reverse_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2242
 *         """
 *         cdef PairPoint3d R
 *         if P.x + P.y < P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.x + P.y
 *             P.v += P.w
 */
  __pyx_t_1 = (((__pyx_v_P.x + __pyx_v_P.y) < __pyx_v_P.z) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2243
 *         cdef PairPoint3d R
 *         if P.x + P.y < P.z:
 *             P.z -= P.x + P.y             # <<<<<<<<<<<<<<
 *             P.v += P.w
 *             P.u += P.w
 */
    __pyx_v_P.z = (__pyx_v_P.z - (__pyx_v_P.x + __pyx_v_P.y));

    /* "slabbe/mult_cont_frac.pyx":2244
 *         if P.x + P.y < P.z:
 *             P.z -= P.x + P.y
 *             P.v += P.w             # <<<<<<<<<<<<<<
 *             P.u += P.w
 *             P.branch = 3
 */
    __pyx_v_P.v = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2245
 *             P.z -= P.x + P.y
 *             P.v += P.w
 *             P.u += P.w             # <<<<<<<<<<<<<<
 *             P.branch = 3
 *             return P
 */
    __pyx_v_P.u = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2246
 *             P.v += P.w
 *             P.u += P.w
 *             P.branch = 3             # <<<<<<<<<<<<<<
 *             return P
 *         elif P.x + P.z < P.y:
 */
    __pyx_v_P.branch = 3;

    /* "slabbe/mult_cont_frac.pyx":2247
 *             P.u += P.w
 *             P.branch = 3
 *             return P             # <<<<<<<<<<<<<<
 *         elif P.x + P.z < P.y:
 *             P.y -= P.x + P.z
 */
    __pyx_r = __pyx_v_P;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":2242
 *         """
 *         cdef PairPoint3d R
 *         if P.x + P.y < P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.x + P.y
 *             P.v += P.w
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2248
 *             P.branch = 3
 *             return P
 *         elif P.x + P.z < P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.x + P.z
 *             P.w += P.v
 */
  __pyx_t_1 = (((__pyx_v_P.x + __pyx_v_P.z) < __pyx_v_P.y) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2249
 *             return P
 *         elif P.x + P.z < P.y:
 *             P.y -= P.x + P.z             # <<<<<<<<<<<<<<
 *             P.w += P.v
 *             P.u += P.v
 */
    __pyx_v_P.y = (__pyx_v_P.y - (__pyx_v_P.x + __pyx_v_P.z));

    /* "slabbe/mult_cont_frac.pyx":2250
 *         elif P.x + P.z < P.y:
 *             P.y -= P.x + P.z
 *             P.w += P.v             # <<<<<<<<<<<<<<
 *             P.u += P.v
 *             P.branch = 2
 */
    __pyx_v_P.w = (__pyx_v_P.w + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":2251
 *             P.y -= P.x + P.z
 *             P.w += P.v
 *             P.u += P.v             # <<<<<<<<<<<<<<
 *             P.branch = 2
 *             return P
 */
    __pyx_v_P.u = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":2252
 *             P.w += P.v
 *             P.u += P.v
 *             P.branch = 2             # <<<<<<<<<<<<<<
 *             return P
 *         elif P.y + P.z < P.x:
 */
    __pyx_v_P.branch = 2;

    /* "slabbe/mult_cont_frac.pyx":2253
 *             P.u += P.v
 *             P.branch = 2
 *             return P             # <<<<<<<<<<<<<<
 *         elif P.y + P.z < P.x:
 *             P.x -= P.y + P.z
 */
    __pyx_r = __pyx_v_P;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":2248
 *             P.branch = 3
 *             return P
 *         elif P.x + P.z < P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.x + P.z
 *             P.w += P.v
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2254
 *             P.branch = 2
 *             return P
 *         elif P.y + P.z < P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.y + P.z
 *             P.v += P.u
 */
  __pyx_t_1 = (((__pyx_v_P.y + __pyx_v_P.z) < __pyx_v_P.x) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2255
 *             return P
 *         elif P.y + P.z < P.x:
 *             P.x -= P.y + P.z             # <<<<<<<<<<<<<<
 *             P.v += P.u
 *             P.w += P.u
 */
    __pyx_v_P.x = (__pyx_v_P.x - (__pyx_v_P.y + __pyx_v_P.z));

    /* "slabbe/mult_cont_frac.pyx":2256
 *         elif P.y + P.z < P.x:
 *             P.x -= P.y + P.z
 *             P.v += P.u             # <<<<<<<<<<<<<<
 *             P.w += P.u
 *             P.branch = 1
 */
    __pyx_v_P.v = (__pyx_v_P.v + __pyx_v_P.u);

    /* "slabbe/mult_cont_frac.pyx":2257
 *             P.x -= P.y + P.z
 *             P.v += P.u
 *             P.w += P.u             # <<<<<<<<<<<<<<
 *             P.branch = 1
 *             return P
 */
    __pyx_v_P.w = (__pyx_v_P.w + __pyx_v_P.u);

    /* "slabbe/mult_cont_frac.pyx":2258
 *             P.v += P.u
 *             P.w += P.u
 *             P.branch = 1             # <<<<<<<<<<<<<<
 *             return P
 *         else:
 */
    __pyx_v_P.branch = 1;

    /* "slabbe/mult_cont_frac.pyx":2259
 *             P.w += P.u
 *             P.branch = 1
 *             return P             # <<<<<<<<<<<<<<
 *         else:
 *             # R.x = 0.629960524947437 * (-P.x + P.y + P.z)
 */
    __pyx_r = __pyx_v_P;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":2254
 *             P.branch = 2
 *             return P
 *         elif P.y + P.z < P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.y + P.z
 *             P.v += P.u
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2269
 *             # R.v = 0.793700525984100 * (P.u + P.w)
 *             # R.w = 0.793700525984100 * (P.u + P.v)
 *             R.x = 0.5 * (-P.x + P.y + P.z)             # <<<<<<<<<<<<<<
 *             R.y = 0.5 * ( P.x - P.y + P.z)
 *             R.z = 0.5 * ( P.x + P.y - P.z)
 */
  /*else*/ {
    __pyx_v_R.x = (0.5 * (((-__pyx_v_P.x) + __pyx_v_P.y) + __pyx_v_P.z));

    /* "slabbe/mult_cont_frac.pyx":2270
 *             # R.w = 0.793700525984100 * (P.u + P.v)
 *             R.x = 0.5 * (-P.x + P.y + P.z)
 *             R.y = 0.5 * ( P.x - P.y + P.z)             # <<<<<<<<<<<<<<
 *             R.z = 0.5 * ( P.x + P.y - P.z)
 *             R.u = P.v + P.w
 */
    __pyx_v_R.y = (0.5 * ((__pyx_v_P.x - __pyx_v_P.y) + __pyx_v_P.z));

    /* "slabbe/mult_cont_frac.pyx":2271
 *             R.x = 0.5 * (-P.x + P.y + P.z)
 *             R.y = 0.5 * ( P.x - P.y + P.z)
 *             R.z = 0.5 * ( P.x + P.y - P.z)             # <<<<<<<<<<<<<<
 *             R.u = P.v + P.w
 *             R.v = P.u + P.w
 */
    __pyx_v_R.z = (0.5 * ((__pyx_v_P.x + __pyx_v_P.y) - __pyx_v_P.z));

    /* "slabbe/mult_cont_frac.pyx":2272
 *             R.y = 0.5 * ( P.x - P.y + P.z)
 *             R.z = 0.5 * ( P.x + P.y - P.z)
 *             R.u = P.v + P.w             # <<<<<<<<<<<<<<
 *             R.v = P.u + P.w
 *             R.w = P.u + P.v
 */
    __pyx_v_R.u = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2273
 *             R.z = 0.5 * ( P.x + P.y - P.z)
 *             R.u = P.v + P.w
 *             R.v = P.u + P.w             # <<<<<<<<<<<<<<
 *             R.w = P.u + P.v
 *             R.branch = 4
 */
    __pyx_v_R.v = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2274
 *             R.u = P.v + P.w
 *             R.v = P.u + P.w
 *             R.w = P.u + P.v             # <<<<<<<<<<<<<<
 *             R.branch = 4
 *             return R
 */
    __pyx_v_R.w = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":2275
 *             R.v = P.u + P.w
 *             R.w = P.u + P.v
 *             R.branch = 4             # <<<<<<<<<<<<<<
 *             return R
 * 
 */
    __pyx_v_R.branch = 4;

    /* "slabbe/mult_cont_frac.pyx":2276
 *             R.w = P.u + P.v
 *             R.branch = 4
 *             return R             # <<<<<<<<<<<<<<
 * 
 *     def substitutions(self):
 */
    __pyx_r = __pyx_v_R;
    goto __pyx_L0;
  }

  /* "slabbe/mult_cont_frac.pyx":2225
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":2278
 *             return R
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_7Reverse_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_7Reverse_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Reverse\n            sage: Reverse().substitutions()\n            {1: WordMorphism: 1->1, 2->21, 3->31,\n             2: WordMorphism: 1->12, 2->2, 3->32,\n             3: WordMorphism: 1->13, 2->23, 3->3,\n             4: WordMorphism: 1->23, 2->31, 3->12}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_7Reverse_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_7Reverse_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_7Reverse_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2289
 *              4: WordMorphism: 1->23, 2->31, 3->12}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2290
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]}),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2290, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1, __pyx_t_1) < 0) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2291
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),             # <<<<<<<<<<<<<<
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]}),
 *                 4:  WordMorphism({1: [2,3], 2: [3,1], 3: [1,2]})}
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2291, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2291, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2291, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2291, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2, __pyx_t_1) < 0) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2292
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 4:  WordMorphism({1: [2,3], 2: [3,1], 3: [1,2]})}
 * 
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2292, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2292, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2292, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2292, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2292, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2292, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3, __pyx_t_1) < 0) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2293
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]}),
 *                 4:  WordMorphism({1: [2,3], 2: [3,1], 3: [1,2]})}             # <<<<<<<<<<<<<<
 * 
 *     def dual_substitutions(self):
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2293, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2293, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2293, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2293, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_4, __pyx_t_1) < 0) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2278
 *             return R
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.Reverse.substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2295
 *                 4:  WordMorphism({1: [2,3], 2: [3,1], 3: [1,2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_7Reverse_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_7Reverse_2dual_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Reverse\n            sage: Reverse().dual_substitutions()\n            {1: WordMorphism: 1->123, 2->2, 3->3,\n             2: WordMorphism: 1->1, 2->231, 3->3,\n             3: WordMorphism: 1->1, 2->2, 3->312,\n             4: WordMorphism: 1->23, 2->13, 3->12}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_7Reverse_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dual_substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_7Reverse_2dual_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_7Reverse_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("dual_substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2306
 *              4: WordMorphism: 1->23, 2->13, 3->12}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2307
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]}),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2307, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2307, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2307, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1, __pyx_t_1) < 0) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2308
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]}),
 *                 4:  WordMorphism({1: [2,3], 2: [1,3], 3: [1,2]})}
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2308, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2308, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2308, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2308, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2, __pyx_t_1) < 0) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2309
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]}),             # <<<<<<<<<<<<<<
 *                 4:  WordMorphism({1: [2,3], 2: [1,3], 3: [1,2]})}
 * 
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2309, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2309, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2309, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2309, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2309, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2309, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3, __pyx_t_1) < 0) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2310
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]}),
 *                 4:  WordMorphism({1: [2,3], 2: [1,3], 3: [1,2]})}             # <<<<<<<<<<<<<<
 * 
 * cdef class ARP(MCFAlgorithm):
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2310, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2310, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2310, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2310, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_4, __pyx_t_1) < 0) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2295
 *                 4:  WordMorphism({1: [2,3], 2: [3,1], 3: [1,2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.Reverse.dual_substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2323
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_3ARP_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_2;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2339
 *              ('z', 0.20000000000000007)]
 *         """
 *         if P.x + P.y < P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.x + P.y
 *             P.v += P.w
 */
  __pyx_t_1 = (((__pyx_v_P.x + __pyx_v_P.y) < __pyx_v_P.z) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2340
 *         """
 *         if P.x + P.y < P.z:
 *             P.z -= P.x + P.y             # <<<<<<<<<<<<<<
 *             P.v += P.w
 *             P.u += P.w
 */
    __pyx_v_P.z = (__pyx_v_P.z - (__pyx_v_P.x + __pyx_v_P.y));

    /* "slabbe/mult_cont_frac.pyx":2341
 *         if P.x + P.y < P.z:
 *             P.z -= P.x + P.y
 *             P.v += P.w             # <<<<<<<<<<<<<<
 *             P.u += P.w
 *             P.branch = 3
 */
    __pyx_v_P.v = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2342
 *             P.z -= P.x + P.y
 *             P.v += P.w
 *             P.u += P.w             # <<<<<<<<<<<<<<
 *             P.branch = 3
 *             return P
 */
    __pyx_v_P.u = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2343
 *             P.v += P.w
 *             P.u += P.w
 *             P.branch = 3             # <<<<<<<<<<<<<<
 *             return P
 *         elif P.x + P.z < P.y:
 */
    __pyx_v_P.branch = 3;

    /* "slabbe/mult_cont_frac.pyx":2344
 *             P.u += P.w
 *             P.branch = 3
 *             return P             # <<<<<<<<<<<<<<
 *         elif P.x + P.z < P.y:
 *             P.y -= P.x + P.z
 */
    __pyx_r = __pyx_v_P;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":2339
 *              ('z', 0.20000000000000007)]
 *         """
 *         if P.x + P.y < P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.x + P.y
 *             P.v += P.w
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2345
 *             P.branch = 3
 *             return P
 *         elif P.x + P.z < P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.x + P.z
 *             P.w += P.v
 */
  __pyx_t_1 = (((__pyx_v_P.x + __pyx_v_P.z) < __pyx_v_P.y) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2346
 *             return P
 *         elif P.x + P.z < P.y:
 *             P.y -= P.x + P.z             # <<<<<<<<<<<<<<
 *             P.w += P.v
 *             P.u += P.v
 */
    __pyx_v_P.y = (__pyx_v_P.y - (__pyx_v_P.x + __pyx_v_P.z));

    /* "slabbe/mult_cont_frac.pyx":2347
 *         elif P.x + P.z < P.y:
 *             P.y -= P.x + P.z
 *             P.w += P.v             # <<<<<<<<<<<<<<
 *             P.u += P.v
 *             P.branch = 2
 */
    __pyx_v_P.w = (__pyx_v_P.w + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":2348
 *             P.y -= P.x + P.z
 *             P.w += P.v
 *             P.u += P.v             # <<<<<<<<<<<<<<
 *             P.branch = 2
 *             return P
 */
    __pyx_v_P.u = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":2349
 *             P.w += P.v
 *             P.u += P.v
 *             P.branch = 2             # <<<<<<<<<<<<<<
 *             return P
 *         elif P.y + P.z < P.x:
 */
    __pyx_v_P.branch = 2;

    /* "slabbe/mult_cont_frac.pyx":2350
 *             P.u += P.v
 *             P.branch = 2
 *             return P             # <<<<<<<<<<<<<<
 *         elif P.y + P.z < P.x:
 *             P.x -= P.y + P.z
 */
    __pyx_r = __pyx_v_P;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":2345
 *             P.branch = 3
 *             return P
 *         elif P.x + P.z < P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.x + P.z
 *             P.w += P.v
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2351
 *             P.branch = 2
 *             return P
 *         elif P.y + P.z < P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.y + P.z
 *             P.v += P.u
 */
  __pyx_t_1 = (((__pyx_v_P.y + __pyx_v_P.z) < __pyx_v_P.x) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2352
 *             return P
 *         elif P.y + P.z < P.x:
 *             P.x -= P.y + P.z             # <<<<<<<<<<<<<<
 *             P.v += P.u
 *             P.w += P.u
 */
    __pyx_v_P.x = (__pyx_v_P.x - (__pyx_v_P.y + __pyx_v_P.z));

    /* "slabbe/mult_cont_frac.pyx":2353
 *         elif P.y + P.z < P.x:
 *             P.x -= P.y + P.z
 *             P.v += P.u             # <<<<<<<<<<<<<<
 *             P.w += P.u
 *             P.branch = 1
 */
    __pyx_v_P.v = (__pyx_v_P.v + __pyx_v_P.u);

    /* "slabbe/mult_cont_frac.pyx":2354
 *             P.x -= P.y + P.z
 *             P.v += P.u
 *             P.w += P.u             # <<<<<<<<<<<<<<
 *             P.branch = 1
 *             return P
 */
    __pyx_v_P.w = (__pyx_v_P.w + __pyx_v_P.u);

    /* "slabbe/mult_cont_frac.pyx":2355
 *             P.v += P.u
 *             P.w += P.u
 *             P.branch = 1             # <<<<<<<<<<<<<<
 *             return P
 *         else:
 */
    __pyx_v_P.branch = 1;

    /* "slabbe/mult_cont_frac.pyx":2356
 *             P.w += P.u
 *             P.branch = 1
 *             return P             # <<<<<<<<<<<<<<
 *         else:
 *             return _Poincare(P)
 */
    __pyx_r = __pyx_v_P;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":2351
 *             P.branch = 2
 *             return P
 *         elif P.y + P.z < P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.y + P.z
 *             P.v += P.u
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2358
 *             return P
 *         else:
 *             return _Poincare(P)             # <<<<<<<<<<<<<<
 *     def name(self):
 *         r"""
 */
  /*else*/ {
    __pyx_t_2 = __pyx_f_6slabbe_14mult_cont_frac__Poincare(__pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2358, __pyx_L1_error)
    __pyx_r = __pyx_t_2;
    goto __pyx_L0;
  }

  /* "slabbe/mult_cont_frac.pyx":2323
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.ARP.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2359
 *         else:
 *             return _Poincare(P)
 *     def name(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_3ARP_1name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_3ARP_name[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import ARP\n            sage: ARP().name()\n            \"Arnoux-Rauzy-Poincar\\\\'e\"\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_3ARP_1name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("name (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_3ARP_name(((struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_3ARP_name(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("name", 0);

  /* "slabbe/mult_cont_frac.pyx":2367
 *             "Arnoux-Rauzy-Poincar\\'e"
 *         """
 *         return r"Arnoux-Rauzy-Poincar\'e"             # <<<<<<<<<<<<<<
 * 
 *     def substitutions(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_kp_s_Arnoux_Rauzy_Poincar_e);
  __pyx_r = __pyx_kp_s_Arnoux_Rauzy_Poincar_e;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2359
 *         else:
 *             return _Poincare(P)
 *     def name(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":2369
 *         return r"Arnoux-Rauzy-Poincar\'e"
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_3ARP_3substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_3ARP_2substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import ARP\n            sage: ARP().substitutions()\n            {1: WordMorphism: 1->1, 2->21, 3->31,\n             2: WordMorphism: 1->12, 2->2, 3->32,\n             3: WordMorphism: 1->13, 2->23, 3->3,\n             123: WordMorphism: 1->123, 2->23, 3->3,\n             132: WordMorphism: 1->132, 2->2, 3->32,\n             213: WordMorphism: 1->13, 2->213, 3->3,\n             231: WordMorphism: 1->1, 2->231, 3->31,\n             312: WordMorphism: 1->12, 2->2, 3->312,\n             321: WordMorphism: 1->1, 2->21, 3->321}\n\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_3ARP_3substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_3ARP_2substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_3ARP_2substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2386
 * 
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2387
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]}),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2387, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1, __pyx_t_1) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2388
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),             # <<<<<<<<<<<<<<
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]}),
 *                 312: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2388, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2388, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2388, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2388, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2, __pyx_t_1) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2389
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 312: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2389, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2389, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2389, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2389, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2389, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2389, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3, __pyx_t_1) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2390
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]}),
 *                 312: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),             # <<<<<<<<<<<<<<
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 213: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2390, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2390, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2390, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2390, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_312, __pyx_t_1) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2391
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]}),
 *                 312: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),             # <<<<<<<<<<<<<<
 *                 213: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2391, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2391, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2391, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2391, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_321, __pyx_t_1) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2392
 *                 312: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 213: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 231: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 123: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2392, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2392, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2392, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2392, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2392, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2392, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_213, __pyx_t_1) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2393
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 213: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 123: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2393, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2393, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2393, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2393, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_231, __pyx_t_1) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2394
 *                 213: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 123: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 132: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2394, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2394, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2394, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2394, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2394, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2394, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_123, __pyx_t_1) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2395
 *                 231: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 123: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}             # <<<<<<<<<<<<<<
 * 
 *     def dual_substitutions(self):
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2395, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2395, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2395, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2395, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2395, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2395, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_132, __pyx_t_1) < 0) __PYX_ERR(0, 2387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2369
 *         return r"Arnoux-Rauzy-Poincar\'e"
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.ARP.substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2397
 *                 132: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_3ARP_5dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_3ARP_4dual_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import ARP\n            sage: ARP().dual_substitutions()\n            {1: WordMorphism: 1->123, 2->2, 3->3,\n             2: WordMorphism: 1->1, 2->231, 3->3,\n             3: WordMorphism: 1->1, 2->2, 3->312,\n             123: WordMorphism: 1->1, 2->21, 3->321,\n             132: WordMorphism: 1->1, 2->231, 3->31,\n             213: WordMorphism: 1->12, 2->2, 3->312,\n             231: WordMorphism: 1->132, 2->2, 3->32,\n             312: WordMorphism: 1->13, 2->213, 3->3,\n             321: WordMorphism: 1->123, 2->23, 3->3}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_3ARP_5dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dual_substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_3ARP_4dual_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_3ARP_4dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("dual_substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2413
 *              321: WordMorphism: 1->123, 2->23, 3->3}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2414
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]}),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2414, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1, __pyx_t_1) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2415
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]}),
 *                 213: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2415, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2415, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2415, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2415, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2, __pyx_t_1) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2416
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]}),             # <<<<<<<<<<<<<<
 *                 213: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 123: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2416, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2416, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2416, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2416, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3, __pyx_t_1) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2417
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]}),
 *                 213: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),             # <<<<<<<<<<<<<<
 *                 123: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 312: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2417, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2417, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2417, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2417, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_213, __pyx_t_1) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2418
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]}),
 *                 213: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 123: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),             # <<<<<<<<<<<<<<
 *                 312: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2418, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2418, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2418, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2418, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2418, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2418, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_123, __pyx_t_1) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2419
 *                 213: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 123: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 312: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 132: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 321: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2419, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2419, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2419, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_312, __pyx_t_1) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2420
 *                 123: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 312: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 321: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 *                 231: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2420, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2420, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2420, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2420, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_132, __pyx_t_1) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2421
 *                 312: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 321: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 231: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2421, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2421, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2421, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2421, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_321, __pyx_t_1) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2422
 *                 132: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 321: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 *                 231: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}             # <<<<<<<<<<<<<<
 * 
 * cdef class ArnouxRauzy(MCFAlgorithm):
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2422, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2422, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2422, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2422, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2422, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2422, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_231, __pyx_t_1) < 0) __PYX_ERR(0, 2414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2397
 *                 132: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.ARP.dual_substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2435
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_11ArnouxRauzy_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2460
 *              ('z', 0.30000000000000004)]
 *         """
 *         if P.x + P.y < P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.x + P.y
 *             P.v += P.w
 */
  __pyx_t_1 = (((__pyx_v_P.x + __pyx_v_P.y) < __pyx_v_P.z) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2461
 *         """
 *         if P.x + P.y < P.z:
 *             P.z -= P.x + P.y             # <<<<<<<<<<<<<<
 *             P.v += P.w
 *             P.u += P.w
 */
    __pyx_v_P.z = (__pyx_v_P.z - (__pyx_v_P.x + __pyx_v_P.y));

    /* "slabbe/mult_cont_frac.pyx":2462
 *         if P.x + P.y < P.z:
 *             P.z -= P.x + P.y
 *             P.v += P.w             # <<<<<<<<<<<<<<
 *             P.u += P.w
 *             P.branch = 3
 */
    __pyx_v_P.v = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2463
 *             P.z -= P.x + P.y
 *             P.v += P.w
 *             P.u += P.w             # <<<<<<<<<<<<<<
 *             P.branch = 3
 *             return P
 */
    __pyx_v_P.u = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2464
 *             P.v += P.w
 *             P.u += P.w
 *             P.branch = 3             # <<<<<<<<<<<<<<
 *             return P
 *         elif P.x + P.z < P.y:
 */
    __pyx_v_P.branch = 3;

    /* "slabbe/mult_cont_frac.pyx":2465
 *             P.u += P.w
 *             P.branch = 3
 *             return P             # <<<<<<<<<<<<<<
 *         elif P.x + P.z < P.y:
 *             P.y -= P.x + P.z
 */
    __pyx_r = __pyx_v_P;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":2460
 *              ('z', 0.30000000000000004)]
 *         """
 *         if P.x + P.y < P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.x + P.y
 *             P.v += P.w
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2466
 *             P.branch = 3
 *             return P
 *         elif P.x + P.z < P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.x + P.z
 *             P.w += P.v
 */
  __pyx_t_1 = (((__pyx_v_P.x + __pyx_v_P.z) < __pyx_v_P.y) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2467
 *             return P
 *         elif P.x + P.z < P.y:
 *             P.y -= P.x + P.z             # <<<<<<<<<<<<<<
 *             P.w += P.v
 *             P.u += P.v
 */
    __pyx_v_P.y = (__pyx_v_P.y - (__pyx_v_P.x + __pyx_v_P.z));

    /* "slabbe/mult_cont_frac.pyx":2468
 *         elif P.x + P.z < P.y:
 *             P.y -= P.x + P.z
 *             P.w += P.v             # <<<<<<<<<<<<<<
 *             P.u += P.v
 *             P.branch = 2
 */
    __pyx_v_P.w = (__pyx_v_P.w + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":2469
 *             P.y -= P.x + P.z
 *             P.w += P.v
 *             P.u += P.v             # <<<<<<<<<<<<<<
 *             P.branch = 2
 *             return P
 */
    __pyx_v_P.u = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":2470
 *             P.w += P.v
 *             P.u += P.v
 *             P.branch = 2             # <<<<<<<<<<<<<<
 *             return P
 *         elif P.y + P.z < P.x:
 */
    __pyx_v_P.branch = 2;

    /* "slabbe/mult_cont_frac.pyx":2471
 *             P.u += P.v
 *             P.branch = 2
 *             return P             # <<<<<<<<<<<<<<
 *         elif P.y + P.z < P.x:
 *             P.x -= P.y + P.z
 */
    __pyx_r = __pyx_v_P;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":2466
 *             P.branch = 3
 *             return P
 *         elif P.x + P.z < P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.x + P.z
 *             P.w += P.v
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2472
 *             P.branch = 2
 *             return P
 *         elif P.y + P.z < P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.y + P.z
 *             P.v += P.u
 */
  __pyx_t_1 = (((__pyx_v_P.y + __pyx_v_P.z) < __pyx_v_P.x) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2473
 *             return P
 *         elif P.y + P.z < P.x:
 *             P.x -= P.y + P.z             # <<<<<<<<<<<<<<
 *             P.v += P.u
 *             P.w += P.u
 */
    __pyx_v_P.x = (__pyx_v_P.x - (__pyx_v_P.y + __pyx_v_P.z));

    /* "slabbe/mult_cont_frac.pyx":2474
 *         elif P.y + P.z < P.x:
 *             P.x -= P.y + P.z
 *             P.v += P.u             # <<<<<<<<<<<<<<
 *             P.w += P.u
 *             P.branch = 1
 */
    __pyx_v_P.v = (__pyx_v_P.v + __pyx_v_P.u);

    /* "slabbe/mult_cont_frac.pyx":2475
 *             P.x -= P.y + P.z
 *             P.v += P.u
 *             P.w += P.u             # <<<<<<<<<<<<<<
 *             P.branch = 1
 *             return P
 */
    __pyx_v_P.w = (__pyx_v_P.w + __pyx_v_P.u);

    /* "slabbe/mult_cont_frac.pyx":2476
 *             P.v += P.u
 *             P.w += P.u
 *             P.branch = 1             # <<<<<<<<<<<<<<
 *             return P
 *         else:
 */
    __pyx_v_P.branch = 1;

    /* "slabbe/mult_cont_frac.pyx":2477
 *             P.w += P.u
 *             P.branch = 1
 *             return P             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError('Arnoux is not defined on {}'.format(P))
 */
    __pyx_r = __pyx_v_P;
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":2472
 *             P.branch = 2
 *             return P
 *         elif P.y + P.z < P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.y + P.z
 *             P.v += P.u
 */
  }

  /* "slabbe/mult_cont_frac.pyx":2479
 *             return P
 *         else:
 *             raise ValueError('Arnoux is not defined on {}'.format(P))             # <<<<<<<<<<<<<<
 * 
 *     def substitutions(self):
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Arnoux_is_not_defined_on, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __pyx_convert__to_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(__pyx_v_P); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2479, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 2479, __pyx_L1_error)
  }

  /* "slabbe/mult_cont_frac.pyx":2435
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.ArnouxRauzy.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2481
 *             raise ValueError('Arnoux is not defined on {}'.format(P))
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_11ArnouxRauzy_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_11ArnouxRauzy_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import ArnouxRauzy\n            sage: ArnouxRauzy().substitutions()\n            {1: WordMorphism: 1->1, 2->21, 3->31,\n             2: WordMorphism: 1->12, 2->2, 3->32,\n             3: WordMorphism: 1->13, 2->23, 3->3}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_11ArnouxRauzy_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_11ArnouxRauzy_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_11ArnouxRauzy_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2491
 *              3: WordMorphism: 1->13, 2->23, 3->3}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2491, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2491, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2491, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2492
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]})}
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2492, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2492, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2492, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2492, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2492, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2492, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2492, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2492, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2492, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2492, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2492, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1, __pyx_t_1) < 0) __PYX_ERR(0, 2492, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2493
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),             # <<<<<<<<<<<<<<
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]})}
 * 
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2493, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2493, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2493, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2493, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2, __pyx_t_1) < 0) __PYX_ERR(0, 2492, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2494
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]})}             # <<<<<<<<<<<<<<
 * 
 *     def dual_substitutions(self):
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2494, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2494, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2494, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2494, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3, __pyx_t_1) < 0) __PYX_ERR(0, 2492, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2481
 *             raise ValueError('Arnoux is not defined on {}'.format(P))
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.ArnouxRauzy.substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2496
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_11ArnouxRauzy_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_11ArnouxRauzy_2dual_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import ArnouxRauzy\n            sage: ArnouxRauzy().dual_substitutions()\n            {1: WordMorphism: 1->123, 2->2, 3->3,\n             2: WordMorphism: 1->1, 2->231, 3->3,\n             3: WordMorphism: 1->1, 2->2, 3->312}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_11ArnouxRauzy_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dual_substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_11ArnouxRauzy_2dual_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_11ArnouxRauzy_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("dual_substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2506
 *              3: WordMorphism: 1->1, 2->2, 3->312}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2507
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]})}
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2507, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2507, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2507, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2507, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1, __pyx_t_1) < 0) __PYX_ERR(0, 2507, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2508
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]})}
 * cdef class Poincare(MCFAlgorithm):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2508, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2508, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2508, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2508, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2, __pyx_t_1) < 0) __PYX_ERR(0, 2507, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2509
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]})}             # <<<<<<<<<<<<<<
 * cdef class Poincare(MCFAlgorithm):
 *     r"""
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2509, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2509, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2509, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3, __pyx_t_1) < 0) __PYX_ERR(0, 2507, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2496
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.ArnouxRauzy.dual_substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2521
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_8Poincare_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_t_1;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2537
 *              ('z', 0.20000000000000007)]
 *         """
 *         return _Poincare(P)             # <<<<<<<<<<<<<<
 * 
 *     def name(self):
 */
  __pyx_t_1 = __pyx_f_6slabbe_14mult_cont_frac__Poincare(__pyx_v_P); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2537, __pyx_L1_error)
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2521
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.Poincare.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2539
 *         return _Poincare(P)
 * 
 *     def name(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_8Poincare_1name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_8Poincare_name[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Poincare\n            sage: Poincare().name()\n            \"Poincar\\\\'e\"\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_8Poincare_1name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("name (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_8Poincare_name(((struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_8Poincare_name(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("name", 0);

  /* "slabbe/mult_cont_frac.pyx":2547
 *             "Poincar\\'e"
 *         """
 *         return r"Poincar\'e"             # <<<<<<<<<<<<<<
 * 
 *     def substitutions(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_kp_s_Poincar_e);
  __pyx_r = __pyx_kp_s_Poincar_e;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2539
 *         return _Poincare(P)
 * 
 *     def name(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":2549
 *         return r"Poincar\'e"
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_8Poincare_3substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_8Poincare_2substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Poincare\n            sage: Poincare().substitutions()\n            {123: WordMorphism: 1->123, 2->23, 3->3,\n             132: WordMorphism: 1->132, 2->2, 3->32,\n             213: WordMorphism: 1->13, 2->213, 3->3,\n             231: WordMorphism: 1->1, 2->231, 3->31,\n             312: WordMorphism: 1->12, 2->2, 3->312,\n             321: WordMorphism: 1->1, 2->21, 3->321}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_8Poincare_3substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_8Poincare_2substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_8Poincare_2substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2562
 *              321: WordMorphism: 1->1, 2->21, 3->321}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {312: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2563
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {312: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),             # <<<<<<<<<<<<<<
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 213: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2563, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_312, __pyx_t_1) < 0) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2564
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {312: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),             # <<<<<<<<<<<<<<
 *                 213: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2564, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2564, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2564, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2564, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_321, __pyx_t_1) < 0) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2565
 *         return {312: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 213: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 231: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 123: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2565, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_213, __pyx_t_1) < 0) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2566
 *                 321: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 213: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 123: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2566, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2566, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2566, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_231, __pyx_t_1) < 0) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2567
 *                 213: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 123: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 132: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2567, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2567, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2567, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2567, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2567, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2567, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_123, __pyx_t_1) < 0) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2568
 *                 231: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 123: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}             # <<<<<<<<<<<<<<
 * 
 *     def dual_substitutions(self):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2568, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2568, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2568, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2568, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_132, __pyx_t_1) < 0) __PYX_ERR(0, 2563, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2549
 *         return r"Poincar\'e"
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.Poincare.substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2570
 *                 132: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_8Poincare_5dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_8Poincare_4dual_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Poincare\n            sage: Poincare().dual_substitutions()\n            {123: WordMorphism: 1->1, 2->21, 3->321,\n             132: WordMorphism: 1->1, 2->231, 3->31,\n             213: WordMorphism: 1->12, 2->2, 3->312,\n             231: WordMorphism: 1->132, 2->2, 3->32,\n             312: WordMorphism: 1->13, 2->213, 3->3,\n             321: WordMorphism: 1->123, 2->23, 3->3}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_8Poincare_5dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dual_substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_8Poincare_4dual_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_8Poincare_4dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("dual_substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2583
 *              321: WordMorphism: 1->123, 2->23, 3->3}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {213: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 123: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2584
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {213: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),             # <<<<<<<<<<<<<<
 *                 123: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 312: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2584, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2584, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2584, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_213, __pyx_t_1) < 0) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2585
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {213: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 123: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),             # <<<<<<<<<<<<<<
 *                 312: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2585, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2585, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2585, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2585, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2585, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2585, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_123, __pyx_t_1) < 0) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2586
 *         return {213: WordMorphism({1: [1, 2], 2: [2], 3: [3, 1, 2]}),
 *                 123: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 312: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 132: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 321: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2586, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2586, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2586, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2586, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_312, __pyx_t_1) < 0) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2587
 *                 123: WordMorphism({1: [1], 2: [2, 1], 3: [3, 2, 1]}),
 *                 312: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 321: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 *                 231: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2587, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2587, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2587, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2587, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_132, __pyx_t_1) < 0) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2588
 *                 312: WordMorphism({1: [1, 3], 2: [2, 1, 3], 3: [3]}),
 *                 132: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 321: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 231: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2588, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2588, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2588, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2588, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_321, __pyx_t_1) < 0) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2589
 *                 132: WordMorphism({1: [1], 2: [2, 3, 1], 3: [3, 1]}),
 *                 321: WordMorphism({1: [1, 2, 3], 2: [2, 3], 3: [3]}),
 *                 231: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}             # <<<<<<<<<<<<<<
 * 
 * cdef class Selmer(MCFAlgorithm):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2589, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2589, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2589, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2589, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2589, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2589, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_231, __pyx_t_1) < 0) __PYX_ERR(0, 2584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2570
 *                 132: WordMorphism({1: [1, 3, 2], 2: [2], 3: [3, 2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.Poincare.dual_substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2602
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_6Selmer_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __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;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2618
 *              ('z', 0.5)]
 *         """
 *         if P.x <= P.y <= P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.x
 *             P.u += P.w
 */
  __pyx_t_1 = (__pyx_v_P.x <= __pyx_v_P.y);
  if (__pyx_t_1) {
    __pyx_t_1 = (__pyx_v_P.y <= __pyx_v_P.z);
  }
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":2619
 *         """
 *         if P.x <= P.y <= P.z:
 *             P.z -= P.x             # <<<<<<<<<<<<<<
 *             P.u += P.w
 *             P.branch = 123
 */
    __pyx_v_P.z = (__pyx_v_P.z - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":2620
 *         if P.x <= P.y <= P.z:
 *             P.z -= P.x
 *             P.u += P.w             # <<<<<<<<<<<<<<
 *             P.branch = 123
 *         elif P.x <= P.z <= P.y:
 */
    __pyx_v_P.u = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2621
 *             P.z -= P.x
 *             P.u += P.w
 *             P.branch = 123             # <<<<<<<<<<<<<<
 *         elif P.x <= P.z <= P.y:
 *             P.y -= P.x
 */
    __pyx_v_P.branch = 0x7B;

    /* "slabbe/mult_cont_frac.pyx":2618
 *              ('z', 0.5)]
 *         """
 *         if P.x <= P.y <= P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.x
 *             P.u += P.w
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2622
 *             P.u += P.w
 *             P.branch = 123
 *         elif P.x <= P.z <= P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.x
 *             P.u += P.v
 */
  __pyx_t_2 = (__pyx_v_P.x <= __pyx_v_P.z);
  if (__pyx_t_2) {
    __pyx_t_2 = (__pyx_v_P.z <= __pyx_v_P.y);
  }
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2623
 *             P.branch = 123
 *         elif P.x <= P.z <= P.y:
 *             P.y -= P.x             # <<<<<<<<<<<<<<
 *             P.u += P.v
 *             P.branch = 132
 */
    __pyx_v_P.y = (__pyx_v_P.y - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":2624
 *         elif P.x <= P.z <= P.y:
 *             P.y -= P.x
 *             P.u += P.v             # <<<<<<<<<<<<<<
 *             P.branch = 132
 *         elif P.y <= P.z <= P.x:
 */
    __pyx_v_P.u = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":2625
 *             P.y -= P.x
 *             P.u += P.v
 *             P.branch = 132             # <<<<<<<<<<<<<<
 *         elif P.y <= P.z <= P.x:
 *             P.x -= P.y
 */
    __pyx_v_P.branch = 0x84;

    /* "slabbe/mult_cont_frac.pyx":2622
 *             P.u += P.w
 *             P.branch = 123
 *         elif P.x <= P.z <= P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.x
 *             P.u += P.v
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2626
 *             P.u += P.v
 *             P.branch = 132
 *         elif P.y <= P.z <= P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.y
 *             P.v += P.u
 */
  __pyx_t_1 = (__pyx_v_P.y <= __pyx_v_P.z);
  if (__pyx_t_1) {
    __pyx_t_1 = (__pyx_v_P.z <= __pyx_v_P.x);
  }
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":2627
 *             P.branch = 132
 *         elif P.y <= P.z <= P.x:
 *             P.x -= P.y             # <<<<<<<<<<<<<<
 *             P.v += P.u
 *             P.branch = 231
 */
    __pyx_v_P.x = (__pyx_v_P.x - __pyx_v_P.y);

    /* "slabbe/mult_cont_frac.pyx":2628
 *         elif P.y <= P.z <= P.x:
 *             P.x -= P.y
 *             P.v += P.u             # <<<<<<<<<<<<<<
 *             P.branch = 231
 *         elif P.y <= P.x <= P.z:
 */
    __pyx_v_P.v = (__pyx_v_P.v + __pyx_v_P.u);

    /* "slabbe/mult_cont_frac.pyx":2629
 *             P.x -= P.y
 *             P.v += P.u
 *             P.branch = 231             # <<<<<<<<<<<<<<
 *         elif P.y <= P.x <= P.z:
 *             P.z -= P.y
 */
    __pyx_v_P.branch = 0xE7;

    /* "slabbe/mult_cont_frac.pyx":2626
 *             P.u += P.v
 *             P.branch = 132
 *         elif P.y <= P.z <= P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.y
 *             P.v += P.u
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2630
 *             P.v += P.u
 *             P.branch = 231
 *         elif P.y <= P.x <= P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.y
 *             P.v += P.w
 */
  __pyx_t_2 = (__pyx_v_P.y <= __pyx_v_P.x);
  if (__pyx_t_2) {
    __pyx_t_2 = (__pyx_v_P.x <= __pyx_v_P.z);
  }
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2631
 *             P.branch = 231
 *         elif P.y <= P.x <= P.z:
 *             P.z -= P.y             # <<<<<<<<<<<<<<
 *             P.v += P.w
 *             P.branch = 213
 */
    __pyx_v_P.z = (__pyx_v_P.z - __pyx_v_P.y);

    /* "slabbe/mult_cont_frac.pyx":2632
 *         elif P.y <= P.x <= P.z:
 *             P.z -= P.y
 *             P.v += P.w             # <<<<<<<<<<<<<<
 *             P.branch = 213
 *         elif P.z <= P.x <= P.y:
 */
    __pyx_v_P.v = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2633
 *             P.z -= P.y
 *             P.v += P.w
 *             P.branch = 213             # <<<<<<<<<<<<<<
 *         elif P.z <= P.x <= P.y:
 *             P.y -= P.z
 */
    __pyx_v_P.branch = 0xD5;

    /* "slabbe/mult_cont_frac.pyx":2630
 *             P.v += P.u
 *             P.branch = 231
 *         elif P.y <= P.x <= P.z:             # <<<<<<<<<<<<<<
 *             P.z -= P.y
 *             P.v += P.w
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2634
 *             P.v += P.w
 *             P.branch = 213
 *         elif P.z <= P.x <= P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.z
 *             P.w += P.v
 */
  __pyx_t_1 = (__pyx_v_P.z <= __pyx_v_P.x);
  if (__pyx_t_1) {
    __pyx_t_1 = (__pyx_v_P.x <= __pyx_v_P.y);
  }
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":2635
 *             P.branch = 213
 *         elif P.z <= P.x <= P.y:
 *             P.y -= P.z             # <<<<<<<<<<<<<<
 *             P.w += P.v
 *             P.branch = 312
 */
    __pyx_v_P.y = (__pyx_v_P.y - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":2636
 *         elif P.z <= P.x <= P.y:
 *             P.y -= P.z
 *             P.w += P.v             # <<<<<<<<<<<<<<
 *             P.branch = 312
 *         elif P.z <= P.y <= P.x:
 */
    __pyx_v_P.w = (__pyx_v_P.w + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":2637
 *             P.y -= P.z
 *             P.w += P.v
 *             P.branch = 312             # <<<<<<<<<<<<<<
 *         elif P.z <= P.y <= P.x:
 *             P.x -= P.z
 */
    __pyx_v_P.branch = 0x138;

    /* "slabbe/mult_cont_frac.pyx":2634
 *             P.v += P.w
 *             P.branch = 213
 *         elif P.z <= P.x <= P.y:             # <<<<<<<<<<<<<<
 *             P.y -= P.z
 *             P.w += P.v
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2638
 *             P.w += P.v
 *             P.branch = 312
 *         elif P.z <= P.y <= P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.z
 *             P.w += P.u
 */
  __pyx_t_2 = (__pyx_v_P.z <= __pyx_v_P.y);
  if (__pyx_t_2) {
    __pyx_t_2 = (__pyx_v_P.y <= __pyx_v_P.x);
  }
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2639
 *             P.branch = 312
 *         elif P.z <= P.y <= P.x:
 *             P.x -= P.z             # <<<<<<<<<<<<<<
 *             P.w += P.u
 *             P.branch = 321
 */
    __pyx_v_P.x = (__pyx_v_P.x - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":2640
 *         elif P.z <= P.y <= P.x:
 *             P.x -= P.z
 *             P.w += P.u             # <<<<<<<<<<<<<<
 *             P.branch = 321
 *         else:
 */
    __pyx_v_P.w = (__pyx_v_P.w + __pyx_v_P.u);

    /* "slabbe/mult_cont_frac.pyx":2641
 *             P.x -= P.z
 *             P.w += P.u
 *             P.branch = 321             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))
 */
    __pyx_v_P.branch = 0x141;

    /* "slabbe/mult_cont_frac.pyx":2638
 *             P.w += P.v
 *             P.branch = 312
 *         elif P.z <= P.y <= P.x:             # <<<<<<<<<<<<<<
 *             P.x -= P.z
 *             P.w += P.u
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2643
 *             P.branch = 321
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))             # <<<<<<<<<<<<<<
 *         return P
 * 
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_limit_case_reach_set_of_measure, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __pyx_convert__to_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(__pyx_v_P); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2643, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2643, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2643, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2643, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":2644
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))
 *         return P             # <<<<<<<<<<<<<<
 * 
 *     def substitutions(self):
 */
  __pyx_r = __pyx_v_P;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2602
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.Selmer.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2646
 *         return P
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_6Selmer_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_6Selmer_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Selmer\n            sage: Selmer().substitutions()\n            {123: WordMorphism: 1->13, 2->2, 3->3,\n             132: WordMorphism: 1->12, 2->2, 3->3,\n             213: WordMorphism: 1->1, 2->23, 3->3,\n             231: WordMorphism: 1->1, 2->21, 3->3,\n             312: WordMorphism: 1->1, 2->2, 3->32,\n             321: WordMorphism: 1->1, 2->2, 3->31}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_6Selmer_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_6Selmer_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_6Selmer_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2659
 *              321: WordMorphism: 1->1, 2->2, 3->31}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {132: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2660
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {132: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 231: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 123: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2660, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2660, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2660, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_132, __pyx_t_1) < 0) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2661
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {132: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 123: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 321: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2661, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2661, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2661, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2661, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2661, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_231, __pyx_t_1) < 0) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2662
 *         return {132: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 231: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 123: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 321: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 213: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2662, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2662, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2662, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2662, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2662, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2662, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2662, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2662, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_123, __pyx_t_1) < 0) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2663
 *                 231: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 123: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 321: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 213: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 *                 312: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2663, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2663, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2663, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2663, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2663, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2663, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_321, __pyx_t_1) < 0) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2664
 *                 123: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 321: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 213: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 312: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2664, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2664, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2664, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2664, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2664, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2664, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_213, __pyx_t_1) < 0) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2665
 *                 321: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 213: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 *                 312: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}             # <<<<<<<<<<<<<<
 * 
 *     def dual_substitutions(self):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2665, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2665, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2665, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2665, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2665, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2665, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2665, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2665, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2665, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2665, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_312, __pyx_t_1) < 0) __PYX_ERR(0, 2660, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2646
 *         return P
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.Selmer.substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2667
 *                 312: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_6Selmer_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_6Selmer_2dual_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Selmer\n            sage: Selmer().dual_substitutions()\n            {123: WordMorphism: 1->1, 2->2, 3->31,\n             132: WordMorphism: 1->1, 2->21, 3->3,\n             213: WordMorphism: 1->1, 2->2, 3->32,\n             231: WordMorphism: 1->12, 2->2, 3->3,\n             312: WordMorphism: 1->1, 2->23, 3->3,\n             321: WordMorphism: 1->13, 2->2, 3->3}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_6Selmer_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dual_substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_6Selmer_2dual_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_6Selmer_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("dual_substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2680
 *              321: WordMorphism: 1->13, 2->2, 3->3}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {231: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 132: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2681
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {231: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 132: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 321: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2681, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2681, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_231, __pyx_t_1) < 0) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2682
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {231: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 132: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 321: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 123: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2682, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2682, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2682, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2682, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_132, __pyx_t_1) < 0) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2683
 *         return {231: WordMorphism({1: [1, 2], 2: [2], 3: [3]}),
 *                 132: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 321: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 123: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 312: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2683, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2683, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2683, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2683, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2683, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2683, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_321, __pyx_t_1) < 0) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2684
 *                 132: WordMorphism({1: [1], 2: [2, 1], 3: [3]}),
 *                 321: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 123: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 312: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 *                 213: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_1, __pyx_t_3) < 0) __PYX_ERR(0, 2684, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_2, __pyx_t_3) < 0) __PYX_ERR(0, 2684, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_5, __pyx_int_3, __pyx_t_3) < 0) __PYX_ERR(0, 2684, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_3 = __pyx_v_WordMorphism; __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2684, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2684, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2684, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_123, __pyx_t_1) < 0) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2685
 *                 321: WordMorphism({1: [1, 3], 2: [2], 3: [3]}),
 *                 123: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 312: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 213: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2685, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2685, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2685, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2685, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2685, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2685, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_312, __pyx_t_1) < 0) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2686
 *                 123: WordMorphism({1: [1], 2: [2], 3: [3, 1]}),
 *                 312: WordMorphism({1: [1], 2: [2, 3], 3: [3]}),
 *                 213: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}             # <<<<<<<<<<<<<<
 * 
 * cdef class FullySubtractive(MCFAlgorithm):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2686, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2686, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2686, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2686, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2686, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2686, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_213, __pyx_t_1) < 0) __PYX_ERR(0, 2681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2667
 *                 312: WordMorphism({1: [1], 2: [2], 3: [3, 2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.Selmer.dual_substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2699
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_16FullySubtractive_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __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;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2715
 *              ('z', 0.5)]
 *         """
 *         if P.x <= P.y and P.x <= P.z:             # <<<<<<<<<<<<<<
 *             P.y -= P.x
 *             P.z -= P.x
 */
  __pyx_t_2 = ((__pyx_v_P.x <= __pyx_v_P.y) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_P.x <= __pyx_v_P.z) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2716
 *         """
 *         if P.x <= P.y and P.x <= P.z:
 *             P.y -= P.x             # <<<<<<<<<<<<<<
 *             P.z -= P.x
 *             P.u += P.v + P.w
 */
    __pyx_v_P.y = (__pyx_v_P.y - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":2717
 *         if P.x <= P.y and P.x <= P.z:
 *             P.y -= P.x
 *             P.z -= P.x             # <<<<<<<<<<<<<<
 *             P.u += P.v + P.w
 *             P.branch = 1
 */
    __pyx_v_P.z = (__pyx_v_P.z - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":2718
 *             P.y -= P.x
 *             P.z -= P.x
 *             P.u += P.v + P.w             # <<<<<<<<<<<<<<
 *             P.branch = 1
 *         elif P.y <= P.x and P.y <= P.z:
 */
    __pyx_v_P.u = (__pyx_v_P.u + (__pyx_v_P.v + __pyx_v_P.w));

    /* "slabbe/mult_cont_frac.pyx":2719
 *             P.z -= P.x
 *             P.u += P.v + P.w
 *             P.branch = 1             # <<<<<<<<<<<<<<
 *         elif P.y <= P.x and P.y <= P.z:
 *             P.x -= P.y
 */
    __pyx_v_P.branch = 1;

    /* "slabbe/mult_cont_frac.pyx":2715
 *              ('z', 0.5)]
 *         """
 *         if P.x <= P.y and P.x <= P.z:             # <<<<<<<<<<<<<<
 *             P.y -= P.x
 *             P.z -= P.x
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2720
 *             P.u += P.v + P.w
 *             P.branch = 1
 *         elif P.y <= P.x and P.y <= P.z:             # <<<<<<<<<<<<<<
 *             P.x -= P.y
 *             P.z -= P.y
 */
  __pyx_t_2 = ((__pyx_v_P.y <= __pyx_v_P.x) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_P.y <= __pyx_v_P.z) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2721
 *             P.branch = 1
 *         elif P.y <= P.x and P.y <= P.z:
 *             P.x -= P.y             # <<<<<<<<<<<<<<
 *             P.z -= P.y
 *             P.v += P.u + P.w
 */
    __pyx_v_P.x = (__pyx_v_P.x - __pyx_v_P.y);

    /* "slabbe/mult_cont_frac.pyx":2722
 *         elif P.y <= P.x and P.y <= P.z:
 *             P.x -= P.y
 *             P.z -= P.y             # <<<<<<<<<<<<<<
 *             P.v += P.u + P.w
 *             P.branch = 2
 */
    __pyx_v_P.z = (__pyx_v_P.z - __pyx_v_P.y);

    /* "slabbe/mult_cont_frac.pyx":2723
 *             P.x -= P.y
 *             P.z -= P.y
 *             P.v += P.u + P.w             # <<<<<<<<<<<<<<
 *             P.branch = 2
 *         elif P.z <= P.x and P.z <= P.y:
 */
    __pyx_v_P.v = (__pyx_v_P.v + (__pyx_v_P.u + __pyx_v_P.w));

    /* "slabbe/mult_cont_frac.pyx":2724
 *             P.z -= P.y
 *             P.v += P.u + P.w
 *             P.branch = 2             # <<<<<<<<<<<<<<
 *         elif P.z <= P.x and P.z <= P.y:
 *             P.x -= P.z
 */
    __pyx_v_P.branch = 2;

    /* "slabbe/mult_cont_frac.pyx":2720
 *             P.u += P.v + P.w
 *             P.branch = 1
 *         elif P.y <= P.x and P.y <= P.z:             # <<<<<<<<<<<<<<
 *             P.x -= P.y
 *             P.z -= P.y
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2725
 *             P.v += P.u + P.w
 *             P.branch = 2
 *         elif P.z <= P.x and P.z <= P.y:             # <<<<<<<<<<<<<<
 *             P.x -= P.z
 *             P.y -= P.z
 */
  __pyx_t_2 = ((__pyx_v_P.z <= __pyx_v_P.x) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_P.z <= __pyx_v_P.y) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2726
 *             P.branch = 2
 *         elif P.z <= P.x and P.z <= P.y:
 *             P.x -= P.z             # <<<<<<<<<<<<<<
 *             P.y -= P.z
 *             P.w += P.u + P.v
 */
    __pyx_v_P.x = (__pyx_v_P.x - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":2727
 *         elif P.z <= P.x and P.z <= P.y:
 *             P.x -= P.z
 *             P.y -= P.z             # <<<<<<<<<<<<<<
 *             P.w += P.u + P.v
 *             P.branch = 3
 */
    __pyx_v_P.y = (__pyx_v_P.y - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":2728
 *             P.x -= P.z
 *             P.y -= P.z
 *             P.w += P.u + P.v             # <<<<<<<<<<<<<<
 *             P.branch = 3
 *         else:
 */
    __pyx_v_P.w = (__pyx_v_P.w + (__pyx_v_P.u + __pyx_v_P.v));

    /* "slabbe/mult_cont_frac.pyx":2729
 *             P.y -= P.z
 *             P.w += P.u + P.v
 *             P.branch = 3             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))
 */
    __pyx_v_P.branch = 3;

    /* "slabbe/mult_cont_frac.pyx":2725
 *             P.v += P.u + P.w
 *             P.branch = 2
 *         elif P.z <= P.x and P.z <= P.y:             # <<<<<<<<<<<<<<
 *             P.x -= P.z
 *             P.y -= P.z
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2731
 *             P.branch = 3
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))             # <<<<<<<<<<<<<<
 *         return P
 * 
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_limit_case_reach_set_of_measure, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2731, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __pyx_convert__to_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(__pyx_v_P); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2731, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2731, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2731, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2731, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2731, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2731, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2731, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":2732
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))
 *         return P             # <<<<<<<<<<<<<<
 * 
 *     def name(self):
 */
  __pyx_r = __pyx_v_P;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2699
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.FullySubtractive.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2734
 *         return P
 * 
 *     def name(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_16FullySubtractive_1name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_16FullySubtractive_name[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import FullySubtractive\n            sage: FullySubtractive().name()\n            'Fully Subtractive'\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_16FullySubtractive_1name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("name (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_16FullySubtractive_name(((struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_16FullySubtractive_name(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("name", 0);

  /* "slabbe/mult_cont_frac.pyx":2742
 *             'Fully Subtractive'
 *         """
 *         return r"Fully Subtractive"             # <<<<<<<<<<<<<<
 * 
 *     def substitutions(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_kp_s_Fully_Subtractive);
  __pyx_r = __pyx_kp_s_Fully_Subtractive;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2734
 *         return P
 * 
 *     def name(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":2744
 *         return r"Fully Subtractive"
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_16FullySubtractive_3substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_16FullySubtractive_2substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import FullySubtractive\n            sage: FullySubtractive().substitutions()\n            {1: WordMorphism: 1->123, 2->2, 3->3,\n             2: WordMorphism: 1->1, 2->231, 3->3,\n             3: WordMorphism: 1->1, 2->2, 3->312}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_16FullySubtractive_3substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_16FullySubtractive_2substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_16FullySubtractive_2substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2754
 *              3: WordMorphism: 1->1, 2->2, 3->312}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2754, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2754, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2754, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2755
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]})}
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2755, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2755, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2755, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2755, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2755, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2755, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1, __pyx_t_1) < 0) __PYX_ERR(0, 2755, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2756
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),             # <<<<<<<<<<<<<<
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]})}
 * 
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2756, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2756, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2756, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2756, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2756, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2756, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2, __pyx_t_1) < 0) __PYX_ERR(0, 2755, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2757
 *         return {1: WordMorphism({1: [1,2,3], 2: [2], 3: [3]}),
 *                 2: WordMorphism({1: [1], 2: [2,3,1], 3: [3]}),
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]})}             # <<<<<<<<<<<<<<
 * 
 *     def dual_substitutions(self):
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2757, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2757, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2757, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2757, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2757, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2757, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3, __pyx_t_1) < 0) __PYX_ERR(0, 2755, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2744
 *         return r"Fully Subtractive"
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.FullySubtractive.substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2759
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_16FullySubtractive_5dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_16FullySubtractive_4dual_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import FullySubtractive\n            sage: FullySubtractive().dual_substitutions()\n            {1: WordMorphism: 1->1, 2->21, 3->31,\n             2: WordMorphism: 1->12, 2->2, 3->32,\n             3: WordMorphism: 1->13, 2->23, 3->3}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_16FullySubtractive_5dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dual_substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_16FullySubtractive_4dual_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_16FullySubtractive_4dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("dual_substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2769
 *              3: WordMorphism: 1->13, 2->23, 3->3}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2769, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2769, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2769, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2770
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),             # <<<<<<<<<<<<<<
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]})}
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2770, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2770, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2770, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1, __pyx_t_1) < 0) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2771
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),             # <<<<<<<<<<<<<<
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]})}
 * 
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2771, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2771, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2771, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2771, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2771, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2771, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2, __pyx_t_1) < 0) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2772
 *         return {1:  WordMorphism({1: [1], 2: [2, 1], 3: [3, 1]}),
 *                 2:  WordMorphism({1: [1, 2], 2: [2], 3: [3, 2]}),
 *                 3:  WordMorphism({1: [1, 3], 2: [2, 3], 3: [3]})}             # <<<<<<<<<<<<<<
 * 
 * cdef class Cassaigne(MCFAlgorithm):
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_1, __pyx_t_5) < 0) __PYX_ERR(0, 2772, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 2772, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_6, __pyx_int_3, __pyx_t_5) < 0) __PYX_ERR(0, 2772, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_5 = __pyx_v_WordMorphism; __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && 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);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2772, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3, __pyx_t_1) < 0) __PYX_ERR(0, 2770, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2759
 *                 3: WordMorphism({1: [1], 2: [2], 3: [3,1,2]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.FullySubtractive.dual_substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2785
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         This algorithm was provided by Julien Cassaigne during a meeting of
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_9Cassaigne_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  double __pyx_v_tmp;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  double __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;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2807
 *         """
 *         cdef double tmp
 *         if P.x >= P.z :             # <<<<<<<<<<<<<<
 *             P.x -= P.z
 *             tmp = P.y
 */
  __pyx_t_1 = ((__pyx_v_P.x >= __pyx_v_P.z) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2808
 *         cdef double tmp
 *         if P.x >= P.z :
 *             P.x -= P.z             # <<<<<<<<<<<<<<
 *             tmp = P.y
 *             P.y = P.z
 */
    __pyx_v_P.x = (__pyx_v_P.x - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":2809
 *         if P.x >= P.z :
 *             P.x -= P.z
 *             tmp = P.y             # <<<<<<<<<<<<<<
 *             P.y = P.z
 *             P.z = tmp
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_tmp = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":2810
 *             P.x -= P.z
 *             tmp = P.y
 *             P.y = P.z             # <<<<<<<<<<<<<<
 *             P.z = tmp
 *             tmp = P.v
 */
    __pyx_t_2 = __pyx_v_P.z;
    __pyx_v_P.y = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":2811
 *             tmp = P.y
 *             P.y = P.z
 *             P.z = tmp             # <<<<<<<<<<<<<<
 *             tmp = P.v
 *             P.v = P.u + P.w
 */
    __pyx_v_P.z = __pyx_v_tmp;

    /* "slabbe/mult_cont_frac.pyx":2812
 *             P.y = P.z
 *             P.z = tmp
 *             tmp = P.v             # <<<<<<<<<<<<<<
 *             P.v = P.u + P.w
 *             P.w = tmp
 */
    __pyx_t_2 = __pyx_v_P.v;
    __pyx_v_tmp = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":2813
 *             P.z = tmp
 *             tmp = P.v
 *             P.v = P.u + P.w             # <<<<<<<<<<<<<<
 *             P.w = tmp
 *             P.branch = 1
 */
    __pyx_v_P.v = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2814
 *             tmp = P.v
 *             P.v = P.u + P.w
 *             P.w = tmp             # <<<<<<<<<<<<<<
 *             P.branch = 1
 *         elif P.x < P.z :
 */
    __pyx_v_P.w = __pyx_v_tmp;

    /* "slabbe/mult_cont_frac.pyx":2815
 *             P.v = P.u + P.w
 *             P.w = tmp
 *             P.branch = 1             # <<<<<<<<<<<<<<
 *         elif P.x < P.z :
 *             P.z -= P.x
 */
    __pyx_v_P.branch = 1;

    /* "slabbe/mult_cont_frac.pyx":2807
 *         """
 *         cdef double tmp
 *         if P.x >= P.z :             # <<<<<<<<<<<<<<
 *             P.x -= P.z
 *             tmp = P.y
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2816
 *             P.w = tmp
 *             P.branch = 1
 *         elif P.x < P.z :             # <<<<<<<<<<<<<<
 *             P.z -= P.x
 *             tmp = P.y
 */
  __pyx_t_1 = ((__pyx_v_P.x < __pyx_v_P.z) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":2817
 *             P.branch = 1
 *         elif P.x < P.z :
 *             P.z -= P.x             # <<<<<<<<<<<<<<
 *             tmp = P.y
 *             P.y = P.x
 */
    __pyx_v_P.z = (__pyx_v_P.z - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":2818
 *         elif P.x < P.z :
 *             P.z -= P.x
 *             tmp = P.y             # <<<<<<<<<<<<<<
 *             P.y = P.x
 *             P.x = tmp
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_tmp = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":2819
 *             P.z -= P.x
 *             tmp = P.y
 *             P.y = P.x             # <<<<<<<<<<<<<<
 *             P.x = tmp
 *             tmp = P.v
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_P.y = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":2820
 *             tmp = P.y
 *             P.y = P.x
 *             P.x = tmp             # <<<<<<<<<<<<<<
 *             tmp = P.v
 *             P.v = P.u + P.w
 */
    __pyx_v_P.x = __pyx_v_tmp;

    /* "slabbe/mult_cont_frac.pyx":2821
 *             P.y = P.x
 *             P.x = tmp
 *             tmp = P.v             # <<<<<<<<<<<<<<
 *             P.v = P.u + P.w
 *             P.u = tmp
 */
    __pyx_t_2 = __pyx_v_P.v;
    __pyx_v_tmp = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":2822
 *             P.x = tmp
 *             tmp = P.v
 *             P.v = P.u + P.w             # <<<<<<<<<<<<<<
 *             P.u = tmp
 *             P.branch = 2
 */
    __pyx_v_P.v = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":2823
 *             tmp = P.v
 *             P.v = P.u + P.w
 *             P.u = tmp             # <<<<<<<<<<<<<<
 *             P.branch = 2
 *         else:
 */
    __pyx_v_P.u = __pyx_v_tmp;

    /* "slabbe/mult_cont_frac.pyx":2824
 *             P.v = P.u + P.w
 *             P.u = tmp
 *             P.branch = 2             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))
 */
    __pyx_v_P.branch = 2;

    /* "slabbe/mult_cont_frac.pyx":2816
 *             P.w = tmp
 *             P.branch = 1
 *         elif P.x < P.z :             # <<<<<<<<<<<<<<
 *             P.z -= P.x
 *             tmp = P.y
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":2826
 *             P.branch = 2
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))             # <<<<<<<<<<<<<<
 *         return P
 * 
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_limit_case_reach_set_of_measure, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2826, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __pyx_convert__to_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(__pyx_v_P); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2826, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && 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);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2826, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2826, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2826, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2826, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2826, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2826, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":2827
 *         else:
 *             raise ValueError('limit case: reach set of measure zero: {}'.format(P))
 *         return P             # <<<<<<<<<<<<<<
 * 
 *     def substitutions(self):
 */
  __pyx_r = __pyx_v_P;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2785
 *         sage: algo._test_definition()
 *     """
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         This algorithm was provided by Julien Cassaigne during a meeting of
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.Cassaigne.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2829
 *         return P
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_9Cassaigne_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_9Cassaigne_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Cassaigne\n            sage: Cassaigne().substitutions()\n            {1: WordMorphism: 1->1, 2->13, 3->2, \n             2: WordMorphism: 1->2, 2->13, 3->3}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_9Cassaigne_1substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_9Cassaigne_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_9Cassaigne_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2838
 *              2: WordMorphism: 1->2, 2->13, 3->3}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {1:  WordMorphism({1: [1], 2: [1, 3], 3: [2]}),
 *                 2:  WordMorphism({1: [2], 2: [1, 3], 3: [3]})}
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2839
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1], 2: [1, 3], 3: [2]}),             # <<<<<<<<<<<<<<
 *                 2:  WordMorphism({1: [2], 2: [1, 3], 3: [3]})}
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2839, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2839, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2839, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2839, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2839, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2839, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2839, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2839, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2839, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2839, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2839, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1, __pyx_t_1) < 0) __PYX_ERR(0, 2839, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2840
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1], 2: [1, 3], 3: [2]}),
 *                 2:  WordMorphism({1: [2], 2: [1, 3], 3: [3]})}             # <<<<<<<<<<<<<<
 * 
 *     def dual_substitutions(self):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2840, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2840, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2840, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2840, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2, __pyx_t_1) < 0) __PYX_ERR(0, 2839, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2829
 *         return P
 * 
 *     def substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.Cassaigne.substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2842
 *                 2:  WordMorphism({1: [2], 2: [1, 3], 3: [3]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

/* Python wrapper */
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_9Cassaigne_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6slabbe_14mult_cont_frac_9Cassaigne_2dual_substitutions[] = "\n        EXAMPLES::\n\n            sage: from slabbe.mult_cont_frac import Cassaigne\n            sage: Cassaigne().dual_substitutions()\n            {1: WordMorphism: 1->12, 2->3, 3->2, \n             2: WordMorphism: 1->2, 2->1, 3->23}\n        ";
static PyObject *__pyx_pw_6slabbe_14mult_cont_frac_9Cassaigne_3dual_substitutions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dual_substitutions (wrapper)", 0);
  __pyx_r = __pyx_pf_6slabbe_14mult_cont_frac_9Cassaigne_2dual_substitutions(((struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne *)__pyx_v_self));

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

static PyObject *__pyx_pf_6slabbe_14mult_cont_frac_9Cassaigne_2dual_substitutions(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne *__pyx_v_self) {
  PyObject *__pyx_v_WordMorphism = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("dual_substitutions", 0);

  /* "slabbe/mult_cont_frac.pyx":2851
 *              2: WordMorphism: 1->2, 2->1, 3->23}
 *         """
 *         from sage.combinat.words.morphism import WordMorphism             # <<<<<<<<<<<<<<
 *         return {1:  WordMorphism({1: [1,2], 2: [3], 3: [2]}),
 *                 2:  WordMorphism({1: [2], 2: [1], 3: [2,3]})}
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_WordMorphism);
  __Pyx_GIVEREF(__pyx_n_s_WordMorphism);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_WordMorphism);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sage_combinat_words_morphism, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_WordMorphism); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_WordMorphism = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "slabbe/mult_cont_frac.pyx":2852
 *         """
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1,2], 2: [3], 3: [2]}),             # <<<<<<<<<<<<<<
 *                 2:  WordMorphism({1: [2], 2: [1], 3: [2,3]})}
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 2852, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_t_4) < 0) __PYX_ERR(0, 2852, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_t_4) < 0) __PYX_ERR(0, 2852, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_4 = __pyx_v_WordMorphism; __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2852, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2852, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2852, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_1, __pyx_t_1) < 0) __PYX_ERR(0, 2852, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "slabbe/mult_cont_frac.pyx":2853
 *         from sage.combinat.words.morphism import WordMorphism
 *         return {1:  WordMorphism({1: [1,2], 2: [3], 3: [2]}),
 *                 2:  WordMorphism({1: [2], 2: [1], 3: [2,3]})}             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_Brun(MCFAlgorithm):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_1, __pyx_t_6) < 0) __PYX_ERR(0, 2853, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_2, __pyx_t_6) < 0) __PYX_ERR(0, 2853, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_int_3, __pyx_t_6) < 0) __PYX_ERR(0, 2853, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_WordMorphism);
  __pyx_t_6 = __pyx_v_WordMorphism; __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2853, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_2, __pyx_t_1) < 0) __PYX_ERR(0, 2852, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2842
 *                 2:  WordMorphism({1: [2], 2: [1, 3], 3: [3]})}
 * 
 *     def dual_substitutions(self):             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* 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_AddTraceback("slabbe.mult_cont_frac.Cassaigne.dual_substitutions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_WordMorphism);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2856
 * 
 * cdef class Sorted_Brun(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_11Sorted_Brun_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Brun *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2893
 * 
 *         """
 *         P.z -= P.y             # <<<<<<<<<<<<<<
 *         P.v += P.w
 *         P.branch = 100
 */
  __pyx_v_P.z = (__pyx_v_P.z - __pyx_v_P.y);

  /* "slabbe/mult_cont_frac.pyx":2894
 *         """
 *         P.z -= P.y
 *         P.v += P.w             # <<<<<<<<<<<<<<
 *         P.branch = 100
 *         return Sort(P)
 */
  __pyx_v_P.v = (__pyx_v_P.v + __pyx_v_P.w);

  /* "slabbe/mult_cont_frac.pyx":2895
 *         P.z -= P.y
 *         P.v += P.w
 *         P.branch = 100             # <<<<<<<<<<<<<<
 *         return Sort(P)
 * 
 */
  __pyx_v_P.branch = 0x64;

  /* "slabbe/mult_cont_frac.pyx":2896
 *         P.v += P.w
 *         P.branch = 100
 *         return Sort(P)             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_BrunMulti(MCFAlgorithm):
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_P);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2856
 * 
 * cdef class Sorted_Brun(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":2899
 * 
 * cdef class Sorted_BrunMulti(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_16Sorted_BrunMulti_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_BrunMulti *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  int __pyx_v_m;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2915
 *              ('z', 0.3)]
 *         """
 *         cdef int m = <int>(P.z / P.y)             # <<<<<<<<<<<<<<
 *         P.z -= m*P.y
 *         P.v += m*P.w
 */
  if (unlikely(__pyx_v_P.y == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 2915, __pyx_L1_error)
  }
  __pyx_v_m = ((int)(__pyx_v_P.z / __pyx_v_P.y));

  /* "slabbe/mult_cont_frac.pyx":2916
 *         """
 *         cdef int m = <int>(P.z / P.y)
 *         P.z -= m*P.y             # <<<<<<<<<<<<<<
 *         P.v += m*P.w
 *         P.branch = 100
 */
  __pyx_v_P.z = (__pyx_v_P.z - (__pyx_v_m * __pyx_v_P.y));

  /* "slabbe/mult_cont_frac.pyx":2917
 *         cdef int m = <int>(P.z / P.y)
 *         P.z -= m*P.y
 *         P.v += m*P.w             # <<<<<<<<<<<<<<
 *         P.branch = 100
 *         return Sort(P)
 */
  __pyx_v_P.v = (__pyx_v_P.v + (__pyx_v_m * __pyx_v_P.w));

  /* "slabbe/mult_cont_frac.pyx":2918
 *         P.z -= m*P.y
 *         P.v += m*P.w
 *         P.branch = 100             # <<<<<<<<<<<<<<
 *         return Sort(P)
 * 
 */
  __pyx_v_P.branch = 0x64;

  /* "slabbe/mult_cont_frac.pyx":2919
 *         P.v += m*P.w
 *         P.branch = 100
 *         return Sort(P)             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_Selmer(MCFAlgorithm):
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_P);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2899
 * 
 * cdef class Sorted_BrunMulti(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.Sorted_BrunMulti.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":2922
 * 
 * cdef class Sorted_Selmer(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_13Sorted_Selmer_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Selmer *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2938
 *              ('z', 0.6000000000000001)]
 *         """
 *         P.z -= P.x             # <<<<<<<<<<<<<<
 *         P.u += P.w
 *         P.branch = 100
 */
  __pyx_v_P.z = (__pyx_v_P.z - __pyx_v_P.x);

  /* "slabbe/mult_cont_frac.pyx":2939
 *         """
 *         P.z -= P.x
 *         P.u += P.w             # <<<<<<<<<<<<<<
 *         P.branch = 100
 *         return Sort(P)
 */
  __pyx_v_P.u = (__pyx_v_P.u + __pyx_v_P.w);

  /* "slabbe/mult_cont_frac.pyx":2940
 *         P.z -= P.x
 *         P.u += P.w
 *         P.branch = 100             # <<<<<<<<<<<<<<
 *         return Sort(P)
 * 
 */
  __pyx_v_P.branch = 0x64;

  /* "slabbe/mult_cont_frac.pyx":2941
 *         P.u += P.w
 *         P.branch = 100
 *         return Sort(P)             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_Meester(MCFAlgorithm):
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_P);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2922
 * 
 * cdef class Sorted_Selmer(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":2944
 * 
 * cdef class Sorted_Meester(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_14Sorted_Meester_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Meester *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":2961
 *         """
 *         # Apply the algo
 *         P.y -= P.x             # <<<<<<<<<<<<<<
 *         P.z -= P.x
 *         P.u += P.v + P.w
 */
  __pyx_v_P.y = (__pyx_v_P.y - __pyx_v_P.x);

  /* "slabbe/mult_cont_frac.pyx":2962
 *         # Apply the algo
 *         P.y -= P.x
 *         P.z -= P.x             # <<<<<<<<<<<<<<
 *         P.u += P.v + P.w
 *         P.branch = 100
 */
  __pyx_v_P.z = (__pyx_v_P.z - __pyx_v_P.x);

  /* "slabbe/mult_cont_frac.pyx":2963
 *         P.y -= P.x
 *         P.z -= P.x
 *         P.u += P.v + P.w             # <<<<<<<<<<<<<<
 *         P.branch = 100
 *         return Sort(P)
 */
  __pyx_v_P.u = (__pyx_v_P.u + (__pyx_v_P.v + __pyx_v_P.w));

  /* "slabbe/mult_cont_frac.pyx":2964
 *         P.z -= P.x
 *         P.u += P.v + P.w
 *         P.branch = 100             # <<<<<<<<<<<<<<
 *         return Sort(P)
 * 
 */
  __pyx_v_P.branch = 0x64;

  /* "slabbe/mult_cont_frac.pyx":2965
 *         P.u += P.v + P.w
 *         P.branch = 100
 *         return Sort(P)             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_ArnouxRauzy(MCFAlgorithm):
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_P);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2944
 * 
 * cdef class Sorted_Meester(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":2968
 * 
 * cdef class Sorted_ArnouxRauzy(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_18Sorted_ArnouxRauzy_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3000
 *         #Arnoux-Rauzy
 *         cdef PairPoint3d R
 *         R.x = P.x             # <<<<<<<<<<<<<<
 *         R.y = P.y
 *         R.z = P.z - (P.x + P.y)
 */
  __pyx_t_1 = __pyx_v_P.x;
  __pyx_v_R.x = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3001
 *         cdef PairPoint3d R
 *         R.x = P.x
 *         R.y = P.y             # <<<<<<<<<<<<<<
 *         R.z = P.z - (P.x + P.y)
 *         R.u = P.u + P.w
 */
  __pyx_t_1 = __pyx_v_P.y;
  __pyx_v_R.y = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3002
 *         R.x = P.x
 *         R.y = P.y
 *         R.z = P.z - (P.x + P.y)             # <<<<<<<<<<<<<<
 *         R.u = P.u + P.w
 *         R.v = P.v + P.w
 */
  __pyx_v_R.z = (__pyx_v_P.z - (__pyx_v_P.x + __pyx_v_P.y));

  /* "slabbe/mult_cont_frac.pyx":3003
 *         R.y = P.y
 *         R.z = P.z - (P.x + P.y)
 *         R.u = P.u + P.w             # <<<<<<<<<<<<<<
 *         R.v = P.v + P.w
 *         R.w = P.w
 */
  __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.w);

  /* "slabbe/mult_cont_frac.pyx":3004
 *         R.z = P.z - (P.x + P.y)
 *         R.u = P.u + P.w
 *         R.v = P.v + P.w             # <<<<<<<<<<<<<<
 *         R.w = P.w
 *         R.branch = 100
 */
  __pyx_v_R.v = (__pyx_v_P.v + __pyx_v_P.w);

  /* "slabbe/mult_cont_frac.pyx":3005
 *         R.u = P.u + P.w
 *         R.v = P.v + P.w
 *         R.w = P.w             # <<<<<<<<<<<<<<
 *         R.branch = 100
 *         return Sort(R)
 */
  __pyx_t_1 = __pyx_v_P.w;
  __pyx_v_R.w = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3006
 *         R.v = P.v + P.w
 *         R.w = P.w
 *         R.branch = 100             # <<<<<<<<<<<<<<
 *         return Sort(R)
 * 
 */
  __pyx_v_R.branch = 0x64;

  /* "slabbe/mult_cont_frac.pyx":3007
 *         R.w = P.w
 *         R.branch = 100
 *         return Sort(R)             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_ArnouxRauzyMulti(MCFAlgorithm):
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_R);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":2968
 * 
 * cdef class Sorted_ArnouxRauzy(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":3010
 * 
 * cdef class Sorted_ArnouxRauzyMulti(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_23Sorted_ArnouxRauzyMulti_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  int __pyx_v_m;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3017
 *         #Arnoux-Rauzy Multi
 *         cdef int m
 *         m = <int>(P.z / (P.x + P.y))             # <<<<<<<<<<<<<<
 *         P.z -= m * (P.x + P.y)
 *         P.v += m * P.w;
 */
  __pyx_t_1 = (__pyx_v_P.x + __pyx_v_P.y);
  if (unlikely(__pyx_t_1 == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 3017, __pyx_L1_error)
  }
  __pyx_v_m = ((int)(__pyx_v_P.z / __pyx_t_1));

  /* "slabbe/mult_cont_frac.pyx":3018
 *         cdef int m
 *         m = <int>(P.z / (P.x + P.y))
 *         P.z -= m * (P.x + P.y)             # <<<<<<<<<<<<<<
 *         P.v += m * P.w;
 *         P.u += m * P.w;
 */
  __pyx_v_P.z = (__pyx_v_P.z - (__pyx_v_m * (__pyx_v_P.x + __pyx_v_P.y)));

  /* "slabbe/mult_cont_frac.pyx":3019
 *         m = <int>(P.z / (P.x + P.y))
 *         P.z -= m * (P.x + P.y)
 *         P.v += m * P.w;             # <<<<<<<<<<<<<<
 *         P.u += m * P.w;
 *         P.branch = 100
 */
  __pyx_v_P.v = (__pyx_v_P.v + (__pyx_v_m * __pyx_v_P.w));

  /* "slabbe/mult_cont_frac.pyx":3020
 *         P.z -= m * (P.x + P.y)
 *         P.v += m * P.w;
 *         P.u += m * P.w;             # <<<<<<<<<<<<<<
 *         P.branch = 100
 *         return Sort(P)
 */
  __pyx_v_P.u = (__pyx_v_P.u + (__pyx_v_m * __pyx_v_P.w));

  /* "slabbe/mult_cont_frac.pyx":3021
 *         P.v += m * P.w;
 *         P.u += m * P.w;
 *         P.branch = 100             # <<<<<<<<<<<<<<
 *         return Sort(P)
 * 
 */
  __pyx_v_P.branch = 0x64;

  /* "slabbe/mult_cont_frac.pyx":3022
 *         P.u += m * P.w;
 *         P.branch = 100
 *         return Sort(P)             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_ARP(MCFAlgorithm):
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_P);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3010
 * 
 * cdef class Sorted_ArnouxRauzyMulti(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.Sorted_ArnouxRauzyMulti.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":3025
 * 
 * cdef class Sorted_ARP(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_10Sorted_ARP_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARP *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3055
 *         """
 *         # Apply the algo
 *         if P.z > P.x + P.y:             # <<<<<<<<<<<<<<
 *             return _Sorted_ArnouxRauzy(P)
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_P.z > (__pyx_v_P.x + __pyx_v_P.y)) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3056
 *         # Apply the algo
 *         if P.z > P.x + P.y:
 *             return _Sorted_ArnouxRauzy(P)             # <<<<<<<<<<<<<<
 *         else:
 *             return _Sorted_Poincare(P)
 */
    __pyx_r = __pyx_f_6slabbe_14mult_cont_frac__Sorted_ArnouxRauzy(__pyx_v_P);
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":3055
 *         """
 *         # Apply the algo
 *         if P.z > P.x + P.y:             # <<<<<<<<<<<<<<
 *             return _Sorted_ArnouxRauzy(P)
 *         else:
 */
  }

  /* "slabbe/mult_cont_frac.pyx":3058
 *             return _Sorted_ArnouxRauzy(P)
 *         else:
 *             return _Sorted_Poincare(P)             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_ARPMulti(MCFAlgorithm):
 */
  /*else*/ {
    __pyx_r = __pyx_f_6slabbe_14mult_cont_frac__Sorted_Poincare(__pyx_v_P);
    goto __pyx_L0;
  }

  /* "slabbe/mult_cont_frac.pyx":3025
 * 
 * cdef class Sorted_ARP(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":3061
 * 
 * cdef class Sorted_ARPMulti(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_15Sorted_ARPMulti_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARPMulti *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3078
 *         """
 *         # Apply the algo
 *         if P.z > P.x + P.y:             # <<<<<<<<<<<<<<
 *             return _Sorted_ArnouxRauzyMulti(P)
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_P.z > (__pyx_v_P.x + __pyx_v_P.y)) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3079
 *         # Apply the algo
 *         if P.z > P.x + P.y:
 *             return _Sorted_ArnouxRauzyMulti(P)             # <<<<<<<<<<<<<<
 *         else:
 *             return _Sorted_Poincare(P)
 */
    __pyx_r = __pyx_f_6slabbe_14mult_cont_frac__Sorted_ArnouxRauzyMulti(__pyx_v_P);
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":3078
 *         """
 *         # Apply the algo
 *         if P.z > P.x + P.y:             # <<<<<<<<<<<<<<
 *             return _Sorted_ArnouxRauzyMulti(P)
 *         else:
 */
  }

  /* "slabbe/mult_cont_frac.pyx":3081
 *             return _Sorted_ArnouxRauzyMulti(P)
 *         else:
 *             return _Sorted_Poincare(P)             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_Poincare(MCFAlgorithm):
 */
  /*else*/ {
    __pyx_r = __pyx_f_6slabbe_14mult_cont_frac__Sorted_Poincare(__pyx_v_P);
    goto __pyx_L0;
  }

  /* "slabbe/mult_cont_frac.pyx":3061
 * 
 * cdef class Sorted_ARPMulti(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":3084
 * 
 * cdef class Sorted_Poincare(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_15Sorted_Poincare_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Poincare *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3115
 *         # Apply the algo
 *         cdef PairPoint3d R
 *         R.x = P.x             # <<<<<<<<<<<<<<
 *         R.y = P.y - P.x
 *         R.z = P.z - P.y
 */
  __pyx_t_1 = __pyx_v_P.x;
  __pyx_v_R.x = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3116
 *         cdef PairPoint3d R
 *         R.x = P.x
 *         R.y = P.y - P.x             # <<<<<<<<<<<<<<
 *         R.z = P.z - P.y
 *         R.u = P.u + P.v + P.w
 */
  __pyx_v_R.y = (__pyx_v_P.y - __pyx_v_P.x);

  /* "slabbe/mult_cont_frac.pyx":3117
 *         R.x = P.x
 *         R.y = P.y - P.x
 *         R.z = P.z - P.y             # <<<<<<<<<<<<<<
 *         R.u = P.u + P.v + P.w
 *         R.v = P.v + P.w
 */
  __pyx_v_R.z = (__pyx_v_P.z - __pyx_v_P.y);

  /* "slabbe/mult_cont_frac.pyx":3118
 *         R.y = P.y - P.x
 *         R.z = P.z - P.y
 *         R.u = P.u + P.v + P.w             # <<<<<<<<<<<<<<
 *         R.v = P.v + P.w
 *         R.w = P.w
 */
  __pyx_v_R.u = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

  /* "slabbe/mult_cont_frac.pyx":3119
 *         R.z = P.z - P.y
 *         R.u = P.u + P.v + P.w
 *         R.v = P.v + P.w             # <<<<<<<<<<<<<<
 *         R.w = P.w
 *         R.branch = 200
 */
  __pyx_v_R.v = (__pyx_v_P.v + __pyx_v_P.w);

  /* "slabbe/mult_cont_frac.pyx":3120
 *         R.u = P.u + P.v + P.w
 *         R.v = P.v + P.w
 *         R.w = P.w             # <<<<<<<<<<<<<<
 *         R.branch = 200
 *         return Sort(R)
 */
  __pyx_t_1 = __pyx_v_P.w;
  __pyx_v_R.w = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3121
 *         R.v = P.v + P.w
 *         R.w = P.w
 *         R.branch = 200             # <<<<<<<<<<<<<<
 *         return Sort(R)
 * 
 */
  __pyx_v_R.branch = 0xC8;

  /* "slabbe/mult_cont_frac.pyx":3122
 *         R.w = P.w
 *         R.branch = 200
 *         return Sort(R)             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_ARrevert(MCFAlgorithm):
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_R);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3084
 * 
 * cdef class Sorted_Poincare(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":3125
 * 
 * cdef class Sorted_ARrevert(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_15Sorted_ARrevert_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevert *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  double __pyx_v_z_x_y;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  double __pyx_t_2;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3142
 *         """
 *         cdef PairPoint3d R
 *         cdef double z_x_y = P.z - P.x - P.y             # <<<<<<<<<<<<<<
 *         if z_x_y > P.y:
 *             R.x = P.x
 */
  __pyx_v_z_x_y = ((__pyx_v_P.z - __pyx_v_P.x) - __pyx_v_P.y);

  /* "slabbe/mult_cont_frac.pyx":3143
 *         cdef PairPoint3d R
 *         cdef double z_x_y = P.z - P.x - P.y
 *         if z_x_y > P.y:             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = P.y
 */
  __pyx_t_1 = ((__pyx_v_z_x_y > __pyx_v_P.y) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3144
 *         cdef double z_x_y = P.z - P.x - P.y
 *         if z_x_y > P.y:
 *             R.x = P.x             # <<<<<<<<<<<<<<
 *             R.y = P.y
 *             R.z = z_x_y
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3145
 *         if z_x_y > P.y:
 *             R.x = P.x
 *             R.y = P.y             # <<<<<<<<<<<<<<
 *             R.z = z_x_y
 *             R.u = P.u + P.w
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_R.y = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3146
 *             R.x = P.x
 *             R.y = P.y
 *             R.z = z_x_y             # <<<<<<<<<<<<<<
 *             R.u = P.u + P.w
 *             R.v = P.v + P.w
 */
    __pyx_v_R.z = __pyx_v_z_x_y;

    /* "slabbe/mult_cont_frac.pyx":3147
 *             R.y = P.y
 *             R.z = z_x_y
 *             R.u = P.u + P.w             # <<<<<<<<<<<<<<
 *             R.v = P.v + P.w
 *             R.w = P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3148
 *             R.z = z_x_y
 *             R.u = P.u + P.w
 *             R.v = P.v + P.w             # <<<<<<<<<<<<<<
 *             R.w = P.w
 *             R.branch = 100
 */
    __pyx_v_R.v = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3149
 *             R.u = P.u + P.w
 *             R.v = P.v + P.w
 *             R.w = P.w             # <<<<<<<<<<<<<<
 *             R.branch = 100
 *         elif z_x_y > P.x:
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_R.w = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3150
 *             R.v = P.v + P.w
 *             R.w = P.w
 *             R.branch = 100             # <<<<<<<<<<<<<<
 *         elif z_x_y > P.x:
 *             R.x = P.x
 */
    __pyx_v_R.branch = 0x64;

    /* "slabbe/mult_cont_frac.pyx":3143
 *         cdef PairPoint3d R
 *         cdef double z_x_y = P.z - P.x - P.y
 *         if z_x_y > P.y:             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = P.y
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3151
 *             R.w = P.w
 *             R.branch = 100
 *         elif z_x_y > P.x:             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = z_x_y
 */
  __pyx_t_1 = ((__pyx_v_z_x_y > __pyx_v_P.x) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3152
 *             R.branch = 100
 *         elif z_x_y > P.x:
 *             R.x = P.x             # <<<<<<<<<<<<<<
 *             R.y = z_x_y
 *             R.z = P.y
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3153
 *         elif z_x_y > P.x:
 *             R.x = P.x
 *             R.y = z_x_y             # <<<<<<<<<<<<<<
 *             R.z = P.y
 *             R.u = P.u + P.w
 */
    __pyx_v_R.y = __pyx_v_z_x_y;

    /* "slabbe/mult_cont_frac.pyx":3154
 *             R.x = P.x
 *             R.y = z_x_y
 *             R.z = P.y             # <<<<<<<<<<<<<<
 *             R.u = P.u + P.w
 *             R.v = P.w
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_R.z = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3155
 *             R.y = z_x_y
 *             R.z = P.y
 *             R.u = P.u + P.w             # <<<<<<<<<<<<<<
 *             R.v = P.w
 *             R.w = P.v + P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3156
 *             R.z = P.y
 *             R.u = P.u + P.w
 *             R.v = P.w             # <<<<<<<<<<<<<<
 *             R.w = P.v + P.w
 *             R.branch = 200
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_R.v = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3157
 *             R.u = P.u + P.w
 *             R.v = P.w
 *             R.w = P.v + P.w             # <<<<<<<<<<<<<<
 *             R.branch = 200
 *         elif z_x_y > 0:
 */
    __pyx_v_R.w = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3158
 *             R.v = P.w
 *             R.w = P.v + P.w
 *             R.branch = 200             # <<<<<<<<<<<<<<
 *         elif z_x_y > 0:
 *             R.x = z_x_y
 */
    __pyx_v_R.branch = 0xC8;

    /* "slabbe/mult_cont_frac.pyx":3151
 *             R.w = P.w
 *             R.branch = 100
 *         elif z_x_y > P.x:             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = z_x_y
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3159
 *             R.w = P.v + P.w
 *             R.branch = 200
 *         elif z_x_y > 0:             # <<<<<<<<<<<<<<
 *             R.x = z_x_y
 *             R.y = P.x
 */
  __pyx_t_1 = ((__pyx_v_z_x_y > 0.0) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3160
 *             R.branch = 200
 *         elif z_x_y > 0:
 *             R.x = z_x_y             # <<<<<<<<<<<<<<
 *             R.y = P.x
 *             R.z = P.y
 */
    __pyx_v_R.x = __pyx_v_z_x_y;

    /* "slabbe/mult_cont_frac.pyx":3161
 *         elif z_x_y > 0:
 *             R.x = z_x_y
 *             R.y = P.x             # <<<<<<<<<<<<<<
 *             R.z = P.y
 *             R.u = P.w
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_R.y = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3162
 *             R.x = z_x_y
 *             R.y = P.x
 *             R.z = P.y             # <<<<<<<<<<<<<<
 *             R.u = P.w
 *             R.v = P.u + P.w
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_R.z = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3163
 *             R.y = P.x
 *             R.z = P.y
 *             R.u = P.w             # <<<<<<<<<<<<<<
 *             R.v = P.u + P.w
 *             R.w = P.v + P.w
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_R.u = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3164
 *             R.z = P.y
 *             R.u = P.w
 *             R.v = P.u + P.w             # <<<<<<<<<<<<<<
 *             R.w = P.v + P.w
 *             R.branch = 300
 */
    __pyx_v_R.v = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3165
 *             R.u = P.w
 *             R.v = P.u + P.w
 *             R.w = P.v + P.w             # <<<<<<<<<<<<<<
 *             R.branch = 300
 *         else:
 */
    __pyx_v_R.w = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3166
 *             R.v = P.u + P.w
 *             R.w = P.v + P.w
 *             R.branch = 300             # <<<<<<<<<<<<<<
 *         else:
 *             # Revert
 */
    __pyx_v_R.branch = 0x12C;

    /* "slabbe/mult_cont_frac.pyx":3159
 *             R.w = P.v + P.w
 *             R.branch = 200
 *         elif z_x_y > 0:             # <<<<<<<<<<<<<<
 *             R.x = z_x_y
 *             R.y = P.x
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3169
 *         else:
 *             # Revert
 *             R.x = (P.x + P.y - P.z)/2             # <<<<<<<<<<<<<<
 *             R.y = (P.x - P.y + P.z)/2
 *             R.z = (-P.x + P.y + P.z)/2
 */
  /*else*/ {
    __pyx_v_R.x = (((__pyx_v_P.x + __pyx_v_P.y) - __pyx_v_P.z) / 2.0);

    /* "slabbe/mult_cont_frac.pyx":3170
 *             # Revert
 *             R.x = (P.x + P.y - P.z)/2
 *             R.y = (P.x - P.y + P.z)/2             # <<<<<<<<<<<<<<
 *             R.z = (-P.x + P.y + P.z)/2
 *             R.u = P.u + P.v
 */
    __pyx_v_R.y = (((__pyx_v_P.x - __pyx_v_P.y) + __pyx_v_P.z) / 2.0);

    /* "slabbe/mult_cont_frac.pyx":3171
 *             R.x = (P.x + P.y - P.z)/2
 *             R.y = (P.x - P.y + P.z)/2
 *             R.z = (-P.x + P.y + P.z)/2             # <<<<<<<<<<<<<<
 *             R.u = P.u + P.v
 *             R.v = P.u + P.w
 */
    __pyx_v_R.z = ((((-__pyx_v_P.x) + __pyx_v_P.y) + __pyx_v_P.z) / 2.0);

    /* "slabbe/mult_cont_frac.pyx":3172
 *             R.y = (P.x - P.y + P.z)/2
 *             R.z = (-P.x + P.y + P.z)/2
 *             R.u = P.u + P.v             # <<<<<<<<<<<<<<
 *             R.v = P.u + P.w
 *             R.w = P.v + P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":3173
 *             R.z = (-P.x + P.y + P.z)/2
 *             R.u = P.u + P.v
 *             R.v = P.u + P.w             # <<<<<<<<<<<<<<
 *             R.w = P.v + P.w
 *             R.branch = 400
 */
    __pyx_v_R.v = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3174
 *             R.u = P.u + P.v
 *             R.v = P.u + P.w
 *             R.w = P.v + P.w             # <<<<<<<<<<<<<<
 *             R.branch = 400
 *         return R
 */
    __pyx_v_R.w = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3175
 *             R.v = P.u + P.w
 *             R.w = P.v + P.w
 *             R.branch = 400             # <<<<<<<<<<<<<<
 *         return R
 * 
 */
    __pyx_v_R.branch = 0x190;
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":3176
 *             R.w = P.v + P.w
 *             R.branch = 400
 *         return R             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_ARrevertMulti(MCFAlgorithm):
 */
  __pyx_r = __pyx_v_R;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3125
 * 
 * cdef class Sorted_ARrevert(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":3179
 * 
 * cdef class Sorted_ARrevertMulti(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_20Sorted_ARrevertMulti_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  int __pyx_v_m;
  double __pyx_v_z_mxy;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3196
 *         """
 *         cdef PairPoint3d R
 *         cdef int m = <int>(P.z / (P.x + P.y))             # <<<<<<<<<<<<<<
 *         cdef double z_mxy = P.z - m * (P.x + P.y)
 *         if m == 0:
 */
  __pyx_t_1 = (__pyx_v_P.x + __pyx_v_P.y);
  if (unlikely(__pyx_t_1 == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 3196, __pyx_L1_error)
  }
  __pyx_v_m = ((int)(__pyx_v_P.z / __pyx_t_1));

  /* "slabbe/mult_cont_frac.pyx":3197
 *         cdef PairPoint3d R
 *         cdef int m = <int>(P.z / (P.x + P.y))
 *         cdef double z_mxy = P.z - m * (P.x + P.y)             # <<<<<<<<<<<<<<
 *         if m == 0:
 *             # Revert
 */
  __pyx_v_z_mxy = (__pyx_v_P.z - (__pyx_v_m * (__pyx_v_P.x + __pyx_v_P.y)));

  /* "slabbe/mult_cont_frac.pyx":3198
 *         cdef int m = <int>(P.z / (P.x + P.y))
 *         cdef double z_mxy = P.z - m * (P.x + P.y)
 *         if m == 0:             # <<<<<<<<<<<<<<
 *             # Revert
 *             R.x = (P.x + P.y - P.z)/2
 */
  __pyx_t_2 = ((__pyx_v_m == 0) != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":3200
 *         if m == 0:
 *             # Revert
 *             R.x = (P.x + P.y - P.z)/2             # <<<<<<<<<<<<<<
 *             R.y = (P.x - P.y + P.z)/2
 *             R.z = (-P.x + P.y + P.z)/2
 */
    __pyx_v_R.x = (((__pyx_v_P.x + __pyx_v_P.y) - __pyx_v_P.z) / 2.0);

    /* "slabbe/mult_cont_frac.pyx":3201
 *             # Revert
 *             R.x = (P.x + P.y - P.z)/2
 *             R.y = (P.x - P.y + P.z)/2             # <<<<<<<<<<<<<<
 *             R.z = (-P.x + P.y + P.z)/2
 *             R.u = P.u + P.v
 */
    __pyx_v_R.y = (((__pyx_v_P.x - __pyx_v_P.y) + __pyx_v_P.z) / 2.0);

    /* "slabbe/mult_cont_frac.pyx":3202
 *             R.x = (P.x + P.y - P.z)/2
 *             R.y = (P.x - P.y + P.z)/2
 *             R.z = (-P.x + P.y + P.z)/2             # <<<<<<<<<<<<<<
 *             R.u = P.u + P.v
 *             R.v = P.u + P.w
 */
    __pyx_v_R.z = ((((-__pyx_v_P.x) + __pyx_v_P.y) + __pyx_v_P.z) / 2.0);

    /* "slabbe/mult_cont_frac.pyx":3203
 *             R.y = (P.x - P.y + P.z)/2
 *             R.z = (-P.x + P.y + P.z)/2
 *             R.u = P.u + P.v             # <<<<<<<<<<<<<<
 *             R.v = P.u + P.w
 *             R.w = P.v + P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":3204
 *             R.z = (-P.x + P.y + P.z)/2
 *             R.u = P.u + P.v
 *             R.v = P.u + P.w             # <<<<<<<<<<<<<<
 *             R.w = P.v + P.w
 *             R.branch = 100
 */
    __pyx_v_R.v = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3205
 *             R.u = P.u + P.v
 *             R.v = P.u + P.w
 *             R.w = P.v + P.w             # <<<<<<<<<<<<<<
 *             R.branch = 100
 *         elif z_mxy > P.y:
 */
    __pyx_v_R.w = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3206
 *             R.v = P.u + P.w
 *             R.w = P.v + P.w
 *             R.branch = 100             # <<<<<<<<<<<<<<
 *         elif z_mxy > P.y:
 *             R.x = P.x
 */
    __pyx_v_R.branch = 0x64;

    /* "slabbe/mult_cont_frac.pyx":3198
 *         cdef int m = <int>(P.z / (P.x + P.y))
 *         cdef double z_mxy = P.z - m * (P.x + P.y)
 *         if m == 0:             # <<<<<<<<<<<<<<
 *             # Revert
 *             R.x = (P.x + P.y - P.z)/2
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3207
 *             R.w = P.v + P.w
 *             R.branch = 100
 *         elif z_mxy > P.y:             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = P.y
 */
  __pyx_t_2 = ((__pyx_v_z_mxy > __pyx_v_P.y) != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":3208
 *             R.branch = 100
 *         elif z_mxy > P.y:
 *             R.x = P.x             # <<<<<<<<<<<<<<
 *             R.y = P.y
 *             R.z = z_mxy
 */
    __pyx_t_1 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_1;

    /* "slabbe/mult_cont_frac.pyx":3209
 *         elif z_mxy > P.y:
 *             R.x = P.x
 *             R.y = P.y             # <<<<<<<<<<<<<<
 *             R.z = z_mxy
 *             R.u = P.u + m*P.w
 */
    __pyx_t_1 = __pyx_v_P.y;
    __pyx_v_R.y = __pyx_t_1;

    /* "slabbe/mult_cont_frac.pyx":3210
 *             R.x = P.x
 *             R.y = P.y
 *             R.z = z_mxy             # <<<<<<<<<<<<<<
 *             R.u = P.u + m*P.w
 *             R.v = P.v + m*P.w
 */
    __pyx_v_R.z = __pyx_v_z_mxy;

    /* "slabbe/mult_cont_frac.pyx":3211
 *             R.y = P.y
 *             R.z = z_mxy
 *             R.u = P.u + m*P.w             # <<<<<<<<<<<<<<
 *             R.v = P.v + m*P.w
 *             R.w = P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + (__pyx_v_m * __pyx_v_P.w));

    /* "slabbe/mult_cont_frac.pyx":3212
 *             R.z = z_mxy
 *             R.u = P.u + m*P.w
 *             R.v = P.v + m*P.w             # <<<<<<<<<<<<<<
 *             R.w = P.w
 *             R.branch = 200
 */
    __pyx_v_R.v = (__pyx_v_P.v + (__pyx_v_m * __pyx_v_P.w));

    /* "slabbe/mult_cont_frac.pyx":3213
 *             R.u = P.u + m*P.w
 *             R.v = P.v + m*P.w
 *             R.w = P.w             # <<<<<<<<<<<<<<
 *             R.branch = 200
 *         elif z_mxy > P.x:
 */
    __pyx_t_1 = __pyx_v_P.w;
    __pyx_v_R.w = __pyx_t_1;

    /* "slabbe/mult_cont_frac.pyx":3214
 *             R.v = P.v + m*P.w
 *             R.w = P.w
 *             R.branch = 200             # <<<<<<<<<<<<<<
 *         elif z_mxy > P.x:
 *             R.x = P.x
 */
    __pyx_v_R.branch = 0xC8;

    /* "slabbe/mult_cont_frac.pyx":3207
 *             R.w = P.v + P.w
 *             R.branch = 100
 *         elif z_mxy > P.y:             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = P.y
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3215
 *             R.w = P.w
 *             R.branch = 200
 *         elif z_mxy > P.x:             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = z_mxy
 */
  __pyx_t_2 = ((__pyx_v_z_mxy > __pyx_v_P.x) != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":3216
 *             R.branch = 200
 *         elif z_mxy > P.x:
 *             R.x = P.x             # <<<<<<<<<<<<<<
 *             R.y = z_mxy
 *             R.z = P.y
 */
    __pyx_t_1 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_1;

    /* "slabbe/mult_cont_frac.pyx":3217
 *         elif z_mxy > P.x:
 *             R.x = P.x
 *             R.y = z_mxy             # <<<<<<<<<<<<<<
 *             R.z = P.y
 *             R.u = P.u + m*P.w
 */
    __pyx_v_R.y = __pyx_v_z_mxy;

    /* "slabbe/mult_cont_frac.pyx":3218
 *             R.x = P.x
 *             R.y = z_mxy
 *             R.z = P.y             # <<<<<<<<<<<<<<
 *             R.u = P.u + m*P.w
 *             R.v = P.w
 */
    __pyx_t_1 = __pyx_v_P.y;
    __pyx_v_R.z = __pyx_t_1;

    /* "slabbe/mult_cont_frac.pyx":3219
 *             R.y = z_mxy
 *             R.z = P.y
 *             R.u = P.u + m*P.w             # <<<<<<<<<<<<<<
 *             R.v = P.w
 *             R.w = P.v + m*P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + (__pyx_v_m * __pyx_v_P.w));

    /* "slabbe/mult_cont_frac.pyx":3220
 *             R.z = P.y
 *             R.u = P.u + m*P.w
 *             R.v = P.w             # <<<<<<<<<<<<<<
 *             R.w = P.v + m*P.w
 *             R.branch = 300
 */
    __pyx_t_1 = __pyx_v_P.w;
    __pyx_v_R.v = __pyx_t_1;

    /* "slabbe/mult_cont_frac.pyx":3221
 *             R.u = P.u + m*P.w
 *             R.v = P.w
 *             R.w = P.v + m*P.w             # <<<<<<<<<<<<<<
 *             R.branch = 300
 *         else:
 */
    __pyx_v_R.w = (__pyx_v_P.v + (__pyx_v_m * __pyx_v_P.w));

    /* "slabbe/mult_cont_frac.pyx":3222
 *             R.v = P.w
 *             R.w = P.v + m*P.w
 *             R.branch = 300             # <<<<<<<<<<<<<<
 *         else:
 *             R.x = z_mxy
 */
    __pyx_v_R.branch = 0x12C;

    /* "slabbe/mult_cont_frac.pyx":3215
 *             R.w = P.w
 *             R.branch = 200
 *         elif z_mxy > P.x:             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = z_mxy
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3224
 *             R.branch = 300
 *         else:
 *             R.x = z_mxy             # <<<<<<<<<<<<<<
 *             R.y = P.x
 *             R.z = P.y
 */
  /*else*/ {
    __pyx_v_R.x = __pyx_v_z_mxy;

    /* "slabbe/mult_cont_frac.pyx":3225
 *         else:
 *             R.x = z_mxy
 *             R.y = P.x             # <<<<<<<<<<<<<<
 *             R.z = P.y
 *             R.u = P.w
 */
    __pyx_t_1 = __pyx_v_P.x;
    __pyx_v_R.y = __pyx_t_1;

    /* "slabbe/mult_cont_frac.pyx":3226
 *             R.x = z_mxy
 *             R.y = P.x
 *             R.z = P.y             # <<<<<<<<<<<<<<
 *             R.u = P.w
 *             R.v = P.u + m*P.w
 */
    __pyx_t_1 = __pyx_v_P.y;
    __pyx_v_R.z = __pyx_t_1;

    /* "slabbe/mult_cont_frac.pyx":3227
 *             R.y = P.x
 *             R.z = P.y
 *             R.u = P.w             # <<<<<<<<<<<<<<
 *             R.v = P.u + m*P.w
 *             R.w = P.v + m*P.w
 */
    __pyx_t_1 = __pyx_v_P.w;
    __pyx_v_R.u = __pyx_t_1;

    /* "slabbe/mult_cont_frac.pyx":3228
 *             R.z = P.y
 *             R.u = P.w
 *             R.v = P.u + m*P.w             # <<<<<<<<<<<<<<
 *             R.w = P.v + m*P.w
 *             R.branch = 400
 */
    __pyx_v_R.v = (__pyx_v_P.u + (__pyx_v_m * __pyx_v_P.w));

    /* "slabbe/mult_cont_frac.pyx":3229
 *             R.u = P.w
 *             R.v = P.u + m*P.w
 *             R.w = P.v + m*P.w             # <<<<<<<<<<<<<<
 *             R.branch = 400
 *         return R
 */
    __pyx_v_R.w = (__pyx_v_P.v + (__pyx_v_m * __pyx_v_P.w));

    /* "slabbe/mult_cont_frac.pyx":3230
 *             R.v = P.u + m*P.w
 *             R.w = P.v + m*P.w
 *             R.branch = 400             # <<<<<<<<<<<<<<
 *         return R
 * 
 */
    __pyx_v_R.branch = 0x190;
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":3231
 *             R.w = P.v + m*P.w
 *             R.branch = 400
 *         return R             # <<<<<<<<<<<<<<
 * 
 * cdef class Sorted_ARMonteil(MCFAlgorithm):
 */
  __pyx_r = __pyx_v_R;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3179
 * 
 * cdef class Sorted_ARrevertMulti(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.Sorted_ARrevertMulti.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":3234
 * 
 * cdef class Sorted_ARMonteil(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_16Sorted_ARMonteil_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARMonteil *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  double __pyx_t_2;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3253
 * 
 *         # Apply the algo
 *         if P.z > P.x + P.y:             # <<<<<<<<<<<<<<
 *             # Arnoux-Rauzy
 *             R.z = P.z - P.y - P.x
 */
  __pyx_t_1 = ((__pyx_v_P.z > (__pyx_v_P.x + __pyx_v_P.y)) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3255
 *         if P.z > P.x + P.y:
 *             # Arnoux-Rauzy
 *             R.z = P.z - P.y - P.x             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = P.y
 */
    __pyx_v_R.z = ((__pyx_v_P.z - __pyx_v_P.y) - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":3256
 *             # Arnoux-Rauzy
 *             R.z = P.z - P.y - P.x
 *             R.x = P.x             # <<<<<<<<<<<<<<
 *             R.y = P.y
 *             R.u = P.u + P.w
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3257
 *             R.z = P.z - P.y - P.x
 *             R.x = P.x
 *             R.y = P.y             # <<<<<<<<<<<<<<
 *             R.u = P.u + P.w
 *             R.v = P.v + P.w
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_R.y = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3258
 *             R.x = P.x
 *             R.y = P.y
 *             R.u = P.u + P.w             # <<<<<<<<<<<<<<
 *             R.v = P.v + P.w
 *             R.w = P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3259
 *             R.y = P.y
 *             R.u = P.u + P.w
 *             R.v = P.v + P.w             # <<<<<<<<<<<<<<
 *             R.w = P.w
 *             R.branch = 100
 */
    __pyx_v_R.v = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3260
 *             R.u = P.u + P.w
 *             R.v = P.v + P.w
 *             R.w = P.w             # <<<<<<<<<<<<<<
 *             R.branch = 100
 *         else:
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_R.w = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3261
 *             R.v = P.v + P.w
 *             R.w = P.w
 *             R.branch = 100             # <<<<<<<<<<<<<<
 *         else:
 *             # Monteil
 */
    __pyx_v_R.branch = 0x64;

    /* "slabbe/mult_cont_frac.pyx":3253
 * 
 *         # Apply the algo
 *         if P.z > P.x + P.y:             # <<<<<<<<<<<<<<
 *             # Arnoux-Rauzy
 *             R.z = P.z - P.y - P.x
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3264
 *         else:
 *             # Monteil
 *             R.x = P.x + P.y - P.z             # <<<<<<<<<<<<<<
 *             R.y = -P.x + P.z
 *             R.z = -P.y + P.z
 */
  /*else*/ {
    __pyx_v_R.x = ((__pyx_v_P.x + __pyx_v_P.y) - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":3265
 *             # Monteil
 *             R.x = P.x + P.y - P.z
 *             R.y = -P.x + P.z             # <<<<<<<<<<<<<<
 *             R.z = -P.y + P.z
 *             R.u = P.u + P.v + P.w
 */
    __pyx_v_R.y = ((-__pyx_v_P.x) + __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":3266
 *             R.x = P.x + P.y - P.z
 *             R.y = -P.x + P.z
 *             R.z = -P.y + P.z             # <<<<<<<<<<<<<<
 *             R.u = P.u + P.v + P.w
 *             R.v = P.v + P.w
 */
    __pyx_v_R.z = ((-__pyx_v_P.y) + __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":3267
 *             R.y = -P.x + P.z
 *             R.z = -P.y + P.z
 *             R.u = P.u + P.v + P.w             # <<<<<<<<<<<<<<
 *             R.v = P.v + P.w
 *             R.w = P.u + P.w
 */
    __pyx_v_R.u = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3268
 *             R.z = -P.y + P.z
 *             R.u = P.u + P.v + P.w
 *             R.v = P.v + P.w             # <<<<<<<<<<<<<<
 *             R.w = P.u + P.w
 *             R.branch = 200
 */
    __pyx_v_R.v = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3269
 *             R.u = P.u + P.v + P.w
 *             R.v = P.v + P.w
 *             R.w = P.u + P.w             # <<<<<<<<<<<<<<
 *             R.branch = 200
 * 
 */
    __pyx_v_R.w = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3270
 *             R.v = P.v + P.w
 *             R.w = P.u + P.w
 *             R.branch = 200             # <<<<<<<<<<<<<<
 * 
 *         return Sort(R)
 */
    __pyx_v_R.branch = 0xC8;
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":3272
 *             R.branch = 200
 * 
 *         return Sort(R)             # <<<<<<<<<<<<<<
 * cdef class Sorted_Delaunay(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_R);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3234
 * 
 * cdef class Sorted_ARMonteil(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":3274
 *         return Sort(R)
 * cdef class Sorted_Delaunay(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         Donn par Xavier Provenal (inspir de en fait) le 3 fvrier 2014.
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_15Sorted_Delaunay_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Delaunay *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  double __pyx_t_2;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3294
 *         cdef PairPoint3d R
 *         # Apply the algo
 *         if P.z > P.x + P.y:             # <<<<<<<<<<<<<<
 *             # Genre de semi revert
 *             R.x = P.x
 */
  __pyx_t_1 = ((__pyx_v_P.z > (__pyx_v_P.x + __pyx_v_P.y)) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3296
 *         if P.z > P.x + P.y:
 *             # Genre de semi revert
 *             R.x = P.x             # <<<<<<<<<<<<<<
 *             R.y = P.y - P.x
 *             R.z = P.x - P.y + P.z
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3297
 *             # Genre de semi revert
 *             R.x = P.x
 *             R.y = P.y - P.x             # <<<<<<<<<<<<<<
 *             R.z = P.x - P.y + P.z
 *             R.u = P.u + P.v
 */
    __pyx_v_R.y = (__pyx_v_P.y - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":3298
 *             R.x = P.x
 *             R.y = P.y - P.x
 *             R.z = P.x - P.y + P.z             # <<<<<<<<<<<<<<
 *             R.u = P.u + P.v
 *             R.v = P.v + P.w
 */
    __pyx_v_R.z = ((__pyx_v_P.x - __pyx_v_P.y) + __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":3299
 *             R.y = P.y - P.x
 *             R.z = P.x - P.y + P.z
 *             R.u = P.u + P.v             # <<<<<<<<<<<<<<
 *             R.v = P.v + P.w
 *             R.w = P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":3300
 *             R.z = P.x - P.y + P.z
 *             R.u = P.u + P.v
 *             R.v = P.v + P.w             # <<<<<<<<<<<<<<
 *             R.w = P.w
 *             R.branch = 200
 */
    __pyx_v_R.v = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3301
 *             R.u = P.u + P.v
 *             R.v = P.v + P.w
 *             R.w = P.w             # <<<<<<<<<<<<<<
 *             R.branch = 200
 *             return Sort(R)
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_R.w = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3302
 *             R.v = P.v + P.w
 *             R.w = P.w
 *             R.branch = 200             # <<<<<<<<<<<<<<
 *             return Sort(R)
 *         else:
 */
    __pyx_v_R.branch = 0xC8;

    /* "slabbe/mult_cont_frac.pyx":3303
 *             R.w = P.w
 *             R.branch = 200
 *             return Sort(R)             # <<<<<<<<<<<<<<
 *         else:
 *             return _Sorted_Meester(P)
 */
    __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_R);
    goto __pyx_L0;

    /* "slabbe/mult_cont_frac.pyx":3294
 *         cdef PairPoint3d R
 *         # Apply the algo
 *         if P.z > P.x + P.y:             # <<<<<<<<<<<<<<
 *             # Genre de semi revert
 *             R.x = P.x
 */
  }

  /* "slabbe/mult_cont_frac.pyx":3305
 *             return Sort(R)
 *         else:
 *             return _Sorted_Meester(P)             # <<<<<<<<<<<<<<
 * cdef class JacobiPerron(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 */
  /*else*/ {
    __pyx_r = __pyx_f_6slabbe_14mult_cont_frac__Sorted_Meester(__pyx_v_P);
    goto __pyx_L0;
  }

  /* "slabbe/mult_cont_frac.pyx":3274
 *         return Sort(R)
 * cdef class Sorted_Delaunay(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         Donn par Xavier Provenal (inspir de en fait) le 3 fvrier 2014.
 */

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

/* "slabbe/mult_cont_frac.pyx":3307
 *             return _Sorted_Meester(P)
 * cdef class JacobiPerron(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_12JacobiPerron_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerron *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  int __pyx_v_m;
  int __pyx_v_n;
  double __pyx_v_r;
  double __pyx_v_s;
  double __pyx_v_t;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3327
 *         cdef double r,s,t           # temporary variables
 * 
 *         R.branch = 100             # <<<<<<<<<<<<<<
 * 
 *         # Apply the algo
 */
  __pyx_v_R.branch = 0x64;

  /* "slabbe/mult_cont_frac.pyx":3330
 * 
 *         # Apply the algo
 *         m = int(P.z / P.x)             # <<<<<<<<<<<<<<
 *         n = int(P.y / P.x)
 *         t = P.z - m*P.x
 */
  if (unlikely(__pyx_v_P.x == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 3330, __pyx_L1_error)
  }
  __pyx_v_m = ((int)(__pyx_v_P.z / __pyx_v_P.x));

  /* "slabbe/mult_cont_frac.pyx":3331
 *         # Apply the algo
 *         m = int(P.z / P.x)
 *         n = int(P.y / P.x)             # <<<<<<<<<<<<<<
 *         t = P.z - m*P.x
 *         s = P.y - n*P.x
 */
  if (unlikely(__pyx_v_P.x == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 3331, __pyx_L1_error)
  }
  __pyx_v_n = ((int)(__pyx_v_P.y / __pyx_v_P.x));

  /* "slabbe/mult_cont_frac.pyx":3332
 *         m = int(P.z / P.x)
 *         n = int(P.y / P.x)
 *         t = P.z - m*P.x             # <<<<<<<<<<<<<<
 *         s = P.y - n*P.x
 *         r = P.x
 */
  __pyx_v_t = (__pyx_v_P.z - (__pyx_v_m * __pyx_v_P.x));

  /* "slabbe/mult_cont_frac.pyx":3333
 *         n = int(P.y / P.x)
 *         t = P.z - m*P.x
 *         s = P.y - n*P.x             # <<<<<<<<<<<<<<
 *         r = P.x
 * 
 */
  __pyx_v_s = (__pyx_v_P.y - (__pyx_v_n * __pyx_v_P.x));

  /* "slabbe/mult_cont_frac.pyx":3334
 *         t = P.z - m*P.x
 *         s = P.y - n*P.x
 *         r = P.x             # <<<<<<<<<<<<<<
 * 
 *         R.z = r
 */
  __pyx_t_1 = __pyx_v_P.x;
  __pyx_v_r = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3336
 *         r = P.x
 * 
 *         R.z = r             # <<<<<<<<<<<<<<
 *         R.y = t
 *         R.x = s
 */
  __pyx_v_R.z = __pyx_v_r;

  /* "slabbe/mult_cont_frac.pyx":3337
 * 
 *         R.z = r
 *         R.y = t             # <<<<<<<<<<<<<<
 *         R.x = s
 * 
 */
  __pyx_v_R.y = __pyx_v_t;

  /* "slabbe/mult_cont_frac.pyx":3338
 *         R.z = r
 *         R.y = t
 *         R.x = s             # <<<<<<<<<<<<<<
 * 
 *         t = P.w
 */
  __pyx_v_R.x = __pyx_v_s;

  /* "slabbe/mult_cont_frac.pyx":3340
 *         R.x = s
 * 
 *         t = P.w             # <<<<<<<<<<<<<<
 *         s = P.v
 *         r = m*P.w + n*P.v + P.u
 */
  __pyx_t_1 = __pyx_v_P.w;
  __pyx_v_t = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3341
 * 
 *         t = P.w
 *         s = P.v             # <<<<<<<<<<<<<<
 *         r = m*P.w + n*P.v + P.u
 * 
 */
  __pyx_t_1 = __pyx_v_P.v;
  __pyx_v_s = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3342
 *         t = P.w
 *         s = P.v
 *         r = m*P.w + n*P.v + P.u             # <<<<<<<<<<<<<<
 * 
 *         R.w = r
 */
  __pyx_v_r = (((__pyx_v_m * __pyx_v_P.w) + (__pyx_v_n * __pyx_v_P.v)) + __pyx_v_P.u);

  /* "slabbe/mult_cont_frac.pyx":3344
 *         r = m*P.w + n*P.v + P.u
 * 
 *         R.w = r             # <<<<<<<<<<<<<<
 *         R.v = t
 *         R.u = s
 */
  __pyx_v_R.w = __pyx_v_r;

  /* "slabbe/mult_cont_frac.pyx":3345
 * 
 *         R.w = r
 *         R.v = t             # <<<<<<<<<<<<<<
 *         R.u = s
 * 
 */
  __pyx_v_R.v = __pyx_v_t;

  /* "slabbe/mult_cont_frac.pyx":3346
 *         R.w = r
 *         R.v = t
 *         R.u = s             # <<<<<<<<<<<<<<
 * 
 *         return R
 */
  __pyx_v_R.u = __pyx_v_s;

  /* "slabbe/mult_cont_frac.pyx":3348
 *         R.u = s
 * 
 *         return R             # <<<<<<<<<<<<<<
 * cdef class JacobiPerronAdditif(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 */
  __pyx_r = __pyx_v_R;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3307
 *             return _Sorted_Meester(P)
 * cdef class JacobiPerron(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("slabbe.mult_cont_frac.JacobiPerron.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":3350
 *         return R
 * cdef class JacobiPerronAdditif(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_19JacobiPerronAdditif_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditif *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  double __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3368
 *         cdef PairPoint3d R
 *         # Apply the algo
 *         if P.x < P.y:             # <<<<<<<<<<<<<<
 *             R.branch = 100
 *             R.x = P.x
 */
  __pyx_t_1 = ((__pyx_v_P.x < __pyx_v_P.y) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3369
 *         # Apply the algo
 *         if P.x < P.y:
 *             R.branch = 100             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = P.y - P.x
 */
    __pyx_v_R.branch = 0x64;

    /* "slabbe/mult_cont_frac.pyx":3370
 *         if P.x < P.y:
 *             R.branch = 100
 *             R.x = P.x             # <<<<<<<<<<<<<<
 *             R.y = P.y - P.x
 *             R.z = P.z
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3371
 *             R.branch = 100
 *             R.x = P.x
 *             R.y = P.y - P.x             # <<<<<<<<<<<<<<
 *             R.z = P.z
 *             R.u = P.u + P.v
 */
    __pyx_v_R.y = (__pyx_v_P.y - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":3372
 *             R.x = P.x
 *             R.y = P.y - P.x
 *             R.z = P.z             # <<<<<<<<<<<<<<
 *             R.u = P.u + P.v
 *             R.v = P.v
 */
    __pyx_t_2 = __pyx_v_P.z;
    __pyx_v_R.z = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3373
 *             R.y = P.y - P.x
 *             R.z = P.z
 *             R.u = P.u + P.v             # <<<<<<<<<<<<<<
 *             R.v = P.v
 *             R.w = P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":3374
 *             R.z = P.z
 *             R.u = P.u + P.v
 *             R.v = P.v             # <<<<<<<<<<<<<<
 *             R.w = P.w
 *         elif P.x < P.z:
 */
    __pyx_t_2 = __pyx_v_P.v;
    __pyx_v_R.v = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3375
 *             R.u = P.u + P.v
 *             R.v = P.v
 *             R.w = P.w             # <<<<<<<<<<<<<<
 *         elif P.x < P.z:
 *             R.branch = 200
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_R.w = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3368
 *         cdef PairPoint3d R
 *         # Apply the algo
 *         if P.x < P.y:             # <<<<<<<<<<<<<<
 *             R.branch = 100
 *             R.x = P.x
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3376
 *             R.v = P.v
 *             R.w = P.w
 *         elif P.x < P.z:             # <<<<<<<<<<<<<<
 *             R.branch = 200
 *             R.x = P.x
 */
  __pyx_t_1 = ((__pyx_v_P.x < __pyx_v_P.z) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3377
 *             R.w = P.w
 *         elif P.x < P.z:
 *             R.branch = 200             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = P.y
 */
    __pyx_v_R.branch = 0xC8;

    /* "slabbe/mult_cont_frac.pyx":3378
 *         elif P.x < P.z:
 *             R.branch = 200
 *             R.x = P.x             # <<<<<<<<<<<<<<
 *             R.y = P.y
 *             R.z = P.z - P.x
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3379
 *             R.branch = 200
 *             R.x = P.x
 *             R.y = P.y             # <<<<<<<<<<<<<<
 *             R.z = P.z - P.x
 *             R.u = P.u + P.w
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_R.y = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3380
 *             R.x = P.x
 *             R.y = P.y
 *             R.z = P.z - P.x             # <<<<<<<<<<<<<<
 *             R.u = P.u + P.w
 *             R.v = P.v
 */
    __pyx_v_R.z = (__pyx_v_P.z - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":3381
 *             R.y = P.y
 *             R.z = P.z - P.x
 *             R.u = P.u + P.w             # <<<<<<<<<<<<<<
 *             R.v = P.v
 *             R.w = P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3382
 *             R.z = P.z - P.x
 *             R.u = P.u + P.w
 *             R.v = P.v             # <<<<<<<<<<<<<<
 *             R.w = P.w
 *         elif P.x > P.y and P.x > P.z:
 */
    __pyx_t_2 = __pyx_v_P.v;
    __pyx_v_R.v = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3383
 *             R.u = P.u + P.w
 *             R.v = P.v
 *             R.w = P.w             # <<<<<<<<<<<<<<
 *         elif P.x > P.y and P.x > P.z:
 *             R.branch = 300
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_R.w = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3376
 *             R.v = P.v
 *             R.w = P.w
 *         elif P.x < P.z:             # <<<<<<<<<<<<<<
 *             R.branch = 200
 *             R.x = P.x
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3384
 *             R.v = P.v
 *             R.w = P.w
 *         elif P.x > P.y and P.x > P.z:             # <<<<<<<<<<<<<<
 *             R.branch = 300
 *             R.x = P.y
 */
  __pyx_t_3 = ((__pyx_v_P.x > __pyx_v_P.y) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_P.x > __pyx_v_P.z) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3385
 *             R.w = P.w
 *         elif P.x > P.y and P.x > P.z:
 *             R.branch = 300             # <<<<<<<<<<<<<<
 *             R.x = P.y
 *             R.y = P.z
 */
    __pyx_v_R.branch = 0x12C;

    /* "slabbe/mult_cont_frac.pyx":3386
 *         elif P.x > P.y and P.x > P.z:
 *             R.branch = 300
 *             R.x = P.y             # <<<<<<<<<<<<<<
 *             R.y = P.z
 *             R.z = P.x
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_R.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3387
 *             R.branch = 300
 *             R.x = P.y
 *             R.y = P.z             # <<<<<<<<<<<<<<
 *             R.z = P.x
 *             R.u = P.v
 */
    __pyx_t_2 = __pyx_v_P.z;
    __pyx_v_R.y = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3388
 *             R.x = P.y
 *             R.y = P.z
 *             R.z = P.x             # <<<<<<<<<<<<<<
 *             R.u = P.v
 *             R.v = P.w
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_R.z = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3389
 *             R.y = P.z
 *             R.z = P.x
 *             R.u = P.v             # <<<<<<<<<<<<<<
 *             R.v = P.w
 *             R.w = P.u
 */
    __pyx_t_2 = __pyx_v_P.v;
    __pyx_v_R.u = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3390
 *             R.z = P.x
 *             R.u = P.v
 *             R.v = P.w             # <<<<<<<<<<<<<<
 *             R.w = P.u
 *         else:
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_R.v = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3391
 *             R.u = P.v
 *             R.v = P.w
 *             R.w = P.u             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("jacobi not defined for (x,y,z)=(%s,%s,%s)"%(P.x,P.y,P.z))
 */
    __pyx_t_2 = __pyx_v_P.u;
    __pyx_v_R.w = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3384
 *             R.v = P.v
 *             R.w = P.w
 *         elif P.x > P.y and P.x > P.z:             # <<<<<<<<<<<<<<
 *             R.branch = 300
 *             R.x = P.y
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3393
 *             R.w = P.u
 *         else:
 *             raise ValueError("jacobi not defined for (x,y,z)=(%s,%s,%s)"%(P.x,P.y,P.z))             # <<<<<<<<<<<<<<
 *         return R
 * cdef class JacobiPerronAdditifv2(MCFAlgorithm):
 */
  /*else*/ {
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyFloat_FromDouble(__pyx_v_P.z); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_jacobi_not_defined_for_x_y_z_s_s, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 3393, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":3394
 *         else:
 *             raise ValueError("jacobi not defined for (x,y,z)=(%s,%s,%s)"%(P.x,P.y,P.z))
 *         return R             # <<<<<<<<<<<<<<
 * cdef class JacobiPerronAdditifv2(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:
 */
  __pyx_r = __pyx_v_R;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3350
 *         return R
 * cdef class JacobiPerronAdditif(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.JacobiPerronAdditif.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":3396
 *         return R
 * cdef class JacobiPerronAdditifv2(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_21JacobiPerronAdditifv2_call(CYTHON_UNUSED struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 *__pyx_v_self, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  double __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("call", 0);

  /* "slabbe/mult_cont_frac.pyx":3414
 *         cdef PairPoint3d R
 *         # Apply the algo
 *         if P.x < P.y:             # <<<<<<<<<<<<<<
 *             R.branch = 100
 *             R.x = P.x
 */
  __pyx_t_1 = ((__pyx_v_P.x < __pyx_v_P.y) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3415
 *         # Apply the algo
 *         if P.x < P.y:
 *             R.branch = 100             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = P.y - P.x
 */
    __pyx_v_R.branch = 0x64;

    /* "slabbe/mult_cont_frac.pyx":3416
 *         if P.x < P.y:
 *             R.branch = 100
 *             R.x = P.x             # <<<<<<<<<<<<<<
 *             R.y = P.y - P.x
 *             R.z = P.z - P.x
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3417
 *             R.branch = 100
 *             R.x = P.x
 *             R.y = P.y - P.x             # <<<<<<<<<<<<<<
 *             R.z = P.z - P.x
 *             R.u = P.u + P.v + P.w
 */
    __pyx_v_R.y = (__pyx_v_P.y - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":3418
 *             R.x = P.x
 *             R.y = P.y - P.x
 *             R.z = P.z - P.x             # <<<<<<<<<<<<<<
 *             R.u = P.u + P.v + P.w
 *             R.v = P.v
 */
    __pyx_v_R.z = (__pyx_v_P.z - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":3419
 *             R.y = P.y - P.x
 *             R.z = P.z - P.x
 *             R.u = P.u + P.v + P.w             # <<<<<<<<<<<<<<
 *             R.v = P.v
 *             R.w = P.w
 */
    __pyx_v_R.u = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3420
 *             R.z = P.z - P.x
 *             R.u = P.u + P.v + P.w
 *             R.v = P.v             # <<<<<<<<<<<<<<
 *             R.w = P.w
 *         elif P.x < P.z:
 */
    __pyx_t_2 = __pyx_v_P.v;
    __pyx_v_R.v = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3421
 *             R.u = P.u + P.v + P.w
 *             R.v = P.v
 *             R.w = P.w             # <<<<<<<<<<<<<<
 *         elif P.x < P.z:
 *             R.branch = 200
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_R.w = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3414
 *         cdef PairPoint3d R
 *         # Apply the algo
 *         if P.x < P.y:             # <<<<<<<<<<<<<<
 *             R.branch = 100
 *             R.x = P.x
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3422
 *             R.v = P.v
 *             R.w = P.w
 *         elif P.x < P.z:             # <<<<<<<<<<<<<<
 *             R.branch = 200
 *             R.x = P.x
 */
  __pyx_t_1 = ((__pyx_v_P.x < __pyx_v_P.z) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3423
 *             R.w = P.w
 *         elif P.x < P.z:
 *             R.branch = 200             # <<<<<<<<<<<<<<
 *             R.x = P.x
 *             R.y = P.y
 */
    __pyx_v_R.branch = 0xC8;

    /* "slabbe/mult_cont_frac.pyx":3424
 *         elif P.x < P.z:
 *             R.branch = 200
 *             R.x = P.x             # <<<<<<<<<<<<<<
 *             R.y = P.y
 *             R.z = P.z - P.x
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3425
 *             R.branch = 200
 *             R.x = P.x
 *             R.y = P.y             # <<<<<<<<<<<<<<
 *             R.z = P.z - P.x
 *             R.u = P.u + P.w
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_R.y = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3426
 *             R.x = P.x
 *             R.y = P.y
 *             R.z = P.z - P.x             # <<<<<<<<<<<<<<
 *             R.u = P.u + P.w
 *             R.v = P.v
 */
    __pyx_v_R.z = (__pyx_v_P.z - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":3427
 *             R.y = P.y
 *             R.z = P.z - P.x
 *             R.u = P.u + P.w             # <<<<<<<<<<<<<<
 *             R.v = P.v
 *             R.w = P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3428
 *             R.z = P.z - P.x
 *             R.u = P.u + P.w
 *             R.v = P.v             # <<<<<<<<<<<<<<
 *             R.w = P.w
 *         elif P.x > P.y and P.x > P.z:
 */
    __pyx_t_2 = __pyx_v_P.v;
    __pyx_v_R.v = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3429
 *             R.u = P.u + P.w
 *             R.v = P.v
 *             R.w = P.w             # <<<<<<<<<<<<<<
 *         elif P.x > P.y and P.x > P.z:
 *             R.branch = 300
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_R.w = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3422
 *             R.v = P.v
 *             R.w = P.w
 *         elif P.x < P.z:             # <<<<<<<<<<<<<<
 *             R.branch = 200
 *             R.x = P.x
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3430
 *             R.v = P.v
 *             R.w = P.w
 *         elif P.x > P.y and P.x > P.z:             # <<<<<<<<<<<<<<
 *             R.branch = 300
 *             R.x = P.y
 */
  __pyx_t_3 = ((__pyx_v_P.x > __pyx_v_P.y) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_P.x > __pyx_v_P.z) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3431
 *             R.w = P.w
 *         elif P.x > P.y and P.x > P.z:
 *             R.branch = 300             # <<<<<<<<<<<<<<
 *             R.x = P.y
 *             R.y = P.z
 */
    __pyx_v_R.branch = 0x12C;

    /* "slabbe/mult_cont_frac.pyx":3432
 *         elif P.x > P.y and P.x > P.z:
 *             R.branch = 300
 *             R.x = P.y             # <<<<<<<<<<<<<<
 *             R.y = P.z
 *             R.z = P.x
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_R.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3433
 *             R.branch = 300
 *             R.x = P.y
 *             R.y = P.z             # <<<<<<<<<<<<<<
 *             R.z = P.x
 *             R.u = P.v
 */
    __pyx_t_2 = __pyx_v_P.z;
    __pyx_v_R.y = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3434
 *             R.x = P.y
 *             R.y = P.z
 *             R.z = P.x             # <<<<<<<<<<<<<<
 *             R.u = P.v
 *             R.v = P.w
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_R.z = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3435
 *             R.y = P.z
 *             R.z = P.x
 *             R.u = P.v             # <<<<<<<<<<<<<<
 *             R.v = P.w
 *             R.w = P.u
 */
    __pyx_t_2 = __pyx_v_P.v;
    __pyx_v_R.u = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3436
 *             R.z = P.x
 *             R.u = P.v
 *             R.v = P.w             # <<<<<<<<<<<<<<
 *             R.w = P.u
 *         else:
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_R.v = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3437
 *             R.u = P.v
 *             R.v = P.w
 *             R.w = P.u             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("jacobi not defined for (x,y,z)=(%s,%s,%s)"%(P.x,P.y,P.z))
 */
    __pyx_t_2 = __pyx_v_P.u;
    __pyx_v_R.w = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3430
 *             R.v = P.v
 *             R.w = P.w
 *         elif P.x > P.y and P.x > P.z:             # <<<<<<<<<<<<<<
 *             R.branch = 300
 *             R.x = P.y
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3439
 *             R.w = P.u
 *         else:
 *             raise ValueError("jacobi not defined for (x,y,z)=(%s,%s,%s)"%(P.x,P.y,P.z))             # <<<<<<<<<<<<<<
 * 
 *         return R
 */
  /*else*/ {
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_P.x); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_P.y); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyFloat_FromDouble(__pyx_v_P.z); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_jacobi_not_defined_for_x_y_z_s_s, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __PYX_ERR(0, 3439, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":3441
 *             raise ValueError("jacobi not defined for (x,y,z)=(%s,%s,%s)"%(P.x,P.y,P.z))
 * 
 *         return R             # <<<<<<<<<<<<<<
 * 
 * cdef inline PairPoint3d _Poincare(PairPoint3d P) except *:
 */
  __pyx_r = __pyx_v_R;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3396
 *         return R
 * cdef class JacobiPerronAdditifv2(MCFAlgorithm):
 *     cdef PairPoint3d call(self, PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *         r"""
 *         EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("slabbe.mult_cont_frac.JacobiPerronAdditifv2.call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":3443
 *         return R
 * 
 * cdef inline PairPoint3d _Poincare(PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac__Poincare(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  double __pyx_t_3;
  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;
  __Pyx_RefNannySetupContext("_Poincare", 0);

  /* "slabbe/mult_cont_frac.pyx":3449
 *     """
 *     cdef PairPoint3d R
 *     if P.x <= P.y <= P.z:             # <<<<<<<<<<<<<<
 *         R.x = P.x
 *         R.y = P.y - P.x
 */
  __pyx_t_1 = (__pyx_v_P.x <= __pyx_v_P.y);
  if (__pyx_t_1) {
    __pyx_t_1 = (__pyx_v_P.y <= __pyx_v_P.z);
  }
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":3450
 *     cdef PairPoint3d R
 *     if P.x <= P.y <= P.z:
 *         R.x = P.x             # <<<<<<<<<<<<<<
 *         R.y = P.y - P.x
 *         R.z = P.z - P.y
 */
    __pyx_t_3 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3451
 *     if P.x <= P.y <= P.z:
 *         R.x = P.x
 *         R.y = P.y - P.x             # <<<<<<<<<<<<<<
 *         R.z = P.z - P.y
 *         R.u = P.u + P.v + P.w
 */
    __pyx_v_R.y = (__pyx_v_P.y - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":3452
 *         R.x = P.x
 *         R.y = P.y - P.x
 *         R.z = P.z - P.y             # <<<<<<<<<<<<<<
 *         R.u = P.u + P.v + P.w
 *         R.v = P.v + P.w
 */
    __pyx_v_R.z = (__pyx_v_P.z - __pyx_v_P.y);

    /* "slabbe/mult_cont_frac.pyx":3453
 *         R.y = P.y - P.x
 *         R.z = P.z - P.y
 *         R.u = P.u + P.v + P.w             # <<<<<<<<<<<<<<
 *         R.v = P.v + P.w
 *         R.w = P.w
 */
    __pyx_v_R.u = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3454
 *         R.z = P.z - P.y
 *         R.u = P.u + P.v + P.w
 *         R.v = P.v + P.w             # <<<<<<<<<<<<<<
 *         R.w = P.w
 *         R.branch = 123
 */
    __pyx_v_R.v = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3455
 *         R.u = P.u + P.v + P.w
 *         R.v = P.v + P.w
 *         R.w = P.w             # <<<<<<<<<<<<<<
 *         R.branch = 123
 *     elif P.x <= P.z <= P.y:
 */
    __pyx_t_3 = __pyx_v_P.w;
    __pyx_v_R.w = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3456
 *         R.v = P.v + P.w
 *         R.w = P.w
 *         R.branch = 123             # <<<<<<<<<<<<<<
 *     elif P.x <= P.z <= P.y:
 *         R.x = P.x
 */
    __pyx_v_R.branch = 0x7B;

    /* "slabbe/mult_cont_frac.pyx":3449
 *     """
 *     cdef PairPoint3d R
 *     if P.x <= P.y <= P.z:             # <<<<<<<<<<<<<<
 *         R.x = P.x
 *         R.y = P.y - P.x
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3457
 *         R.w = P.w
 *         R.branch = 123
 *     elif P.x <= P.z <= P.y:             # <<<<<<<<<<<<<<
 *         R.x = P.x
 *         R.y = P.y - P.z
 */
  __pyx_t_2 = (__pyx_v_P.x <= __pyx_v_P.z);
  if (__pyx_t_2) {
    __pyx_t_2 = (__pyx_v_P.z <= __pyx_v_P.y);
  }
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3458
 *         R.branch = 123
 *     elif P.x <= P.z <= P.y:
 *         R.x = P.x             # <<<<<<<<<<<<<<
 *         R.y = P.y - P.z
 *         R.z = P.z - P.x
 */
    __pyx_t_3 = __pyx_v_P.x;
    __pyx_v_R.x = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3459
 *     elif P.x <= P.z <= P.y:
 *         R.x = P.x
 *         R.y = P.y - P.z             # <<<<<<<<<<<<<<
 *         R.z = P.z - P.x
 *         R.u = P.u + P.v + P.w
 */
    __pyx_v_R.y = (__pyx_v_P.y - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":3460
 *         R.x = P.x
 *         R.y = P.y - P.z
 *         R.z = P.z - P.x             # <<<<<<<<<<<<<<
 *         R.u = P.u + P.v + P.w
 *         R.v = P.v
 */
    __pyx_v_R.z = (__pyx_v_P.z - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":3461
 *         R.y = P.y - P.z
 *         R.z = P.z - P.x
 *         R.u = P.u + P.v + P.w             # <<<<<<<<<<<<<<
 *         R.v = P.v
 *         R.w = P.v + P.w
 */
    __pyx_v_R.u = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3462
 *         R.z = P.z - P.x
 *         R.u = P.u + P.v + P.w
 *         R.v = P.v             # <<<<<<<<<<<<<<
 *         R.w = P.v + P.w
 *         R.branch = 132
 */
    __pyx_t_3 = __pyx_v_P.v;
    __pyx_v_R.v = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3463
 *         R.u = P.u + P.v + P.w
 *         R.v = P.v
 *         R.w = P.v + P.w             # <<<<<<<<<<<<<<
 *         R.branch = 132
 *     elif P.y <= P.x <= P.z:
 */
    __pyx_v_R.w = (__pyx_v_P.v + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3464
 *         R.v = P.v
 *         R.w = P.v + P.w
 *         R.branch = 132             # <<<<<<<<<<<<<<
 *     elif P.y <= P.x <= P.z:
 *         R.x = P.x - P.y
 */
    __pyx_v_R.branch = 0x84;

    /* "slabbe/mult_cont_frac.pyx":3457
 *         R.w = P.w
 *         R.branch = 123
 *     elif P.x <= P.z <= P.y:             # <<<<<<<<<<<<<<
 *         R.x = P.x
 *         R.y = P.y - P.z
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3465
 *         R.w = P.v + P.w
 *         R.branch = 132
 *     elif P.y <= P.x <= P.z:             # <<<<<<<<<<<<<<
 *         R.x = P.x - P.y
 *         R.y = P.y
 */
  __pyx_t_1 = (__pyx_v_P.y <= __pyx_v_P.x);
  if (__pyx_t_1) {
    __pyx_t_1 = (__pyx_v_P.x <= __pyx_v_P.z);
  }
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":3466
 *         R.branch = 132
 *     elif P.y <= P.x <= P.z:
 *         R.x = P.x - P.y             # <<<<<<<<<<<<<<
 *         R.y = P.y
 *         R.z = P.z - P.x
 */
    __pyx_v_R.x = (__pyx_v_P.x - __pyx_v_P.y);

    /* "slabbe/mult_cont_frac.pyx":3467
 *     elif P.y <= P.x <= P.z:
 *         R.x = P.x - P.y
 *         R.y = P.y             # <<<<<<<<<<<<<<
 *         R.z = P.z - P.x
 *         R.u = P.u       + P.w
 */
    __pyx_t_3 = __pyx_v_P.y;
    __pyx_v_R.y = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3468
 *         R.x = P.x - P.y
 *         R.y = P.y
 *         R.z = P.z - P.x             # <<<<<<<<<<<<<<
 *         R.u = P.u       + P.w
 *         R.v = P.u + P.v + P.w
 */
    __pyx_v_R.z = (__pyx_v_P.z - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":3469
 *         R.y = P.y
 *         R.z = P.z - P.x
 *         R.u = P.u       + P.w             # <<<<<<<<<<<<<<
 *         R.v = P.u + P.v + P.w
 *         R.w = P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3470
 *         R.z = P.z - P.x
 *         R.u = P.u       + P.w
 *         R.v = P.u + P.v + P.w             # <<<<<<<<<<<<<<
 *         R.w = P.w
 *         R.branch = 213
 */
    __pyx_v_R.v = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3471
 *         R.u = P.u       + P.w
 *         R.v = P.u + P.v + P.w
 *         R.w = P.w             # <<<<<<<<<<<<<<
 *         R.branch = 213
 *     elif P.z <= P.x <= P.y:
 */
    __pyx_t_3 = __pyx_v_P.w;
    __pyx_v_R.w = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3472
 *         R.v = P.u + P.v + P.w
 *         R.w = P.w
 *         R.branch = 213             # <<<<<<<<<<<<<<
 *     elif P.z <= P.x <= P.y:
 *         R.x = P.x - P.z
 */
    __pyx_v_R.branch = 0xD5;

    /* "slabbe/mult_cont_frac.pyx":3465
 *         R.w = P.v + P.w
 *         R.branch = 132
 *     elif P.y <= P.x <= P.z:             # <<<<<<<<<<<<<<
 *         R.x = P.x - P.y
 *         R.y = P.y
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3473
 *         R.w = P.w
 *         R.branch = 213
 *     elif P.z <= P.x <= P.y:             # <<<<<<<<<<<<<<
 *         R.x = P.x - P.z
 *         R.y = P.y - P.x
 */
  __pyx_t_2 = (__pyx_v_P.z <= __pyx_v_P.x);
  if (__pyx_t_2) {
    __pyx_t_2 = (__pyx_v_P.x <= __pyx_v_P.y);
  }
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3474
 *         R.branch = 213
 *     elif P.z <= P.x <= P.y:
 *         R.x = P.x - P.z             # <<<<<<<<<<<<<<
 *         R.y = P.y - P.x
 *         R.z = P.z
 */
    __pyx_v_R.x = (__pyx_v_P.x - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":3475
 *     elif P.z <= P.x <= P.y:
 *         R.x = P.x - P.z
 *         R.y = P.y - P.x             # <<<<<<<<<<<<<<
 *         R.z = P.z
 *         R.u = P.u + P.v
 */
    __pyx_v_R.y = (__pyx_v_P.y - __pyx_v_P.x);

    /* "slabbe/mult_cont_frac.pyx":3476
 *         R.x = P.x - P.z
 *         R.y = P.y - P.x
 *         R.z = P.z             # <<<<<<<<<<<<<<
 *         R.u = P.u + P.v
 *         R.v = P.v
 */
    __pyx_t_3 = __pyx_v_P.z;
    __pyx_v_R.z = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3477
 *         R.y = P.y - P.x
 *         R.z = P.z
 *         R.u = P.u + P.v             # <<<<<<<<<<<<<<
 *         R.v = P.v
 *         R.w = P.u + P.v + P.w
 */
    __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":3478
 *         R.z = P.z
 *         R.u = P.u + P.v
 *         R.v = P.v             # <<<<<<<<<<<<<<
 *         R.w = P.u + P.v + P.w
 *         R.branch = 312
 */
    __pyx_t_3 = __pyx_v_P.v;
    __pyx_v_R.v = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3479
 *         R.u = P.u + P.v
 *         R.v = P.v
 *         R.w = P.u + P.v + P.w             # <<<<<<<<<<<<<<
 *         R.branch = 312
 *     elif P.y <= P.z <= P.x:
 */
    __pyx_v_R.w = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3480
 *         R.v = P.v
 *         R.w = P.u + P.v + P.w
 *         R.branch = 312             # <<<<<<<<<<<<<<
 *     elif P.y <= P.z <= P.x:
 *         R.x = P.x - P.z
 */
    __pyx_v_R.branch = 0x138;

    /* "slabbe/mult_cont_frac.pyx":3473
 *         R.w = P.w
 *         R.branch = 213
 *     elif P.z <= P.x <= P.y:             # <<<<<<<<<<<<<<
 *         R.x = P.x - P.z
 *         R.y = P.y - P.x
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3481
 *         R.w = P.u + P.v + P.w
 *         R.branch = 312
 *     elif P.y <= P.z <= P.x:             # <<<<<<<<<<<<<<
 *         R.x = P.x - P.z
 *         R.y = P.y
 */
  __pyx_t_1 = (__pyx_v_P.y <= __pyx_v_P.z);
  if (__pyx_t_1) {
    __pyx_t_1 = (__pyx_v_P.z <= __pyx_v_P.x);
  }
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "slabbe/mult_cont_frac.pyx":3482
 *         R.branch = 312
 *     elif P.y <= P.z <= P.x:
 *         R.x = P.x - P.z             # <<<<<<<<<<<<<<
 *         R.y = P.y
 *         R.z = P.z - P.y
 */
    __pyx_v_R.x = (__pyx_v_P.x - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":3483
 *     elif P.y <= P.z <= P.x:
 *         R.x = P.x - P.z
 *         R.y = P.y             # <<<<<<<<<<<<<<
 *         R.z = P.z - P.y
 *         R.u = P.u
 */
    __pyx_t_3 = __pyx_v_P.y;
    __pyx_v_R.y = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3484
 *         R.x = P.x - P.z
 *         R.y = P.y
 *         R.z = P.z - P.y             # <<<<<<<<<<<<<<
 *         R.u = P.u
 *         R.v = P.u + P.v + P.w
 */
    __pyx_v_R.z = (__pyx_v_P.z - __pyx_v_P.y);

    /* "slabbe/mult_cont_frac.pyx":3485
 *         R.y = P.y
 *         R.z = P.z - P.y
 *         R.u = P.u             # <<<<<<<<<<<<<<
 *         R.v = P.u + P.v + P.w
 *         R.w = P.u + P.w
 */
    __pyx_t_3 = __pyx_v_P.u;
    __pyx_v_R.u = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3486
 *         R.z = P.z - P.y
 *         R.u = P.u
 *         R.v = P.u + P.v + P.w             # <<<<<<<<<<<<<<
 *         R.w = P.u + P.w
 *         R.branch = 231
 */
    __pyx_v_R.v = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3487
 *         R.u = P.u
 *         R.v = P.u + P.v + P.w
 *         R.w = P.u + P.w             # <<<<<<<<<<<<<<
 *         R.branch = 231
 *     elif P.z <= P.y <= P.x:
 */
    __pyx_v_R.w = (__pyx_v_P.u + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3488
 *         R.v = P.u + P.v + P.w
 *         R.w = P.u + P.w
 *         R.branch = 231             # <<<<<<<<<<<<<<
 *     elif P.z <= P.y <= P.x:
 *         R.x = P.x - P.y
 */
    __pyx_v_R.branch = 0xE7;

    /* "slabbe/mult_cont_frac.pyx":3481
 *         R.w = P.u + P.v + P.w
 *         R.branch = 312
 *     elif P.y <= P.z <= P.x:             # <<<<<<<<<<<<<<
 *         R.x = P.x - P.z
 *         R.y = P.y
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3489
 *         R.w = P.u + P.w
 *         R.branch = 231
 *     elif P.z <= P.y <= P.x:             # <<<<<<<<<<<<<<
 *         R.x = P.x - P.y
 *         R.y = P.y - P.z
 */
  __pyx_t_2 = (__pyx_v_P.z <= __pyx_v_P.y);
  if (__pyx_t_2) {
    __pyx_t_2 = (__pyx_v_P.y <= __pyx_v_P.x);
  }
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3490
 *         R.branch = 231
 *     elif P.z <= P.y <= P.x:
 *         R.x = P.x - P.y             # <<<<<<<<<<<<<<
 *         R.y = P.y - P.z
 *         R.z = P.z
 */
    __pyx_v_R.x = (__pyx_v_P.x - __pyx_v_P.y);

    /* "slabbe/mult_cont_frac.pyx":3491
 *     elif P.z <= P.y <= P.x:
 *         R.x = P.x - P.y
 *         R.y = P.y - P.z             # <<<<<<<<<<<<<<
 *         R.z = P.z
 *         R.u = P.u
 */
    __pyx_v_R.y = (__pyx_v_P.y - __pyx_v_P.z);

    /* "slabbe/mult_cont_frac.pyx":3492
 *         R.x = P.x - P.y
 *         R.y = P.y - P.z
 *         R.z = P.z             # <<<<<<<<<<<<<<
 *         R.u = P.u
 *         R.v = P.u + P.v
 */
    __pyx_t_3 = __pyx_v_P.z;
    __pyx_v_R.z = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3493
 *         R.y = P.y - P.z
 *         R.z = P.z
 *         R.u = P.u             # <<<<<<<<<<<<<<
 *         R.v = P.u + P.v
 *         R.w = P.u + P.v + P.w
 */
    __pyx_t_3 = __pyx_v_P.u;
    __pyx_v_R.u = __pyx_t_3;

    /* "slabbe/mult_cont_frac.pyx":3494
 *         R.z = P.z
 *         R.u = P.u
 *         R.v = P.u + P.v             # <<<<<<<<<<<<<<
 *         R.w = P.u + P.v + P.w
 *         R.branch = 321
 */
    __pyx_v_R.v = (__pyx_v_P.u + __pyx_v_P.v);

    /* "slabbe/mult_cont_frac.pyx":3495
 *         R.u = P.u
 *         R.v = P.u + P.v
 *         R.w = P.u + P.v + P.w             # <<<<<<<<<<<<<<
 *         R.branch = 321
 *     else:
 */
    __pyx_v_R.w = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

    /* "slabbe/mult_cont_frac.pyx":3496
 *         R.v = P.u + P.v
 *         R.w = P.u + P.v + P.w
 *         R.branch = 321             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError('limit case: reach set of measure zero: {}'.format(P))
 */
    __pyx_v_R.branch = 0x141;

    /* "slabbe/mult_cont_frac.pyx":3489
 *         R.w = P.u + P.w
 *         R.branch = 231
 *     elif P.z <= P.y <= P.x:             # <<<<<<<<<<<<<<
 *         R.x = P.x - P.y
 *         R.y = P.y - P.z
 */
    goto __pyx_L3;
  }

  /* "slabbe/mult_cont_frac.pyx":3498
 *         R.branch = 321
 *     else:
 *         raise ValueError('limit case: reach set of measure zero: {}'.format(P))             # <<<<<<<<<<<<<<
 *     return R
 * 
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_limit_case_reach_set_of_measure, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __pyx_convert__to_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(__pyx_v_P); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3498, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3498, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3498, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 3498, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "slabbe/mult_cont_frac.pyx":3499
 *     else:
 *         raise ValueError('limit case: reach set of measure zero: {}'.format(P))
 *     return R             # <<<<<<<<<<<<<<
 * 
 * cdef inline PairPoint3d _Sorted_ArnouxRauzy(PairPoint3d P):
 */
  __pyx_r = __pyx_v_R;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3443
 *         return R
 * 
 * cdef inline PairPoint3d _Poincare(PairPoint3d P) except *:             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("slabbe.mult_cont_frac._Poincare", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":3501
 *     return R
 * 
 * cdef inline PairPoint3d _Sorted_ArnouxRauzy(PairPoint3d P):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac__Sorted_ArnouxRauzy(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  __Pyx_RefNannySetupContext("_Sorted_ArnouxRauzy", 0);

  /* "slabbe/mult_cont_frac.pyx":3508
 *     #Arnoux-Rauzy
 *     cdef PairPoint3d R
 *     R.x = P.x             # <<<<<<<<<<<<<<
 *     R.y = P.y
 *     R.z = P.z - (P.x + P.y)
 */
  __pyx_t_1 = __pyx_v_P.x;
  __pyx_v_R.x = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3509
 *     cdef PairPoint3d R
 *     R.x = P.x
 *     R.y = P.y             # <<<<<<<<<<<<<<
 *     R.z = P.z - (P.x + P.y)
 *     R.u = P.u + P.w
 */
  __pyx_t_1 = __pyx_v_P.y;
  __pyx_v_R.y = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3510
 *     R.x = P.x
 *     R.y = P.y
 *     R.z = P.z - (P.x + P.y)             # <<<<<<<<<<<<<<
 *     R.u = P.u + P.w
 *     R.v = P.v + P.w
 */
  __pyx_v_R.z = (__pyx_v_P.z - (__pyx_v_P.x + __pyx_v_P.y));

  /* "slabbe/mult_cont_frac.pyx":3511
 *     R.y = P.y
 *     R.z = P.z - (P.x + P.y)
 *     R.u = P.u + P.w             # <<<<<<<<<<<<<<
 *     R.v = P.v + P.w
 *     R.w = P.w
 */
  __pyx_v_R.u = (__pyx_v_P.u + __pyx_v_P.w);

  /* "slabbe/mult_cont_frac.pyx":3512
 *     R.z = P.z - (P.x + P.y)
 *     R.u = P.u + P.w
 *     R.v = P.v + P.w             # <<<<<<<<<<<<<<
 *     R.w = P.w
 *     R.branch = 100
 */
  __pyx_v_R.v = (__pyx_v_P.v + __pyx_v_P.w);

  /* "slabbe/mult_cont_frac.pyx":3513
 *     R.u = P.u + P.w
 *     R.v = P.v + P.w
 *     R.w = P.w             # <<<<<<<<<<<<<<
 *     R.branch = 100
 *     return Sort(R)
 */
  __pyx_t_1 = __pyx_v_P.w;
  __pyx_v_R.w = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3514
 *     R.v = P.v + P.w
 *     R.w = P.w
 *     R.branch = 100             # <<<<<<<<<<<<<<
 *     return Sort(R)
 * 
 */
  __pyx_v_R.branch = 0x64;

  /* "slabbe/mult_cont_frac.pyx":3515
 *     R.w = P.w
 *     R.branch = 100
 *     return Sort(R)             # <<<<<<<<<<<<<<
 * 
 * cdef inline PairPoint3d _Sorted_ArnouxRauzyMulti(PairPoint3d P):
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_R);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3501
 *     return R
 * 
 * cdef inline PairPoint3d _Sorted_ArnouxRauzy(PairPoint3d P):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":3517
 *     return Sort(R)
 * 
 * cdef inline PairPoint3d _Sorted_ArnouxRauzyMulti(PairPoint3d P):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac__Sorted_ArnouxRauzyMulti(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  int __pyx_v_m;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  __Pyx_RefNannySetupContext("_Sorted_ArnouxRauzyMulti", 0);

  /* "slabbe/mult_cont_frac.pyx":3524
 *     #Arnoux-Rauzy Multi
 *     cdef int m
 *     m = <int>(P.z / (P.x + P.y))             # <<<<<<<<<<<<<<
 *     P.z -= m * (P.x + P.y)
 *     P.v += m * P.w;
 */
  __pyx_t_1 = (__pyx_v_P.x + __pyx_v_P.y);
  if (unlikely(__pyx_t_1 == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 3524, __pyx_L1_error)
  }
  __pyx_v_m = ((int)(__pyx_v_P.z / __pyx_t_1));

  /* "slabbe/mult_cont_frac.pyx":3525
 *     cdef int m
 *     m = <int>(P.z / (P.x + P.y))
 *     P.z -= m * (P.x + P.y)             # <<<<<<<<<<<<<<
 *     P.v += m * P.w;
 *     P.u += m * P.w;
 */
  __pyx_v_P.z = (__pyx_v_P.z - (__pyx_v_m * (__pyx_v_P.x + __pyx_v_P.y)));

  /* "slabbe/mult_cont_frac.pyx":3526
 *     m = <int>(P.z / (P.x + P.y))
 *     P.z -= m * (P.x + P.y)
 *     P.v += m * P.w;             # <<<<<<<<<<<<<<
 *     P.u += m * P.w;
 *     P.branch = 100
 */
  __pyx_v_P.v = (__pyx_v_P.v + (__pyx_v_m * __pyx_v_P.w));

  /* "slabbe/mult_cont_frac.pyx":3527
 *     P.z -= m * (P.x + P.y)
 *     P.v += m * P.w;
 *     P.u += m * P.w;             # <<<<<<<<<<<<<<
 *     P.branch = 100
 *     return Sort(P)
 */
  __pyx_v_P.u = (__pyx_v_P.u + (__pyx_v_m * __pyx_v_P.w));

  /* "slabbe/mult_cont_frac.pyx":3528
 *     P.v += m * P.w;
 *     P.u += m * P.w;
 *     P.branch = 100             # <<<<<<<<<<<<<<
 *     return Sort(P)
 * 
 */
  __pyx_v_P.branch = 0x64;

  /* "slabbe/mult_cont_frac.pyx":3529
 *     P.u += m * P.w;
 *     P.branch = 100
 *     return Sort(P)             # <<<<<<<<<<<<<<
 * 
 * cdef inline PairPoint3d _Sorted_Poincare(PairPoint3d P):
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_P);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3517
 *     return Sort(R)
 * 
 * cdef inline PairPoint3d _Sorted_ArnouxRauzyMulti(PairPoint3d P):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("slabbe.mult_cont_frac._Sorted_ArnouxRauzyMulti", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "slabbe/mult_cont_frac.pyx":3531
 *     return Sort(P)
 * 
 * cdef inline PairPoint3d _Sorted_Poincare(PairPoint3d P):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac__Sorted_Poincare(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_R;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  __Pyx_RefNannySetupContext("_Sorted_Poincare", 0);

  /* "slabbe/mult_cont_frac.pyx":3538
 *     # Apply the algo
 *     cdef PairPoint3d R
 *     R.x = P.x             # <<<<<<<<<<<<<<
 *     R.y = P.y - P.x
 *     R.z = P.z - P.y
 */
  __pyx_t_1 = __pyx_v_P.x;
  __pyx_v_R.x = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3539
 *     cdef PairPoint3d R
 *     R.x = P.x
 *     R.y = P.y - P.x             # <<<<<<<<<<<<<<
 *     R.z = P.z - P.y
 *     R.u = P.u + P.v + P.w
 */
  __pyx_v_R.y = (__pyx_v_P.y - __pyx_v_P.x);

  /* "slabbe/mult_cont_frac.pyx":3540
 *     R.x = P.x
 *     R.y = P.y - P.x
 *     R.z = P.z - P.y             # <<<<<<<<<<<<<<
 *     R.u = P.u + P.v + P.w
 *     R.v = P.v + P.w
 */
  __pyx_v_R.z = (__pyx_v_P.z - __pyx_v_P.y);

  /* "slabbe/mult_cont_frac.pyx":3541
 *     R.y = P.y - P.x
 *     R.z = P.z - P.y
 *     R.u = P.u + P.v + P.w             # <<<<<<<<<<<<<<
 *     R.v = P.v + P.w
 *     R.w = P.w
 */
  __pyx_v_R.u = ((__pyx_v_P.u + __pyx_v_P.v) + __pyx_v_P.w);

  /* "slabbe/mult_cont_frac.pyx":3542
 *     R.z = P.z - P.y
 *     R.u = P.u + P.v + P.w
 *     R.v = P.v + P.w             # <<<<<<<<<<<<<<
 *     R.w = P.w
 *     R.branch = 200
 */
  __pyx_v_R.v = (__pyx_v_P.v + __pyx_v_P.w);

  /* "slabbe/mult_cont_frac.pyx":3543
 *     R.u = P.u + P.v + P.w
 *     R.v = P.v + P.w
 *     R.w = P.w             # <<<<<<<<<<<<<<
 *     R.branch = 200
 *     return Sort(R)
 */
  __pyx_t_1 = __pyx_v_P.w;
  __pyx_v_R.w = __pyx_t_1;

  /* "slabbe/mult_cont_frac.pyx":3544
 *     R.v = P.v + P.w
 *     R.w = P.w
 *     R.branch = 200             # <<<<<<<<<<<<<<
 *     return Sort(R)
 * cdef inline PairPoint3d _Sorted_Meester(PairPoint3d P):
 */
  __pyx_v_R.branch = 0xC8;

  /* "slabbe/mult_cont_frac.pyx":3545
 *     R.w = P.w
 *     R.branch = 200
 *     return Sort(R)             # <<<<<<<<<<<<<<
 * cdef inline PairPoint3d _Sorted_Meester(PairPoint3d P):
 *     r"""
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_R);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3531
 *     return Sort(P)
 * 
 * cdef inline PairPoint3d _Sorted_Poincare(PairPoint3d P):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":3546
 *     R.branch = 200
 *     return Sort(R)
 * cdef inline PairPoint3d _Sorted_Meester(PairPoint3d P):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac__Sorted_Meester(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Sorted_Meester", 0);

  /* "slabbe/mult_cont_frac.pyx":3552
 *     """
 *     # Apply the algo
 *     P.y -= P.x             # <<<<<<<<<<<<<<
 *     P.z -= P.x
 *     P.u += P.v + P.w
 */
  __pyx_v_P.y = (__pyx_v_P.y - __pyx_v_P.x);

  /* "slabbe/mult_cont_frac.pyx":3553
 *     # Apply the algo
 *     P.y -= P.x
 *     P.z -= P.x             # <<<<<<<<<<<<<<
 *     P.u += P.v + P.w
 *     P.branch = 100
 */
  __pyx_v_P.z = (__pyx_v_P.z - __pyx_v_P.x);

  /* "slabbe/mult_cont_frac.pyx":3554
 *     P.y -= P.x
 *     P.z -= P.x
 *     P.u += P.v + P.w             # <<<<<<<<<<<<<<
 *     P.branch = 100
 *     return Sort(P)
 */
  __pyx_v_P.u = (__pyx_v_P.u + (__pyx_v_P.v + __pyx_v_P.w));

  /* "slabbe/mult_cont_frac.pyx":3555
 *     P.z -= P.x
 *     P.u += P.v + P.w
 *     P.branch = 100             # <<<<<<<<<<<<<<
 *     return Sort(P)
 * 
 */
  __pyx_v_P.branch = 0x64;

  /* "slabbe/mult_cont_frac.pyx":3556
 *     P.u += P.v + P.w
 *     P.branch = 100
 *     return Sort(P)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_f_6slabbe_14mult_cont_frac_Sort(__pyx_v_P);
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3546
 *     R.branch = 200
 *     return Sort(R)
 * cdef inline PairPoint3d _Sorted_Meester(PairPoint3d P):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":3559
 * 
 * 
 * cdef inline PairPoint3d Sort(PairPoint3d P):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

static CYTHON_INLINE struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_f_6slabbe_14mult_cont_frac_Sort(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_P) {
  double __pyx_v_tmp;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  double __pyx_t_2;
  __Pyx_RefNannySetupContext("Sort", 0);

  /* "slabbe/mult_cont_frac.pyx":3565
 *     """
 *     cdef double tmp
 *     if P.x > P.y:             # <<<<<<<<<<<<<<
 *         tmp = P.x
 *         P.x = P.y
 */
  __pyx_t_1 = ((__pyx_v_P.x > __pyx_v_P.y) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3566
 *     cdef double tmp
 *     if P.x > P.y:
 *         tmp = P.x             # <<<<<<<<<<<<<<
 *         P.x = P.y
 *         P.y = tmp
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_tmp = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3567
 *     if P.x > P.y:
 *         tmp = P.x
 *         P.x = P.y             # <<<<<<<<<<<<<<
 *         P.y = tmp
 *         tmp = P.u
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_P.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3568
 *         tmp = P.x
 *         P.x = P.y
 *         P.y = tmp             # <<<<<<<<<<<<<<
 *         tmp = P.u
 *         P.u = P.v
 */
    __pyx_v_P.y = __pyx_v_tmp;

    /* "slabbe/mult_cont_frac.pyx":3569
 *         P.x = P.y
 *         P.y = tmp
 *         tmp = P.u             # <<<<<<<<<<<<<<
 *         P.u = P.v
 *         P.v = tmp
 */
    __pyx_t_2 = __pyx_v_P.u;
    __pyx_v_tmp = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3570
 *         P.y = tmp
 *         tmp = P.u
 *         P.u = P.v             # <<<<<<<<<<<<<<
 *         P.v = tmp
 *         P.branch += 1
 */
    __pyx_t_2 = __pyx_v_P.v;
    __pyx_v_P.u = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3571
 *         tmp = P.u
 *         P.u = P.v
 *         P.v = tmp             # <<<<<<<<<<<<<<
 *         P.branch += 1
 *     if P.y > P.z:
 */
    __pyx_v_P.v = __pyx_v_tmp;

    /* "slabbe/mult_cont_frac.pyx":3572
 *         P.u = P.v
 *         P.v = tmp
 *         P.branch += 1             # <<<<<<<<<<<<<<
 *     if P.y > P.z:
 *         tmp = P.y
 */
    __pyx_v_P.branch = (__pyx_v_P.branch + 1);

    /* "slabbe/mult_cont_frac.pyx":3565
 *     """
 *     cdef double tmp
 *     if P.x > P.y:             # <<<<<<<<<<<<<<
 *         tmp = P.x
 *         P.x = P.y
 */
  }

  /* "slabbe/mult_cont_frac.pyx":3573
 *         P.v = tmp
 *         P.branch += 1
 *     if P.y > P.z:             # <<<<<<<<<<<<<<
 *         tmp = P.y
 *         P.y = P.z
 */
  __pyx_t_1 = ((__pyx_v_P.y > __pyx_v_P.z) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3574
 *         P.branch += 1
 *     if P.y > P.z:
 *         tmp = P.y             # <<<<<<<<<<<<<<
 *         P.y = P.z
 *         P.z = tmp
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_tmp = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3575
 *     if P.y > P.z:
 *         tmp = P.y
 *         P.y = P.z             # <<<<<<<<<<<<<<
 *         P.z = tmp
 *         tmp = P.v
 */
    __pyx_t_2 = __pyx_v_P.z;
    __pyx_v_P.y = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3576
 *         tmp = P.y
 *         P.y = P.z
 *         P.z = tmp             # <<<<<<<<<<<<<<
 *         tmp = P.v
 *         P.v = P.w
 */
    __pyx_v_P.z = __pyx_v_tmp;

    /* "slabbe/mult_cont_frac.pyx":3577
 *         P.y = P.z
 *         P.z = tmp
 *         tmp = P.v             # <<<<<<<<<<<<<<
 *         P.v = P.w
 *         P.w = tmp
 */
    __pyx_t_2 = __pyx_v_P.v;
    __pyx_v_tmp = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3578
 *         P.z = tmp
 *         tmp = P.v
 *         P.v = P.w             # <<<<<<<<<<<<<<
 *         P.w = tmp
 *         P.branch += 2
 */
    __pyx_t_2 = __pyx_v_P.w;
    __pyx_v_P.v = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3579
 *         tmp = P.v
 *         P.v = P.w
 *         P.w = tmp             # <<<<<<<<<<<<<<
 *         P.branch += 2
 *     if P.x > P.y:
 */
    __pyx_v_P.w = __pyx_v_tmp;

    /* "slabbe/mult_cont_frac.pyx":3580
 *         P.v = P.w
 *         P.w = tmp
 *         P.branch += 2             # <<<<<<<<<<<<<<
 *     if P.x > P.y:
 *         tmp = P.x
 */
    __pyx_v_P.branch = (__pyx_v_P.branch + 2);

    /* "slabbe/mult_cont_frac.pyx":3573
 *         P.v = tmp
 *         P.branch += 1
 *     if P.y > P.z:             # <<<<<<<<<<<<<<
 *         tmp = P.y
 *         P.y = P.z
 */
  }

  /* "slabbe/mult_cont_frac.pyx":3581
 *         P.w = tmp
 *         P.branch += 2
 *     if P.x > P.y:             # <<<<<<<<<<<<<<
 *         tmp = P.x
 *         P.x = P.y
 */
  __pyx_t_1 = ((__pyx_v_P.x > __pyx_v_P.y) != 0);
  if (__pyx_t_1) {

    /* "slabbe/mult_cont_frac.pyx":3582
 *         P.branch += 2
 *     if P.x > P.y:
 *         tmp = P.x             # <<<<<<<<<<<<<<
 *         P.x = P.y
 *         P.y = tmp
 */
    __pyx_t_2 = __pyx_v_P.x;
    __pyx_v_tmp = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3583
 *     if P.x > P.y:
 *         tmp = P.x
 *         P.x = P.y             # <<<<<<<<<<<<<<
 *         P.y = tmp
 *         tmp = P.u
 */
    __pyx_t_2 = __pyx_v_P.y;
    __pyx_v_P.x = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3584
 *         tmp = P.x
 *         P.x = P.y
 *         P.y = tmp             # <<<<<<<<<<<<<<
 *         tmp = P.u
 *         P.u = P.v
 */
    __pyx_v_P.y = __pyx_v_tmp;

    /* "slabbe/mult_cont_frac.pyx":3585
 *         P.x = P.y
 *         P.y = tmp
 *         tmp = P.u             # <<<<<<<<<<<<<<
 *         P.u = P.v
 *         P.v = tmp
 */
    __pyx_t_2 = __pyx_v_P.u;
    __pyx_v_tmp = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3586
 *         P.y = tmp
 *         tmp = P.u
 *         P.u = P.v             # <<<<<<<<<<<<<<
 *         P.v = tmp
 *         P.branch += 4
 */
    __pyx_t_2 = __pyx_v_P.v;
    __pyx_v_P.u = __pyx_t_2;

    /* "slabbe/mult_cont_frac.pyx":3587
 *         tmp = P.u
 *         P.u = P.v
 *         P.v = tmp             # <<<<<<<<<<<<<<
 *         P.branch += 4
 *     return P
 */
    __pyx_v_P.v = __pyx_v_tmp;

    /* "slabbe/mult_cont_frac.pyx":3588
 *         P.u = P.v
 *         P.v = tmp
 *         P.branch += 4             # <<<<<<<<<<<<<<
 *     return P
 * 
 */
    __pyx_v_P.branch = (__pyx_v_P.branch + 4);

    /* "slabbe/mult_cont_frac.pyx":3581
 *         P.w = tmp
 *         P.branch += 2
 *     if P.x > P.y:             # <<<<<<<<<<<<<<
 *         tmp = P.x
 *         P.x = P.y
 */
  }

  /* "slabbe/mult_cont_frac.pyx":3589
 *         P.v = tmp
 *         P.branch += 4
 *     return P             # <<<<<<<<<<<<<<
 * 
 * cdef inline (double, double) projection3to2(double x, double y, double z):
 */
  __pyx_r = __pyx_v_P;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3559
 * 
 * 
 * cdef inline PairPoint3d Sort(PairPoint3d P):             # <<<<<<<<<<<<<<
 *     r"""
 *     EXAMPLES::
 */

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

/* "slabbe/mult_cont_frac.pyx":3591
 *     return P
 * 
 * cdef inline (double, double) projection3to2(double x, double y, double z):             # <<<<<<<<<<<<<<
 *     cdef double s = -SQRT3SUR2 * x + SQRT3SUR2 * y
 *     cdef double t = -.5 * x -.5 * y + z
 */

static CYTHON_INLINE __pyx_ctuple_double__and_double __pyx_f_6slabbe_14mult_cont_frac_projection3to2(double __pyx_v_x, double __pyx_v_y, double __pyx_v_z) {
  double __pyx_v_s;
  double __pyx_v_t;
  __pyx_ctuple_double__and_double __pyx_r;
  __Pyx_RefNannyDeclarations
  __pyx_ctuple_double__and_double __pyx_t_1;
  __Pyx_RefNannySetupContext("projection3to2", 0);

  /* "slabbe/mult_cont_frac.pyx":3592
 * 
 * cdef inline (double, double) projection3to2(double x, double y, double z):
 *     cdef double s = -SQRT3SUR2 * x + SQRT3SUR2 * y             # <<<<<<<<<<<<<<
 *     cdef double t = -.5 * x -.5 * y + z
 *     return s,t
 */
  __pyx_v_s = (((-__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2) * __pyx_v_x) + (__pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2 * __pyx_v_y));

  /* "slabbe/mult_cont_frac.pyx":3593
 * cdef inline (double, double) projection3to2(double x, double y, double z):
 *     cdef double s = -SQRT3SUR2 * x + SQRT3SUR2 * y
 *     cdef double t = -.5 * x -.5 * y + z             # <<<<<<<<<<<<<<
 *     return s,t
 * 
 */
  __pyx_v_t = (((-.5 * __pyx_v_x) - (.5 * __pyx_v_y)) + __pyx_v_z);

  /* "slabbe/mult_cont_frac.pyx":3594
 *     cdef double s = -SQRT3SUR2 * x + SQRT3SUR2 * y
 *     cdef double t = -.5 * x -.5 * y + z
 *     return s,t             # <<<<<<<<<<<<<<
 * 
 */
  __pyx_t_1.f0 = __pyx_v_s;
  __pyx_t_1.f1 = __pyx_v_t;
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "slabbe/mult_cont_frac.pyx":3591
 *     return P
 * 
 * cdef inline (double, double) projection3to2(double x, double y, double z):             # <<<<<<<<<<<<<<
 *     cdef double s = -SQRT3SUR2 * x + SQRT3SUR2 * y
 *     cdef double t = -.5 * x -.5 * y + z
 */

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

/* "cysignals/signals.pxd":35
 * # (PyErr_Occurred() is non-NULL). To Cython, it will look like
 * # cython_check_exception() actually raised the exception.
 * cdef inline void cython_check_exception() nogil except *:             # <<<<<<<<<<<<<<
 *     pass
 * 
 */

static CYTHON_INLINE void __pyx_f_9cysignals_7signals_cython_check_exception(void) {

  /* function exit code */
}

/* "FromPyStructUtility":11
 * 
 * @cname("__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d")
 * cdef PairPoint3d __pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(obj) except *:             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d result
 *     if not PyMapping_Check(obj):
 */

static struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(PyObject *__pyx_v_obj) {
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_v_result;
  PyObject *__pyx_v_value = NULL;
  struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  double __pyx_t_10;
  __Pyx_RefNannySetupContext("__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d", 0);

  /* "FromPyStructUtility":13
 * cdef PairPoint3d __pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(obj) except *:
 *     cdef PairPoint3d result
 *     if not PyMapping_Check(obj):             # <<<<<<<<<<<<<<
 *         PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name)
 * 
 */
  __pyx_t_1 = ((!(PyMapping_Check(__pyx_v_obj) != 0)) != 0);
  if (__pyx_t_1) {

    /* "FromPyStructUtility":14
 *     cdef PairPoint3d result
 *     if not PyMapping_Check(obj):
 *         PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name)             # <<<<<<<<<<<<<<
 * 
 *     try:
 */
    __pyx_t_2 = PyErr_Format(__pyx_builtin_TypeError, ((char const *)"Expected %.16s, got %.200s"), ((char *)"a mapping"), Py_TYPE(__pyx_v_obj)->tp_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "FromPyStructUtility":13
 * cdef PairPoint3d __pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(obj) except *:
 *     cdef PairPoint3d result
 *     if not PyMapping_Check(obj):             # <<<<<<<<<<<<<<
 *         PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name)
 * 
 */
  }

  /* "FromPyStructUtility":16
 *         PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name)
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['x']
 *     except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "FromPyStructUtility":17
 * 
 *     try:
 *         value = obj['x']             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'x'")
 */
      __pyx_t_2 = PyObject_GetItem(__pyx_v_obj, __pyx_n_s_x); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 17, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_value = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "FromPyStructUtility":16
 *         PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name)
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['x']
 *     except KeyError:
 */
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L11_try_end;
    __pyx_L4_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "FromPyStructUtility":18
 *     try:
 *         value = obj['x']
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise ValueError("No value specified for struct attribute 'x'")
 *     result.x = value
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("FromPyStructUtility.__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(1, 18, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_8);

      /* "FromPyStructUtility":19
 *         value = obj['x']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'x'")             # <<<<<<<<<<<<<<
 *     result.x = value
 *     try:
 */
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 19, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(1, 19, __pyx_L6_except_error)
    }
    goto __pyx_L6_except_error;
    __pyx_L6_except_error:;

    /* "FromPyStructUtility":16
 *         PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name)
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['x']
 *     except KeyError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L11_try_end:;
  }

  /* "FromPyStructUtility":20
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'x'")
 *     result.x = value             # <<<<<<<<<<<<<<
 *     try:
 *         value = obj['y']
 */
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 20, __pyx_L1_error)
  __pyx_v_result.x = __pyx_t_10;

  /* "FromPyStructUtility":21
 *         raise ValueError("No value specified for struct attribute 'x'")
 *     result.x = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['y']
 *     except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "FromPyStructUtility":22
 *     result.x = value
 *     try:
 *         value = obj['y']             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'y'")
 */
      __pyx_t_8 = PyObject_GetItem(__pyx_v_obj, __pyx_n_s_y); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 22, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "FromPyStructUtility":21
 *         raise ValueError("No value specified for struct attribute 'x'")
 *     result.x = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['y']
 *     except KeyError:
 */
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L21_try_end;
    __pyx_L14_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "FromPyStructUtility":23
 *     try:
 *         value = obj['y']
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise ValueError("No value specified for struct attribute 'y'")
 *     result.y = value
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("FromPyStructUtility.__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_2) < 0) __PYX_ERR(1, 23, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_2);

      /* "FromPyStructUtility":24
 *         value = obj['y']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'y'")             # <<<<<<<<<<<<<<
 *     result.y = value
 *     try:
 */
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 24, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(1, 24, __pyx_L16_except_error)
    }
    goto __pyx_L16_except_error;
    __pyx_L16_except_error:;

    /* "FromPyStructUtility":21
 *         raise ValueError("No value specified for struct attribute 'x'")
 *     result.x = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['y']
 *     except KeyError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L21_try_end:;
  }

  /* "FromPyStructUtility":25
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'y'")
 *     result.y = value             # <<<<<<<<<<<<<<
 *     try:
 *         value = obj['z']
 */
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 25, __pyx_L1_error)
  __pyx_v_result.y = __pyx_t_10;

  /* "FromPyStructUtility":26
 *         raise ValueError("No value specified for struct attribute 'y'")
 *     result.y = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['z']
 *     except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "FromPyStructUtility":27
 *     result.y = value
 *     try:
 *         value = obj['z']             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'z'")
 */
      __pyx_t_2 = PyObject_GetItem(__pyx_v_obj, __pyx_n_s_z); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 27, __pyx_L24_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "FromPyStructUtility":26
 *         raise ValueError("No value specified for struct attribute 'y'")
 *     result.y = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['z']
 *     except KeyError:
 */
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L31_try_end;
    __pyx_L24_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "FromPyStructUtility":28
 *     try:
 *         value = obj['z']
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise ValueError("No value specified for struct attribute 'z'")
 *     result.z = value
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("FromPyStructUtility.__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(1, 28, __pyx_L26_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_8);

      /* "FromPyStructUtility":29
 *         value = obj['z']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'z'")             # <<<<<<<<<<<<<<
 *     result.z = value
 *     try:
 */
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 29, __pyx_L26_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(1, 29, __pyx_L26_except_error)
    }
    goto __pyx_L26_except_error;
    __pyx_L26_except_error:;

    /* "FromPyStructUtility":26
 *         raise ValueError("No value specified for struct attribute 'y'")
 *     result.y = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['z']
 *     except KeyError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L31_try_end:;
  }

  /* "FromPyStructUtility":30
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'z'")
 *     result.z = value             # <<<<<<<<<<<<<<
 *     try:
 *         value = obj['u']
 */
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 30, __pyx_L1_error)
  __pyx_v_result.z = __pyx_t_10;

  /* "FromPyStructUtility":31
 *         raise ValueError("No value specified for struct attribute 'z'")
 *     result.z = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['u']
 *     except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "FromPyStructUtility":32
 *     result.z = value
 *     try:
 *         value = obj['u']             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'u'")
 */
      __pyx_t_8 = PyObject_GetItem(__pyx_v_obj, __pyx_n_s_u); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 32, __pyx_L34_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "FromPyStructUtility":31
 *         raise ValueError("No value specified for struct attribute 'z'")
 *     result.z = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['u']
 *     except KeyError:
 */
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L41_try_end;
    __pyx_L34_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "FromPyStructUtility":33
 *     try:
 *         value = obj['u']
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise ValueError("No value specified for struct attribute 'u'")
 *     result.u = value
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("FromPyStructUtility.__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_2) < 0) __PYX_ERR(1, 33, __pyx_L36_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_2);

      /* "FromPyStructUtility":34
 *         value = obj['u']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'u'")             # <<<<<<<<<<<<<<
 *     result.u = value
 *     try:
 */
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 34, __pyx_L36_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(1, 34, __pyx_L36_except_error)
    }
    goto __pyx_L36_except_error;
    __pyx_L36_except_error:;

    /* "FromPyStructUtility":31
 *         raise ValueError("No value specified for struct attribute 'z'")
 *     result.z = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['u']
 *     except KeyError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L41_try_end:;
  }

  /* "FromPyStructUtility":35
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'u'")
 *     result.u = value             # <<<<<<<<<<<<<<
 *     try:
 *         value = obj['v']
 */
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 35, __pyx_L1_error)
  __pyx_v_result.u = __pyx_t_10;

  /* "FromPyStructUtility":36
 *         raise ValueError("No value specified for struct attribute 'u'")
 *     result.u = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['v']
 *     except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "FromPyStructUtility":37
 *     result.u = value
 *     try:
 *         value = obj['v']             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'v'")
 */
      __pyx_t_2 = PyObject_GetItem(__pyx_v_obj, __pyx_n_s_v); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 37, __pyx_L44_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "FromPyStructUtility":36
 *         raise ValueError("No value specified for struct attribute 'u'")
 *     result.u = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['v']
 *     except KeyError:
 */
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L51_try_end;
    __pyx_L44_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "FromPyStructUtility":38
 *     try:
 *         value = obj['v']
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise ValueError("No value specified for struct attribute 'v'")
 *     result.v = value
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("FromPyStructUtility.__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(1, 38, __pyx_L46_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_8);

      /* "FromPyStructUtility":39
 *         value = obj['v']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'v'")             # <<<<<<<<<<<<<<
 *     result.v = value
 *     try:
 */
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 39, __pyx_L46_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(1, 39, __pyx_L46_except_error)
    }
    goto __pyx_L46_except_error;
    __pyx_L46_except_error:;

    /* "FromPyStructUtility":36
 *         raise ValueError("No value specified for struct attribute 'u'")
 *     result.u = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['v']
 *     except KeyError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L51_try_end:;
  }

  /* "FromPyStructUtility":40
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'v'")
 *     result.v = value             # <<<<<<<<<<<<<<
 *     try:
 *         value = obj['w']
 */
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 40, __pyx_L1_error)
  __pyx_v_result.v = __pyx_t_10;

  /* "FromPyStructUtility":41
 *         raise ValueError("No value specified for struct attribute 'v'")
 *     result.v = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['w']
 *     except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "FromPyStructUtility":42
 *     result.v = value
 *     try:
 *         value = obj['w']             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'w'")
 */
      __pyx_t_8 = PyObject_GetItem(__pyx_v_obj, __pyx_n_s_w); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 42, __pyx_L54_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "FromPyStructUtility":41
 *         raise ValueError("No value specified for struct attribute 'v'")
 *     result.v = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['w']
 *     except KeyError:
 */
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L61_try_end;
    __pyx_L54_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "FromPyStructUtility":43
 *     try:
 *         value = obj['w']
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise ValueError("No value specified for struct attribute 'w'")
 *     result.w = value
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("FromPyStructUtility.__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_2) < 0) __PYX_ERR(1, 43, __pyx_L56_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_2);

      /* "FromPyStructUtility":44
 *         value = obj['w']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'w'")             # <<<<<<<<<<<<<<
 *     result.w = value
 *     try:
 */
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 44, __pyx_L56_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(1, 44, __pyx_L56_except_error)
    }
    goto __pyx_L56_except_error;
    __pyx_L56_except_error:;

    /* "FromPyStructUtility":41
 *         raise ValueError("No value specified for struct attribute 'v'")
 *     result.v = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['w']
 *     except KeyError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L61_try_end:;
  }

  /* "FromPyStructUtility":45
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'w'")
 *     result.w = value             # <<<<<<<<<<<<<<
 *     try:
 *         value = obj['branch']
 */
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 45, __pyx_L1_error)
  __pyx_v_result.w = __pyx_t_10;

  /* "FromPyStructUtility":46
 *         raise ValueError("No value specified for struct attribute 'w'")
 *     result.w = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['branch']
 *     except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "FromPyStructUtility":47
 *     result.w = value
 *     try:
 *         value = obj['branch']             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'branch'")
 */
      __pyx_t_2 = PyObject_GetItem(__pyx_v_obj, __pyx_n_s_branch); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 47, __pyx_L64_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "FromPyStructUtility":46
 *         raise ValueError("No value specified for struct attribute 'w'")
 *     result.w = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['branch']
 *     except KeyError:
 */
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L71_try_end;
    __pyx_L64_error:;
    __Pyx_PyThreadState_assign
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "FromPyStructUtility":48
 *     try:
 *         value = obj['branch']
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise ValueError("No value specified for struct attribute 'branch'")
 *     result.branch = value
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("FromPyStructUtility.__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(1, 48, __pyx_L66_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_8);

      /* "FromPyStructUtility":49
 *         value = obj['branch']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'branch'")             # <<<<<<<<<<<<<<
 *     result.branch = value
 *     return result
 */
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 49, __pyx_L66_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(1, 49, __pyx_L66_except_error)
    }
    goto __pyx_L66_except_error;
    __pyx_L66_except_error:;

    /* "FromPyStructUtility":46
 *         raise ValueError("No value specified for struct attribute 'w'")
 *     result.w = value
 *     try:             # <<<<<<<<<<<<<<
 *         value = obj['branch']
 *     except KeyError:
 */
    __Pyx_PyThreadState_assign
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L71_try_end:;
  }

  /* "FromPyStructUtility":50
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'branch'")
 *     result.branch = value             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 50, __pyx_L1_error)
  __pyx_v_result.branch = __pyx_t_6;

  /* "FromPyStructUtility":51
 *         raise ValueError("No value specified for struct attribute 'branch'")
 *     result.branch = value
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "FromPyStructUtility":11
 * 
 * @cname("__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d")
 * cdef PairPoint3d __pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(obj) except *:             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d result
 *     if not PyMapping_Check(obj):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("FromPyStructUtility.__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm __pyx_vtable_6slabbe_14mult_cont_frac_MCFAlgorithm;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *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_6slabbe_14mult_cont_frac_MCFAlgorithm *)o);
  p->__pyx_vtab = __pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_6slabbe_14mult_cont_frac_MCFAlgorithm[] = {
  {"substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_1substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_substitutions},
  {"dual_substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_3dual_substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_2dual_substitutions},
  {"branches", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_5branches, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_4branches},
  {"_test_definition", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_7_test_definition, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_6_test_definition},
  {"_test_dual_substitution_definition", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_9_test_dual_substitution_definition, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_8_test_dual_substitution_definition},
  {"_test_coherence", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_11_test_coherence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_10_test_coherence},
  {"class_name", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_13class_name, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_12class_name},
  {"name", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_15name, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_14name},
  {"matrix_cocycle", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_23matrix_cocycle, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_22matrix_cocycle},
  {"coding_iterator", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_25coding_iterator, METH_O, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_24coding_iterator},
  {"n_matrix", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_28n_matrix, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_27n_matrix},
  {"simplex_orbit_iterator", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_30simplex_orbit_iterator, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_29simplex_orbit_iterator},
  {"simplex_orbit_list", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_33simplex_orbit_list, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_32simplex_orbit_list},
  {"simplex_orbit_filtered_list", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_35simplex_orbit_filtered_list, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_34simplex_orbit_filtered_list},
  {"cone_orbit_iterator", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_37cone_orbit_iterator, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_36cone_orbit_iterator},
  {"cone_orbit_list", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_40cone_orbit_list, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_39cone_orbit_list},
  {"image", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_42image, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_41image},
  {"_invariant_measure_dict", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_44_invariant_measure_dict, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_43_invariant_measure_dict},
  {"_natural_extention_dict", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_46_natural_extention_dict, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_45_natural_extention_dict},
  {"lyapunov_exponents", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_48lyapunov_exponents, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_47lyapunov_exponents},
  {"s_adic_word", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_50s_adic_word, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_49s_adic_word},
  {"discrepancy_statistics", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_52discrepancy_statistics, METH_O, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_51discrepancy_statistics},
  {"e_one_star_patch", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_54e_one_star_patch, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_53e_one_star_patch},
  {"invariant_measure_wireframe_plot", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_56invariant_measure_wireframe_plot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_55invariant_measure_wireframe_plot},
  {"invariant_measure_contour_plot", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_58invariant_measure_contour_plot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_57invariant_measure_contour_plot},
  {"natural_extension_plot", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_60natural_extension_plot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_59natural_extension_plot},
  {"natural_extension_tikz", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_62natural_extension_tikz, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_61natural_extension_tikz},
  {"natural_extension_part_tikz", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_64natural_extension_part_tikz, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_63natural_extension_part_tikz},
  {"natural_extension_part_png", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_66natural_extension_part_png, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_65natural_extension_part_png},
  {"measure_evaluation", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_68measure_evaluation, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_67measure_evaluation},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_MCFAlgorithm = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.MCFAlgorithm", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_21__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6slabbe_14mult_cont_frac_MCFAlgorithm, /*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_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Brun __pyx_vtable_6slabbe_14mult_cont_frac_Brun;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Brun(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Brun *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Brun *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Brun;
  return o;
}

static PyMethodDef __pyx_methods_6slabbe_14mult_cont_frac_Brun[] = {
  {"substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_4Brun_1substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_4Brun_substitutions},
  {"dual_substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_4Brun_3dual_substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_4Brun_2dual_substitutions},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Brun = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Brun", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Brun), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "\n    EXAMPLES::\n\n        sage: from slabbe.mult_cont_frac import Brun\n        sage: algo = Brun()\n        sage: TestSuite(algo).run()\n        sage: algo._test_dual_substitution_definition()\n        sage: algo._test_coherence()\n        sage: algo._test_definition()\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6slabbe_14mult_cont_frac_Brun, /*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_6slabbe_14mult_cont_frac_Brun, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Reverse __pyx_vtable_6slabbe_14mult_cont_frac_Reverse;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Reverse(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Reverse;
  return o;
}

static PyMethodDef __pyx_methods_6slabbe_14mult_cont_frac_Reverse[] = {
  {"substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_7Reverse_1substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_7Reverse_substitutions},
  {"dual_substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_7Reverse_3dual_substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_7Reverse_2dual_substitutions},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Reverse = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Reverse", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Reverse), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "\n    EXAMPLES::\n\n        sage: from slabbe.mult_cont_frac import Reverse\n        sage: algo = Reverse()\n        sage: TestSuite(algo).run()\n        sage: algo._test_dual_substitution_definition()\n        sage: algo._test_coherence()\n        sage: algo._test_definition()\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6slabbe_14mult_cont_frac_Reverse, /*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_6slabbe_14mult_cont_frac_Reverse, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_ARP __pyx_vtable_6slabbe_14mult_cont_frac_ARP;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_ARP(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_ARP *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_ARP;
  return o;
}

static PyMethodDef __pyx_methods_6slabbe_14mult_cont_frac_ARP[] = {
  {"name", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_3ARP_1name, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_3ARP_name},
  {"substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_3ARP_3substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_3ARP_2substitutions},
  {"dual_substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_3ARP_5dual_substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_3ARP_4dual_substitutions},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_ARP = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.ARP", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_ARP), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "\n    EXAMPLES::\n\n        sage: from slabbe.mult_cont_frac import ARP\n        sage: algo = ARP()\n        sage: TestSuite(algo).run()\n        sage: algo._test_dual_substitution_definition()\n        sage: algo._test_coherence()\n        sage: algo._test_definition()\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6slabbe_14mult_cont_frac_ARP, /*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_6slabbe_14mult_cont_frac_ARP, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_ArnouxRauzy __pyx_vtable_6slabbe_14mult_cont_frac_ArnouxRauzy;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_ArnouxRauzy(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_ArnouxRauzy;
  return o;
}

static PyMethodDef __pyx_methods_6slabbe_14mult_cont_frac_ArnouxRauzy[] = {
  {"substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_11ArnouxRauzy_1substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_11ArnouxRauzy_substitutions},
  {"dual_substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_11ArnouxRauzy_3dual_substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_11ArnouxRauzy_2dual_substitutions},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_ArnouxRauzy = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.ArnouxRauzy", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_ArnouxRauzy), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "\n    EXAMPLES::\n\n        sage: from slabbe.mult_cont_frac import ArnouxRauzy\n        sage: algo = ArnouxRauzy()\n        sage: TestSuite(algo).run()\n        sage: algo._test_dual_substitution_definition()\n        sage: algo._test_coherence()\n        sage: algo._test_definition()\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6slabbe_14mult_cont_frac_ArnouxRauzy, /*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_6slabbe_14mult_cont_frac_ArnouxRauzy, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Poincare __pyx_vtable_6slabbe_14mult_cont_frac_Poincare;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Poincare(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Poincare;
  return o;
}

static PyMethodDef __pyx_methods_6slabbe_14mult_cont_frac_Poincare[] = {
  {"name", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_8Poincare_1name, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_8Poincare_name},
  {"substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_8Poincare_3substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_8Poincare_2substitutions},
  {"dual_substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_8Poincare_5dual_substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_8Poincare_4dual_substitutions},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Poincare = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Poincare", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Poincare), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "\n    EXAMPLES::\n\n        sage: from slabbe.mult_cont_frac import Poincare\n        sage: algo = Poincare()\n        sage: TestSuite(algo).run()\n        sage: algo._test_dual_substitution_definition()\n        sage: algo._test_coherence()\n        sage: algo._test_definition()\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6slabbe_14mult_cont_frac_Poincare, /*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_6slabbe_14mult_cont_frac_Poincare, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Selmer __pyx_vtable_6slabbe_14mult_cont_frac_Selmer;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Selmer(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Selmer;
  return o;
}

static PyMethodDef __pyx_methods_6slabbe_14mult_cont_frac_Selmer[] = {
  {"substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_6Selmer_1substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_6Selmer_substitutions},
  {"dual_substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_6Selmer_3dual_substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_6Selmer_2dual_substitutions},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Selmer = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Selmer", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Selmer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "\n    EXAMPLES::\n\n        sage: from slabbe.mult_cont_frac import Selmer\n        sage: algo = Selmer()\n        sage: TestSuite(algo).run()\n        sage: algo._test_dual_substitution_definition()\n        sage: algo._test_coherence()\n        sage: algo._test_definition()\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6slabbe_14mult_cont_frac_Selmer, /*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_6slabbe_14mult_cont_frac_Selmer, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_FullySubtractive __pyx_vtable_6slabbe_14mult_cont_frac_FullySubtractive;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_FullySubtractive(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_FullySubtractive;
  return o;
}

static PyMethodDef __pyx_methods_6slabbe_14mult_cont_frac_FullySubtractive[] = {
  {"name", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_16FullySubtractive_1name, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_16FullySubtractive_name},
  {"substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_16FullySubtractive_3substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_16FullySubtractive_2substitutions},
  {"dual_substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_16FullySubtractive_5dual_substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_16FullySubtractive_4dual_substitutions},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_FullySubtractive = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.FullySubtractive", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_FullySubtractive), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "\n    EXAMPLES::\n\n        sage: from slabbe.mult_cont_frac import FullySubtractive\n        sage: algo = FullySubtractive()\n        sage: TestSuite(algo).run()\n        sage: algo._test_dual_substitution_definition()\n        sage: algo._test_coherence()\n        sage: algo._test_definition()\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6slabbe_14mult_cont_frac_FullySubtractive, /*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_6slabbe_14mult_cont_frac_FullySubtractive, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Cassaigne __pyx_vtable_6slabbe_14mult_cont_frac_Cassaigne;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Cassaigne(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Cassaigne;
  return o;
}

static PyMethodDef __pyx_methods_6slabbe_14mult_cont_frac_Cassaigne[] = {
  {"substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_9Cassaigne_1substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_9Cassaigne_substitutions},
  {"dual_substitutions", (PyCFunction)__pyx_pw_6slabbe_14mult_cont_frac_9Cassaigne_3dual_substitutions, METH_NOARGS, __pyx_doc_6slabbe_14mult_cont_frac_9Cassaigne_2dual_substitutions},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Cassaigne = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Cassaigne", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Cassaigne), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "\n    EXAMPLES::\n\n        sage: from slabbe.mult_cont_frac import Cassaigne\n        sage: algo = Cassaigne()\n        sage: TestSuite(algo).run()\n        sage: algo._test_dual_substitution_definition()\n        sage: algo._test_coherence()\n        sage: algo._test_definition()\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6slabbe_14mult_cont_frac_Cassaigne, /*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_6slabbe_14mult_cont_frac_Cassaigne, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Brun __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Brun;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_Brun(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Brun *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Brun *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Brun;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_Brun = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_Brun", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Brun), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_Brun, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_BrunMulti __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_BrunMulti;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_BrunMulti(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_BrunMulti *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_BrunMulti *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_BrunMulti;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_BrunMulti = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_BrunMulti", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_BrunMulti), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_BrunMulti, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Selmer __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Selmer;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_Selmer(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Selmer *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Selmer *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Selmer;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_Selmer = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_Selmer", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Selmer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_Selmer, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Meester __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Meester;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_Meester(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Meester *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Meester *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Meester;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_Meester = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_Meester", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Meester), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_Meester, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_ArnouxRauzy", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_ArnouxRauzyMulti", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARP __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARP;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ARP(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARP *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARP *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARP;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARP = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_ARP", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARP), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_ARP, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARPMulti __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARPMulti;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ARPMulti(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARPMulti *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARPMulti *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARPMulti;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARPMulti = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_ARPMulti", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARPMulti), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_ARPMulti, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Poincare __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Poincare;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_Poincare(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Poincare *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Poincare *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Poincare;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_Poincare = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_Poincare", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Poincare), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_Poincare, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARrevert __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARrevert;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ARrevert(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevert *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevert *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARrevert;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevert = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_ARrevert", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevert), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_ARrevert, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_ARrevertMulti", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_ARMonteil __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARMonteil;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_ARMonteil(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARMonteil *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARMonteil *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARMonteil;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARMonteil = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_ARMonteil", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_ARMonteil), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_ARMonteil, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_Sorted_Delaunay __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Delaunay;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_Sorted_Delaunay(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Delaunay *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Delaunay *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Delaunay;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_Sorted_Delaunay = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.Sorted_Delaunay", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_Sorted_Delaunay), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_Sorted_Delaunay, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_JacobiPerron __pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerron;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_JacobiPerron(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerron *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerron *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerron;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_JacobiPerron = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.JacobiPerron", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerron), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_JacobiPerron, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_JacobiPerronAdditif __pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerronAdditif;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_JacobiPerronAdditif(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditif *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditif *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerronAdditif;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditif = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.JacobiPerronAdditif", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditif), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_JacobiPerronAdditif, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 __pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 *p;
  PyObject *o = __pyx_tp_new_6slabbe_14mult_cont_frac_MCFAlgorithm(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6slabbe_14mult_cont_frac_MCFAlgorithm*)__pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2;
  return o;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.JacobiPerronAdditifv2", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac_MCFAlgorithm, /*tp_dealloc*/
  0, /*tp_print*/
  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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6slabbe_14mult_cont_frac_12MCFAlgorithm_19__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  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_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct___test_coherence", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_k);
  Py_CLEAR(p->__pyx_v_s);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_k) {
    e = (*v)(p->__pyx_v_k, a); if (e) return e;
  }
  if (p->__pyx_v_s) {
    e = (*v)(p->__pyx_v_s, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_k);
  p->__pyx_v_k = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_s);
  p->__pyx_v_s = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_1_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_start);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_v_start) {
    e = (*v)(p->__pyx_v_start, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_start);
  p->__pyx_v_start = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_2_coding_iterator", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_norm_uvw);
  Py_CLEAR(p->__pyx_v_norm_xyz);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_start);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *)o;
  if (p->__pyx_v_norm_uvw) {
    e = (*v)(p->__pyx_v_norm_uvw, a); if (e) return e;
  }
  if (p->__pyx_v_norm_xyz) {
    e = (*v)(p->__pyx_v_norm_xyz, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_v_start) {
    e = (*v)(p->__pyx_v_start, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator *)o;
  tmp = ((PyObject*)p->__pyx_v_norm_uvw);
  p->__pyx_v_norm_uvw = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_norm_xyz);
  p->__pyx_v_norm_xyz = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_start);
  p->__pyx_v_start = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_3_simplex_orbit_iterator", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_start);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_v_start) {
    e = (*v)(p->__pyx_v_start, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_start);
  p->__pyx_v_start = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_4_cone_orbit_iterator", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_A);
  Py_CLEAR(p->__pyx_v_ZZ);
  Py_CLEAR(p->__pyx_v_v);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *)o;
  if (p->__pyx_v_A) {
    e = (*v)(p->__pyx_v_A, a); if (e) return e;
  }
  if (p->__pyx_v_ZZ) {
    e = (*v)(p->__pyx_v_ZZ, a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *)o;
  tmp = ((PyObject*)p->__pyx_v_A);
  p->__pyx_v_A = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_ZZ);
  p->__pyx_v_ZZ = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_v);
  p->__pyx_v_v = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_5_s_adic_word", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_a);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_a) {
    e = (*v)(p->__pyx_v_a, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_a);
  p->__pyx_v_a = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_6_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_a);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_a) {
    e = (*v)(p->__pyx_v_a, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_a);
  p->__pyx_v_a = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_7_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_D);
  Py_CLEAR(p->__pyx_v_keys);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *)o;
  if (p->__pyx_v_D) {
    e = (*v)(p->__pyx_v_D, a); if (e) return e;
  }
  if (p->__pyx_v_keys) {
    e = (*v)(p->__pyx_v_keys, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *)o;
  tmp = ((PyObject*)p->__pyx_v_D);
  p->__pyx_v_D = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_keys);
  p->__pyx_v_keys = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_8_e_one_star_patch", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_key);
  p->__pyx_v_key = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_0);
  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_9_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_c);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *)o;
  if (p->__pyx_v_c) {
    e = (*v)(p->__pyx_v_c, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot *)o;
  tmp = ((PyObject*)p->__pyx_v_c);
  p->__pyx_v_c = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_10_natural_extension_plot", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_branch_order);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *)o;
  if (p->__pyx_v_branch_order) {
    e = (*v)(p->__pyx_v_branch_order, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png *)o;
  tmp = ((PyObject*)p->__pyx_v_branch_order);
  p->__pyx_v_branch_order = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_11_natural_extension_part_png", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_L);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *)o;
  if (p->__pyx_v_L) {
    e = (*v)(p->__pyx_v_L, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *)o;
  tmp = ((PyObject*)p->__pyx_v_L);
  p->__pyx_v_L = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_12_measure_evaluation", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_p);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_p) {
    e = (*v)(p->__pyx_v_p, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_p);
  p->__pyx_v_p = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_13_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr[8];
static int __pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr = 0;

static PyObject *__pyx_tp_new_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr)))) {
    o = (PyObject*)__pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr[--__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr(PyObject *o) {
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_p);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr)))) {
    __pyx_freelist_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr[__pyx_freecount_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr++] = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_p) {
    e = (*v)(p->__pyx_v_p, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *p = (struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_p);
  p->__pyx_v_p = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "slabbe.mult_cont_frac.__pyx_scope_struct_14_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr, /*tp_traverse*/
  __pyx_tp_clear_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr, /*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_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    "mult_cont_frac",
    __pyx_k_Multidimensional_Continued_Frac, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0},
  {&__pyx_kp_s_0_0_1, __pyx_k_0_0_1, sizeof(__pyx_k_0_0_1), 0, 0, 1, 0},
  {&__pyx_kp_s_0_1_0, __pyx_k_0_1_0, sizeof(__pyx_k_0_1_0), 0, 0, 1, 0},
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_1_0_0, __pyx_k_1_0_0, sizeof(__pyx_k_1_0_0), 0, 0, 1, 0},
  {&__pyx_kp_s_1pt, __pyx_k_1pt, sizeof(__pyx_k_1pt), 0, 0, 1, 0},
  {&__pyx_kp_s_3_dimensional_continued_fractio, __pyx_k_3_dimensional_continued_fractio, sizeof(__pyx_k_3_dimensional_continued_fractio), 0, 0, 1, 0},
  {&__pyx_kp_s_3d, __pyx_k_3d, sizeof(__pyx_k_3d), 0, 0, 1, 0},
  {&__pyx_kp_s_4_by_1, __pyx_k_4_by_1, sizeof(__pyx_k_4_by_1), 0, 0, 1, 0},
  {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
  {&__pyx_kp_s_Algo_IN, __pyx_k_Algo_IN, sizeof(__pyx_k_Algo_IN), 0, 0, 1, 0},
  {&__pyx_kp_s_Algo_OUT, __pyx_k_Algo_OUT, sizeof(__pyx_k_Algo_OUT), 0, 0, 1, 0},
  {&__pyx_kp_s_Algo_s_nbiter_s, __pyx_k_Algo_s_nbiter_s, sizeof(__pyx_k_Algo_s_nbiter_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Arnoux_Rauzy_Poincar_e, __pyx_k_Arnoux_Rauzy_Poincar_e, sizeof(__pyx_k_Arnoux_Rauzy_Poincar_e), 0, 0, 1, 0},
  {&__pyx_kp_s_Arnoux_is_not_defined_on, __pyx_k_Arnoux_is_not_defined_on, sizeof(__pyx_k_Arnoux_is_not_defined_on), 0, 0, 1, 0},
  {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
  {&__pyx_n_s_Compositions, __pyx_k_Compositions, sizeof(__pyx_k_Compositions), 0, 0, 1, 1},
  {&__pyx_n_s_D, __pyx_k_D, sizeof(__pyx_k_D), 0, 0, 1, 1},
  {&__pyx_kp_s_Density_of_an_orbit_for_algorith, __pyx_k_Density_of_an_orbit_for_algorith, sizeof(__pyx_k_Density_of_an_orbit_for_algorith), 0, 0, 1, 0},
  {&__pyx_n_s_E1Star, __pyx_k_E1Star, sizeof(__pyx_k_E1Star), 0, 0, 1, 1},
  {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1},
  {&__pyx_n_s_Face, __pyx_k_Face, sizeof(__pyx_k_Face), 0, 0, 1, 1},
  {&__pyx_n_s_Frequency, __pyx_k_Frequency, sizeof(__pyx_k_Frequency), 0, 0, 1, 1},
  {&__pyx_kp_s_Fully_Subtractive, __pyx_k_Fully_Subtractive, sizeof(__pyx_k_Fully_Subtractive), 0, 0, 1, 0},
  {&__pyx_kp_s_INPUT, __pyx_k_INPUT, sizeof(__pyx_k_INPUT), 0, 0, 1, 0},
  {&__pyx_kp_s_Incoherence_between_the_definiti, __pyx_k_Incoherence_between_the_definiti, sizeof(__pyx_k_Incoherence_between_the_definiti), 0, 0, 1, 0},
  {&__pyx_kp_s_Incoherence_between_the_definiti_2, __pyx_k_Incoherence_between_the_definiti_2, sizeof(__pyx_k_Incoherence_between_the_definiti_2), 0, 0, 1, 0},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_n_s_MCFAlgorithm_coding_iterator, __pyx_k_MCFAlgorithm_coding_iterator, sizeof(__pyx_k_MCFAlgorithm_coding_iterator), 0, 0, 1, 1},
  {&__pyx_n_s_MCFAlgorithm_cone_orbit_iterator, __pyx_k_MCFAlgorithm_cone_orbit_iterator, sizeof(__pyx_k_MCFAlgorithm_cone_orbit_iterator), 0, 0, 1, 1},
  {&__pyx_n_s_MCFAlgorithm_simplex_orbit_itera, __pyx_k_MCFAlgorithm_simplex_orbit_itera, sizeof(__pyx_k_MCFAlgorithm_simplex_orbit_itera), 0, 0, 1, 1},
  {&__pyx_kp_s_Matrix_cocyle_not_implemented_fo, __pyx_k_Matrix_cocyle_not_implemented_fo, sizeof(__pyx_k_Matrix_cocyle_not_implemented_fo), 0, 0, 1, 0},
  {&__pyx_kp_s_NatExt_IN, __pyx_k_NatExt_IN, sizeof(__pyx_k_NatExt_IN), 0, 0, 1, 0},
  {&__pyx_kp_s_NatExt_OUT, __pyx_k_NatExt_OUT, sizeof(__pyx_k_NatExt_OUT), 0, 0, 1, 0},
  {&__pyx_kp_s_No_value_specified_for_struct_at, __pyx_k_No_value_specified_for_struct_at, sizeof(__pyx_k_No_value_specified_for_struct_at), 0, 0, 1, 0},
  {&__pyx_kp_s_No_value_specified_for_struct_at_2, __pyx_k_No_value_specified_for_struct_at_2, sizeof(__pyx_k_No_value_specified_for_struct_at_2), 0, 0, 1, 0},
  {&__pyx_kp_s_No_value_specified_for_struct_at_3, __pyx_k_No_value_specified_for_struct_at_3, sizeof(__pyx_k_No_value_specified_for_struct_at_3), 0, 0, 1, 0},
  {&__pyx_kp_s_No_value_specified_for_struct_at_4, __pyx_k_No_value_specified_for_struct_at_4, sizeof(__pyx_k_No_value_specified_for_struct_at_4), 0, 0, 1, 0},
  {&__pyx_kp_s_No_value_specified_for_struct_at_5, __pyx_k_No_value_specified_for_struct_at_5, sizeof(__pyx_k_No_value_specified_for_struct_at_5), 0, 0, 1, 0},
  {&__pyx_kp_s_No_value_specified_for_struct_at_6, __pyx_k_No_value_specified_for_struct_at_6, sizeof(__pyx_k_No_value_specified_for_struct_at_6), 0, 0, 1, 0},
  {&__pyx_kp_s_No_value_specified_for_struct_at_7, __pyx_k_No_value_specified_for_struct_at_7, sizeof(__pyx_k_No_value_specified_for_struct_at_7), 0, 0, 1, 0},
  {&__pyx_n_s_NotImplemented, __pyx_k_NotImplemented, sizeof(__pyx_k_NotImplemented), 0, 0, 1, 1},
  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
  {&__pyx_kp_s_OUTPUT, __pyx_k_OUTPUT, sizeof(__pyx_k_OUTPUT), 0, 0, 1, 0},
  {&__pyx_kp_s_On_input_algorithm_loops_on, __pyx_k_On_input_algorithm_loops_on, sizeof(__pyx_k_On_input_algorithm_loops_on), 0, 0, 1, 0},
  {&__pyx_kp_s_On_input_algorithm_reaches_non_i, __pyx_k_On_input_algorithm_reaches_non_i, sizeof(__pyx_k_On_input_algorithm_reaches_non_i), 0, 0, 1, 0},
  {&__pyx_n_s_P, __pyx_k_P, sizeof(__pyx_k_P), 0, 0, 1, 1},
  {&__pyx_n_s_PGF_COLORS, __pyx_k_PGF_COLORS, sizeof(__pyx_k_PGF_COLORS), 0, 0, 1, 1},
  {&__pyx_n_s_Patch, __pyx_k_Patch, sizeof(__pyx_k_Patch), 0, 0, 1, 1},
  {&__pyx_kp_s_Poincar_e, __pyx_k_Poincar_e, sizeof(__pyx_k_Poincar_e), 0, 0, 1, 0},
  {&__pyx_kp_s_Taking_only_points_instead_of_fo, __pyx_k_Taking_only_points_instead_of_fo, sizeof(__pyx_k_Taking_only_points_instead_of_fo), 0, 0, 1, 0},
  {&__pyx_kp_s_Taking_points_for_key, __pyx_k_Taking_points_for_key, sizeof(__pyx_k_Taking_points_for_key), 0, 0, 1, 0},
  {&__pyx_kp_s_The_problem_is_on_branch, __pyx_k_The_problem_is_on_branch, sizeof(__pyx_k_The_problem_is_on_branch), 0, 0, 1, 0},
  {&__pyx_kp_s_This_algo_does_not_preserve_the, __pyx_k_This_algo_does_not_preserve_the, sizeof(__pyx_k_This_algo_does_not_preserve_the), 0, 0, 1, 0},
  {&__pyx_n_s_TikzPicture, __pyx_k_TikzPicture, sizeof(__pyx_k_TikzPicture), 0, 0, 1, 1},
  {&__pyx_kp_s_Transpose_of_substitution_do_not, __pyx_k_Transpose_of_substitution_do_not, sizeof(__pyx_k_Transpose_of_substitution_do_not), 0, 0, 1, 0},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Unknown_value_for_norm_s, __pyx_k_Unknown_value_for_norm_s, sizeof(__pyx_k_Unknown_value_for_norm_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Unknown_value_for_norm_uvw_s, __pyx_k_Unknown_value_for_norm_uvw_s, sizeof(__pyx_k_Unknown_value_for_norm_uvw_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Unknown_value_for_norm_xyz_s, __pyx_k_Unknown_value_for_norm_xyz_s, sizeof(__pyx_k_Unknown_value_for_norm_xyz_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Unkown_value_for_draw, __pyx_k_Unkown_value_for_draw, sizeof(__pyx_k_Unkown_value_for_draw), 0, 0, 1, 0},
  {&__pyx_kp_s_Users_slabbe_GitHgSvn_slabbe_0, __pyx_k_Users_slabbe_GitHgSvn_slabbe_0, sizeof(__pyx_k_Users_slabbe_GitHgSvn_slabbe_0), 0, 0, 1, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_n_s_WordMorphism, __pyx_k_WordMorphism, sizeof(__pyx_k_WordMorphism), 0, 0, 1, 1},
  {&__pyx_n_s_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 0, 1, 1},
  {&__pyx_n_s_Y, __pyx_k_Y, sizeof(__pyx_k_Y), 0, 0, 1, 1},
  {&__pyx_n_s_ZZ, __pyx_k_ZZ, sizeof(__pyx_k_ZZ), 0, 0, 1, 1},
  {&__pyx_n_s__17, __pyx_k__17, sizeof(__pyx_k__17), 0, 0, 1, 1},
  {&__pyx_kp_s__27, __pyx_k__27, sizeof(__pyx_k__27), 0, 0, 1, 0},
  {&__pyx_kp_s__28, __pyx_k__28, sizeof(__pyx_k__28), 0, 0, 1, 0},
  {&__pyx_kp_s__29, __pyx_k__29, sizeof(__pyx_k__29), 0, 0, 1, 0},
  {&__pyx_n_s_abelian_vector, __pyx_k_abelian_vector, sizeof(__pyx_k_abelian_vector), 0, 0, 1, 1},
  {&__pyx_n_s_add_subplot, __pyx_k_add_subplot, sizeof(__pyx_k_add_subplot), 0, 0, 1, 1},
  {&__pyx_kp_s_addlegendentry_s, __pyx_k_addlegendentry_s, sizeof(__pyx_k_addlegendentry_s), 0, 0, 1, 0},
  {&__pyx_kp_s_addlegendentry_s_2, __pyx_k_addlegendentry_s_2, sizeof(__pyx_k_addlegendentry_s_2), 0, 0, 1, 0},
  {&__pyx_kp_s_addplot, __pyx_k_addplot, sizeof(__pyx_k_addplot), 0, 0, 1, 0},
  {&__pyx_kp_s_addplot_only_marks_mark_mark_op, __pyx_k_addplot_only_marks_mark_mark_op, sizeof(__pyx_k_addplot_only_marks_mark_mark_op), 0, 0, 1, 0},
  {&__pyx_kp_s_and_the_associated_substitutions, __pyx_k_and_the_associated_substitutions, sizeof(__pyx_k_and_the_associated_substitutions), 0, 0, 1, 0},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_axes3d, __pyx_k_axes3d, sizeof(__pyx_k_axes3d), 0, 0, 1, 1},
  {&__pyx_kp_s_axis_cs_s_s, __pyx_k_axis_cs_s_s, sizeof(__pyx_k_axis_cs_s_s), 0, 0, 1, 0},
  {&__pyx_n_s_axis_off, __pyx_k_axis_off, sizeof(__pyx_k_axis_off), 0, 0, 1, 1},
  {&__pyx_n_s_axx, __pyx_k_axx, sizeof(__pyx_k_axx), 0, 0, 1, 1},
  {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
  {&__pyx_kp_s_begin_axis_height_7cm_width_8cm, __pyx_k_begin_axis_height_7cm_width_8cm, sizeof(__pyx_k_begin_axis_height_7cm_width_8cm), 0, 0, 1, 0},
  {&__pyx_kp_s_begin_groupplot, __pyx_k_begin_groupplot, sizeof(__pyx_k_begin_groupplot), 0, 0, 1, 0},
  {&__pyx_kp_s_begin_tikzpicture_scale_7, __pyx_k_begin_tikzpicture_scale_7, sizeof(__pyx_k_begin_tikzpicture_scale_7), 0, 0, 1, 0},
  {&__pyx_kp_s_begin_tikzpicture_scale_7_2, __pyx_k_begin_tikzpicture_scale_7_2, sizeof(__pyx_k_begin_tikzpicture_scale_7_2), 0, 0, 1, 0},
  {&__pyx_n_s_black, __pyx_k_black, sizeof(__pyx_k_black), 0, 0, 1, 1},
  {&__pyx_n_s_blue, __pyx_k_blue, sizeof(__pyx_k_blue), 0, 0, 1, 1},
  {&__pyx_n_s_branch, __pyx_k_branch, sizeof(__pyx_k_branch), 0, 0, 1, 1},
  {&__pyx_n_s_branch_order, __pyx_k_branch_order, sizeof(__pyx_k_branch_order), 0, 0, 1, 1},
  {&__pyx_n_s_brown, __pyx_k_brown, sizeof(__pyx_k_brown), 0, 0, 1, 1},
  {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
  {&__pyx_kp_s_c_but_vector_is, __pyx_k_c_but_vector_is, sizeof(__pyx_k_c_but_vector_is), 0, 0, 1, 0},
  {&__pyx_n_s_clabel, __pyx_k_clabel, sizeof(__pyx_k_clabel), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_class_name, __pyx_k_class_name, sizeof(__pyx_k_class_name), 0, 0, 1, 1},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_cocycles, __pyx_k_cocycles, sizeof(__pyx_k_cocycles), 0, 0, 1, 1},
  {&__pyx_n_s_coding_iterator, __pyx_k_coding_iterator, sizeof(__pyx_k_coding_iterator), 0, 0, 1, 1},
  {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
  {&__pyx_n_s_color, __pyx_k_color, sizeof(__pyx_k_color), 0, 0, 1, 1},
  {&__pyx_n_s_color_dict, __pyx_k_color_dict, sizeof(__pyx_k_color_dict), 0, 0, 1, 1},
  {&__pyx_n_s_cone_orbit_iterator, __pyx_k_cone_orbit_iterator, sizeof(__pyx_k_cone_orbit_iterator), 0, 0, 1, 1},
  {&__pyx_n_s_contour, __pyx_k_contour, sizeof(__pyx_k_contour), 0, 0, 1, 1},
  {&__pyx_kp_s_coordinates, __pyx_k_coordinates, sizeof(__pyx_k_coordinates), 0, 0, 1, 0},
  {&__pyx_kp_s_coordinates_s, __pyx_k_coordinates_s, sizeof(__pyx_k_coordinates_s), 0, 0, 1, 0},
  {&__pyx_n_s_create_sub_plot, __pyx_k_create_sub_plot, sizeof(__pyx_k_create_sub_plot), 0, 0, 1, 1},
  {&__pyx_n_s_cstride, __pyx_k_cstride, sizeof(__pyx_k_cstride), 0, 0, 1, 1},
  {&__pyx_n_s_cyan, __pyx_k_cyan, sizeof(__pyx_k_cyan), 0, 0, 1, 1},
  {&__pyx_n_s_darkgray, __pyx_k_darkgray, sizeof(__pyx_k_darkgray), 0, 0, 1, 1},
  {&__pyx_n_s_defaultdict, __pyx_k_defaultdict, sizeof(__pyx_k_defaultdict), 0, 0, 1, 1},
  {&__pyx_n_s_discrepancy, __pyx_k_discrepancy, sizeof(__pyx_k_discrepancy), 0, 0, 1, 1},
  {&__pyx_n_s_domain, __pyx_k_domain, sizeof(__pyx_k_domain), 0, 0, 1, 1},
  {&__pyx_n_s_domain_left, __pyx_k_domain_left, sizeof(__pyx_k_domain_left), 0, 0, 1, 1},
  {&__pyx_n_s_domain_right, __pyx_k_domain_right, sizeof(__pyx_k_domain_right), 0, 0, 1, 1},
  {&__pyx_n_s_draw, __pyx_k_draw, sizeof(__pyx_k_draw), 0, 0, 1, 1},
  {&__pyx_kp_s_draw_dashed, __pyx_k_draw_dashed, sizeof(__pyx_k_draw_dashed), 0, 0, 1, 0},
  {&__pyx_kp_s_draw_dashed_axis_cs_s_s, __pyx_k_draw_dashed_axis_cs_s_s, sizeof(__pyx_k_draw_dashed_axis_cs_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_draw_draw_none_group_c1r1_cente, __pyx_k_draw_draw_none_group_c1r1_cente, sizeof(__pyx_k_draw_draw_none_group_c1r1_cente), 0, 0, 1, 0},
  {&__pyx_kp_s_draw_draw_none_group_c2r1_cente, __pyx_k_draw_draw_none_group_c2r1_cente, sizeof(__pyx_k_draw_draw_none_group_c2r1_cente), 0, 0, 1, 0},
  {&__pyx_kp_s_draw_draw_none_group_c3r1_cente, __pyx_k_draw_draw_none_group_c3r1_cente, sizeof(__pyx_k_draw_draw_none_group_c3r1_cente), 0, 0, 1, 0},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_dual_substitutions, __pyx_k_dual_substitutions, sizeof(__pyx_k_dual_substitutions), 0, 0, 1, 1},
  {&__pyx_n_s_e_one_star_patch_locals_genexpr, __pyx_k_e_one_star_patch_locals_genexpr, sizeof(__pyx_k_e_one_star_patch_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  {&__pyx_kp_s_end_axis, __pyx_k_end_axis, sizeof(__pyx_k_end_axis), 0, 0, 1, 0},
  {&__pyx_kp_s_end_groupplot, __pyx_k_end_groupplot, sizeof(__pyx_k_end_groupplot), 0, 0, 1, 0},
  {&__pyx_kp_s_end_tikzpicture, __pyx_k_end_tikzpicture, sizeof(__pyx_k_end_tikzpicture), 0, 0, 1, 0},
  {&__pyx_kp_s_end_tikzpicture_2, __pyx_k_end_tikzpicture_2, sizeof(__pyx_k_end_tikzpicture_2), 0, 0, 1, 0},
  {&__pyx_n_s_endswith, __pyx_k_endswith, sizeof(__pyx_k_endswith), 0, 0, 1, 1},
  {&__pyx_n_s_figure, __pyx_k_figure, sizeof(__pyx_k_figure), 0, 0, 1, 1},
  {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
  {&__pyx_n_s_finite_word, __pyx_k_finite_word, sizeof(__pyx_k_finite_word), 0, 0, 1, 1},
  {&__pyx_n_s_fontsize, __pyx_k_fontsize, sizeof(__pyx_k_fontsize), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_g, __pyx_k_g, sizeof(__pyx_k_g), 0, 0, 1, 1},
  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_gray, __pyx_k_gray, sizeof(__pyx_k_gray), 0, 0, 1, 1},
  {&__pyx_n_s_green, __pyx_k_green, sizeof(__pyx_k_green), 0, 0, 1, 1},
  {&__pyx_n_s_group_size, __pyx_k_group_size, sizeof(__pyx_k_group_size), 0, 0, 1, 1},
  {&__pyx_kp_s_group_style_group_size_s, __pyx_k_group_style_group_size_s, sizeof(__pyx_k_group_style_group_size_s), 0, 0, 1, 0},
  {&__pyx_n_s_ha, __pyx_k_ha, sizeof(__pyx_k_ha), 0, 0, 1, 1},
  {&__pyx_kp_s_height_7cm_width_8cm, __pyx_k_height_7cm_width_8cm, sizeof(__pyx_k_height_7cm_width_8cm), 0, 0, 1, 0},
  {&__pyx_kp_s_hide_axis, __pyx_k_hide_axis, sizeof(__pyx_k_hide_axis), 0, 0, 1, 0},
  {&__pyx_n_s_hypersurface, __pyx_k_hypersurface, sizeof(__pyx_k_hypersurface), 0, 0, 1, 1},
  {&__pyx_n_s_image, __pyx_k_image, sizeof(__pyx_k_image), 0, 0, 1, 1},
  {&__pyx_n_s_image_left, __pyx_k_image_left, sizeof(__pyx_k_image_left), 0, 0, 1, 1},
  {&__pyx_n_s_image_right, __pyx_k_image_right, sizeof(__pyx_k_image_right), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_incidence_matrix, __pyx_k_incidence_matrix, sizeof(__pyx_k_incidence_matrix), 0, 0, 1, 1},
  {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  {&__pyx_n_s_inf, __pyx_k_inf, sizeof(__pyx_k_inf), 0, 0, 1, 1},
  {&__pyx_n_s_inline, __pyx_k_inline, sizeof(__pyx_k_inline), 0, 0, 1, 1},
  {&__pyx_n_s_invariant_measure_dict, __pyx_k_invariant_measure_dict, sizeof(__pyx_k_invariant_measure_dict), 0, 0, 1, 1},
  {&__pyx_n_s_iteritems, __pyx_k_iteritems, sizeof(__pyx_k_iteritems), 0, 0, 1, 1},
  {&__pyx_kp_s_jacobi_not_defined_for_x_y_z_s_s, __pyx_k_jacobi_not_defined_for_x_y_z_s_s, sizeof(__pyx_k_jacobi_not_defined_for_x_y_z_s_s), 0, 0, 1, 0},
  {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
  {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1},
  {&__pyx_n_s_label, __pyx_k_label, sizeof(__pyx_k_label), 0, 0, 1, 1},
  {&__pyx_n_s_left, __pyx_k_left, sizeof(__pyx_k_left), 0, 0, 1, 1},
  {&__pyx_n_s_legend, __pyx_k_legend, sizeof(__pyx_k_legend), 0, 0, 1, 1},
  {&__pyx_kp_s_legend_image_post_style_mark_siz, __pyx_k_legend_image_post_style_mark_siz, sizeof(__pyx_k_legend_image_post_style_mark_siz), 0, 0, 1, 0},
  {&__pyx_n_s_legend_marksize, __pyx_k_legend_marksize, sizeof(__pyx_k_legend_marksize), 0, 0, 1, 1},
  {&__pyx_n_s_length, __pyx_k_length, sizeof(__pyx_k_length), 0, 0, 1, 1},
  {&__pyx_n_s_lightgray, __pyx_k_lightgray, sizeof(__pyx_k_lightgray), 0, 0, 1, 1},
  {&__pyx_n_s_lime, __pyx_k_lime, sizeof(__pyx_k_lime), 0, 0, 1, 1},
  {&__pyx_kp_s_limit_case_reach_set_of_measure, __pyx_k_limit_case_reach_set_of_measure, sizeof(__pyx_k_limit_case_reach_set_of_measure), 0, 0, 1, 0},
  {&__pyx_n_s_limit_nb_points, __pyx_k_limit_nb_points, sizeof(__pyx_k_limit_nb_points), 0, 0, 1, 1},
  {&__pyx_n_s_log, __pyx_k_log, sizeof(__pyx_k_log), 0, 0, 1, 1},
  {&__pyx_n_s_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 0, 1, 1},
  {&__pyx_n_s_magenta, __pyx_k_magenta, sizeof(__pyx_k_magenta), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_map, __pyx_k_map, sizeof(__pyx_k_map), 0, 0, 1, 1},
  {&__pyx_kp_s_mark_options_color_s, __pyx_k_mark_options_color_s, sizeof(__pyx_k_mark_options_color_s), 0, 0, 1, 0},
  {&__pyx_kp_s_mark_size_s, __pyx_k_mark_size_s, sizeof(__pyx_k_mark_size_s), 0, 0, 1, 0},
  {&__pyx_kp_s_mark_size_s_2, __pyx_k_mark_size_s_2, sizeof(__pyx_k_mark_size_s_2), 0, 0, 1, 0},
  {&__pyx_n_s_markerscale, __pyx_k_markerscale, sizeof(__pyx_k_markerscale), 0, 0, 1, 1},
  {&__pyx_n_s_markersize, __pyx_k_markersize, sizeof(__pyx_k_markersize), 0, 0, 1, 1},
  {&__pyx_n_s_marksize, __pyx_k_marksize, sizeof(__pyx_k_marksize), 0, 0, 1, 1},
  {&__pyx_n_s_math, __pyx_k_math, sizeof(__pyx_k_math), 0, 0, 1, 1},
  {&__pyx_kp_s_mathbf_a___n_1, __pyx_k_mathbf_a___n_1, sizeof(__pyx_k_mathbf_a___n_1), 0, 0, 1, 0},
  {&__pyx_kp_s_mathbf_a__n, __pyx_k_mathbf_a__n, sizeof(__pyx_k_mathbf_a__n), 0, 0, 1, 0},
  {&__pyx_kp_s_mathbf_x___n_1, __pyx_k_mathbf_x___n_1, sizeof(__pyx_k_mathbf_x___n_1), 0, 0, 1, 0},
  {&__pyx_kp_s_mathbf_x__n, __pyx_k_mathbf_x__n, sizeof(__pyx_k_mathbf_x__n), 0, 0, 1, 0},
  {&__pyx_n_s_matplotlib, __pyx_k_matplotlib, sizeof(__pyx_k_matplotlib), 0, 0, 1, 1},
  {&__pyx_n_s_matplotlib_pyplot, __pyx_k_matplotlib_pyplot, sizeof(__pyx_k_matplotlib_pyplot), 0, 0, 1, 1},
  {&__pyx_n_s_matrix_cocycle, __pyx_k_matrix_cocycle, sizeof(__pyx_k_matrix_cocycle), 0, 0, 1, 1},
  {&__pyx_n_s_measure_evaluation_locals_genexp, __pyx_k_measure_evaluation_locals_genexp, sizeof(__pyx_k_measure_evaluation_locals_genexp), 0, 0, 1, 1},
  {&__pyx_n_s_min_part, __pyx_k_min_part, sizeof(__pyx_k_min_part), 0, 0, 1, 1},
  {&__pyx_n_s_mpl_toolkits_mplot3d, __pyx_k_mpl_toolkits_mplot3d, sizeof(__pyx_k_mpl_toolkits_mplot3d), 0, 0, 1, 1},
  {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
  {&__pyx_n_s_n_iterations, __pyx_k_n_iterations, sizeof(__pyx_k_n_iterations), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  {&__pyx_n_s_natural_extension_part_png_local, __pyx_k_natural_extension_part_png_local, sizeof(__pyx_k_natural_extension_part_png_local), 0, 0, 1, 1},
  {&__pyx_n_s_natural_extension_plot_locals_cr, __pyx_k_natural_extension_plot_locals_cr, sizeof(__pyx_k_natural_extension_plot_locals_cr), 0, 0, 1, 1},
  {&__pyx_n_s_natural_extention_dict, __pyx_k_natural_extention_dict, sizeof(__pyx_k_natural_extention_dict), 0, 0, 1, 1},
  {&__pyx_n_s_ndivs, __pyx_k_ndivs, sizeof(__pyx_k_ndivs), 0, 0, 1, 1},
  {&__pyx_kp_s_ndivs_s_must_be_less_or_equal_to, __pyx_k_ndivs_s_must_be_less_or_equal_to, sizeof(__pyx_k_ndivs_s_must_be_less_or_equal_to), 0, 0, 1, 0},
  {&__pyx_kp_s_nextgroupplot, __pyx_k_nextgroupplot, sizeof(__pyx_k_nextgroupplot), 0, 0, 1, 0},
  {&__pyx_kp_s_node_above_mathbf_e__3_cycle, __pyx_k_node_above_mathbf_e__3_cycle, sizeof(__pyx_k_node_above_mathbf_e__3_cycle), 0, 0, 1, 0},
  {&__pyx_kp_s_node_above_mathbf_e__3_cycle_2, __pyx_k_node_above_mathbf_e__3_cycle_2, sizeof(__pyx_k_node_above_mathbf_e__3_cycle_2), 0, 0, 1, 0},
  {&__pyx_kp_s_node_at_axis_cs_s_s_s, __pyx_k_node_at_axis_cs_s_s_s, sizeof(__pyx_k_node_at_axis_cs_s_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_node_left_mathbf_e__1, __pyx_k_node_left_mathbf_e__1, sizeof(__pyx_k_node_left_mathbf_e__1), 0, 0, 1, 0},
  {&__pyx_kp_s_node_left_mathbf_e__1_axis_cs_s, __pyx_k_node_left_mathbf_e__1_axis_cs_s, sizeof(__pyx_k_node_left_mathbf_e__1_axis_cs_s), 0, 0, 1, 0},
  {&__pyx_kp_s_node_right_mathbf_e__2, __pyx_k_node_right_mathbf_e__2, sizeof(__pyx_k_node_right_mathbf_e__2), 0, 0, 1, 0},
  {&__pyx_kp_s_node_right_mathbf_e__2_axis_cs, __pyx_k_node_right_mathbf_e__2_axis_cs, sizeof(__pyx_k_node_right_mathbf_e__2_axis_cs), 0, 0, 1, 0},
  {&__pyx_kp_s_node_times_group_c2r1_center, __pyx_k_node_times_group_c2r1_center, sizeof(__pyx_k_node_times_group_c2r1_center), 0, 0, 1, 0},
  {&__pyx_kp_s_node_times_group_c4r1_center, __pyx_k_node_times_group_c4r1_center, sizeof(__pyx_k_node_times_group_c4r1_center), 0, 0, 1, 0},
  {&__pyx_kp_s_node_to_group_c3r1_center, __pyx_k_node_to_group_c3r1_center, sizeof(__pyx_k_node_to_group_c3r1_center), 0, 0, 1, 0},
  {&__pyx_kp_s_nombre_diterations_dans_la_fenet, __pyx_k_nombre_diterations_dans_la_fenet, sizeof(__pyx_k_nombre_diterations_dans_la_fenet), 0, 0, 1, 0},
  {&__pyx_n_s_norm, __pyx_k_norm, sizeof(__pyx_k_norm), 0, 0, 1, 1},
  {&__pyx_n_s_norm_uvw, __pyx_k_norm_uvw, sizeof(__pyx_k_norm_uvw), 0, 0, 1, 1},
  {&__pyx_n_s_norm_xyz, __pyx_k_norm_xyz, sizeof(__pyx_k_norm_xyz), 0, 0, 1, 1},
  {&__pyx_n_s_nth_letter, __pyx_k_nth_letter, sizeof(__pyx_k_nth_letter), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_s_o, __pyx_k_o, sizeof(__pyx_k_o), 0, 0, 1, 1},
  {&__pyx_n_s_olive, __pyx_k_olive, sizeof(__pyx_k_olive), 0, 0, 1, 1},
  {&__pyx_kp_s_on_the_th_iteration, __pyx_k_on_the_th_iteration, sizeof(__pyx_k_on_the_th_iteration), 0, 0, 1, 0},
  {&__pyx_kp_s_only_marks_mark, __pyx_k_only_marks_mark, sizeof(__pyx_k_only_marks_mark), 0, 0, 1, 0},
  {&__pyx_n_s_orange, __pyx_k_orange, sizeof(__pyx_k_orange), 0, 0, 1, 1},
  {&__pyx_n_s_packages, __pyx_k_packages, sizeof(__pyx_k_packages), 0, 0, 1, 1},
  {&__pyx_n_s_part, __pyx_k_part, sizeof(__pyx_k_part), 0, 0, 1, 1},
  {&__pyx_n_s_pgfplots, __pyx_k_pgfplots, sizeof(__pyx_k_pgfplots), 0, 0, 1, 1},
  {&__pyx_kp_s_pgfplots_groupplots, __pyx_k_pgfplots_groupplots, sizeof(__pyx_k_pgfplots_groupplots), 0, 0, 1, 0},
  {&__pyx_n_s_pink, __pyx_k_pink, sizeof(__pyx_k_pink), 0, 0, 1, 1},
  {&__pyx_kp_s_pixels_touchs_parmi_limage_2, __pyx_k_pixels_touchs_parmi_limage_2, sizeof(__pyx_k_pixels_touchs_parmi_limage_2), 0, 0, 1, 0},
  {&__pyx_n_s_plot, __pyx_k_plot, sizeof(__pyx_k_plot), 0, 0, 1, 1},
  {&__pyx_n_s_plot_wireframe, __pyx_k_plot_wireframe, sizeof(__pyx_k_plot_wireframe), 0, 0, 1, 1},
  {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1},
  {&__pyx_n_s_prod, __pyx_k_prod, sizeof(__pyx_k_prod), 0, 0, 1, 1},
  {&__pyx_n_s_projection, __pyx_k_projection, sizeof(__pyx_k_projection), 0, 0, 1, 1},
  {&__pyx_n_s_purple, __pyx_k_purple, sizeof(__pyx_k_purple), 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_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1},
  {&__pyx_n_s_randint, __pyx_k_randint, sizeof(__pyx_k_randint), 0, 0, 1, 1},
  {&__pyx_n_s_random, __pyx_k_random, sizeof(__pyx_k_random), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_red, __pyx_k_red, sizeof(__pyx_k_red), 0, 0, 1, 1},
  {&__pyx_n_s_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 0, 0, 1, 1},
  {&__pyx_n_s_right, __pyx_k_right, sizeof(__pyx_k_right), 0, 0, 1, 1},
  {&__pyx_n_s_rstride, __pyx_k_rstride, sizeof(__pyx_k_rstride), 0, 0, 1, 1},
  {&__pyx_n_s_s_adic, __pyx_k_s_adic, sizeof(__pyx_k_s_adic), 0, 0, 1, 1},
  {&__pyx_n_s_s_adic_word, __pyx_k_s_adic_word, sizeof(__pyx_k_s_adic_word), 0, 0, 1, 1},
  {&__pyx_n_s_s_adic_word_locals_genexpr, __pyx_k_s_adic_word_locals_genexpr, sizeof(__pyx_k_s_adic_word_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_sage_combinat_composition, __pyx_k_sage_combinat_composition, sizeof(__pyx_k_sage_combinat_composition), 0, 0, 1, 1},
  {&__pyx_n_s_sage_combinat_e_one_star, __pyx_k_sage_combinat_e_one_star, sizeof(__pyx_k_sage_combinat_e_one_star), 0, 0, 1, 1},
  {&__pyx_n_s_sage_combinat_words_morphism, __pyx_k_sage_combinat_words_morphism, sizeof(__pyx_k_sage_combinat_words_morphism), 0, 0, 1, 1},
  {&__pyx_n_s_sage_combinat_words_word_generat, __pyx_k_sage_combinat_words_word_generat, sizeof(__pyx_k_sage_combinat_words_word_generat), 0, 0, 1, 1},
  {&__pyx_n_s_sage_misc_misc_c, __pyx_k_sage_misc_misc_c, sizeof(__pyx_k_sage_misc_misc_c), 0, 0, 1, 1},
  {&__pyx_n_s_sage_misc_prandom, __pyx_k_sage_misc_prandom, sizeof(__pyx_k_sage_misc_prandom), 0, 0, 1, 1},
  {&__pyx_n_s_sage_modules_free_module_element, __pyx_k_sage_modules_free_module_element, sizeof(__pyx_k_sage_modules_free_module_element), 0, 0, 1, 1},
  {&__pyx_n_s_sage_rings_integer_ring, __pyx_k_sage_rings_integer_ring, sizeof(__pyx_k_sage_rings_integer_ring), 0, 0, 1, 1},
  {&__pyx_kp_s_scal_prod_x_y_z_u_v_w_f, __pyx_k_scal_prod_x_y_z_u_v_w_f, sizeof(__pyx_k_scal_prod_x_y_z_u_v_w_f), 0, 0, 1, 0},
  {&__pyx_kp_s_scal_prod_x_y_z_u_v_w_f_after_al, __pyx_k_scal_prod_x_y_z_u_v_w_f_after_al, sizeof(__pyx_k_scal_prod_x_y_z_u_v_w_f_after_al), 0, 0, 1, 0},
  {&__pyx_n_s_scipy_misc, __pyx_k_scipy_misc, sizeof(__pyx_k_scipy_misc), 0, 0, 1, 1},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_set_axis_off, __pyx_k_set_axis_off, sizeof(__pyx_k_set_axis_off), 0, 0, 1, 1},
  {&__pyx_n_s_set_figheight, __pyx_k_set_figheight, sizeof(__pyx_k_set_figheight), 0, 0, 1, 1},
  {&__pyx_n_s_set_figwidth, __pyx_k_set_figwidth, sizeof(__pyx_k_set_figwidth), 0, 0, 1, 1},
  {&__pyx_n_s_set_title, __pyx_k_set_title, sizeof(__pyx_k_set_title), 0, 0, 1, 1},
  {&__pyx_n_s_set_xticklabels, __pyx_k_set_xticklabels, sizeof(__pyx_k_set_xticklabels), 0, 0, 1, 1},
  {&__pyx_n_s_set_yticklabels, __pyx_k_set_yticklabels, sizeof(__pyx_k_set_yticklabels), 0, 0, 1, 1},
  {&__pyx_n_s_set_zlabel, __pyx_k_set_zlabel, sizeof(__pyx_k_set_zlabel), 0, 0, 1, 1},
  {&__pyx_n_s_sharex, __pyx_k_sharex, sizeof(__pyx_k_sharex), 0, 0, 1, 1},
  {&__pyx_n_s_sharey, __pyx_k_sharey, sizeof(__pyx_k_sharey), 0, 0, 1, 1},
  {&__pyx_n_s_simplex_orbit_filtered_list, __pyx_k_simplex_orbit_filtered_list, sizeof(__pyx_k_simplex_orbit_filtered_list), 0, 0, 1, 1},
  {&__pyx_n_s_simplex_orbit_iterator, __pyx_k_simplex_orbit_iterator, sizeof(__pyx_k_simplex_orbit_iterator), 0, 0, 1, 1},
  {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  {&__pyx_n_s_slabbe, __pyx_k_slabbe, sizeof(__pyx_k_slabbe), 0, 0, 1, 1},
  {&__pyx_n_s_slabbe_mult_cont_frac, __pyx_k_slabbe_mult_cont_frac, sizeof(__pyx_k_slabbe_mult_cont_frac), 0, 0, 1, 1},
  {&__pyx_n_s_sort, __pyx_k_sort, sizeof(__pyx_k_sort), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_startswith, __pyx_k_startswith, sizeof(__pyx_k_startswith), 0, 0, 1, 1},
  {&__pyx_n_s_subplots, __pyx_k_subplots, sizeof(__pyx_k_subplots), 0, 0, 1, 1},
  {&__pyx_n_s_substitutions, __pyx_k_substitutions, sizeof(__pyx_k_substitutions), 0, 0, 1, 1},
  {&__pyx_n_s_sup, __pyx_k_sup, sizeof(__pyx_k_sup), 0, 0, 1, 1},
  {&__pyx_n_s_suptitle, __pyx_k_suptitle, sizeof(__pyx_k_suptitle), 0, 0, 1, 1},
  {&__pyx_n_s_teal, __pyx_k_teal, sizeof(__pyx_k_teal), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_test_coherence_locals_genexpr, __pyx_k_test_coherence_locals_genexpr, sizeof(__pyx_k_test_coherence_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_text, __pyx_k_text, sizeof(__pyx_k_text), 0, 0, 1, 1},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_tikzlibraries, __pyx_k_tikzlibraries, sizeof(__pyx_k_tikzlibraries), 0, 0, 1, 1},
  {&__pyx_n_s_title, __pyx_k_title, sizeof(__pyx_k_title), 0, 0, 1, 1},
  {&__pyx_n_s_toimage, __pyx_k_toimage, sizeof(__pyx_k_toimage), 0, 0, 1, 1},
  {&__pyx_n_s_top, __pyx_k_top, sizeof(__pyx_k_top), 0, 0, 1, 1},
  {&__pyx_n_s_transpose, __pyx_k_transpose, sizeof(__pyx_k_transpose), 0, 0, 1, 1},
  {&__pyx_n_s_u, __pyx_k_u, sizeof(__pyx_k_u), 0, 0, 1, 1},
  {&__pyx_kp_s_u_f_v_f_w_f, __pyx_k_u_f_v_f_w_f, sizeof(__pyx_k_u_f_v_f_w_f), 0, 0, 1, 0},
  {&__pyx_n_s_uint8, __pyx_k_uint8, sizeof(__pyx_k_uint8), 0, 0, 1, 1},
  {&__pyx_n_s_umax, __pyx_k_umax, sizeof(__pyx_k_umax), 0, 0, 1, 1},
  {&__pyx_n_s_umin, __pyx_k_umin, sizeof(__pyx_k_umin), 0, 0, 1, 1},
  {&__pyx_n_s_urange, __pyx_k_urange, sizeof(__pyx_k_urange), 0, 0, 1, 1},
  {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
  {&__pyx_n_s_va, __pyx_k_va, sizeof(__pyx_k_va), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_n_s_vector, __pyx_k_vector, sizeof(__pyx_k_vector), 0, 0, 1, 1},
  {&__pyx_n_s_verbose, __pyx_k_verbose, sizeof(__pyx_k_verbose), 0, 0, 1, 1},
  {&__pyx_n_s_violet, __pyx_k_violet, sizeof(__pyx_k_violet), 0, 0, 1, 1},
  {&__pyx_n_s_vmax, __pyx_k_vmax, sizeof(__pyx_k_vmax), 0, 0, 1, 1},
  {&__pyx_n_s_vmin, __pyx_k_vmin, sizeof(__pyx_k_vmin), 0, 0, 1, 1},
  {&__pyx_n_s_vrange, __pyx_k_vrange, sizeof(__pyx_k_vrange), 0, 0, 1, 1},
  {&__pyx_n_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1},
  {&__pyx_kp_s_when_ndivs_is_specified_you_must, __pyx_k_when_ndivs_is_specified_you_must, sizeof(__pyx_k_when_ndivs_is_specified_you_must), 0, 0, 1, 0},
  {&__pyx_n_s_white, __pyx_k_white, sizeof(__pyx_k_white), 0, 0, 1, 1},
  {&__pyx_n_s_word_to_matrix, __pyx_k_word_to_matrix, sizeof(__pyx_k_word_to_matrix), 0, 0, 1, 1},
  {&__pyx_n_s_words, __pyx_k_words, sizeof(__pyx_k_words), 0, 0, 1, 1},
  {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
  {&__pyx_kp_s_x_f_y_f_z_f, __pyx_k_x_f_y_f_z_f, sizeof(__pyx_k_x_f_y_f_z_f), 0, 0, 1, 0},
  {&__pyx_n_s_xmax, __pyx_k_xmax, sizeof(__pyx_k_xmax), 0, 0, 1, 1},
  {&__pyx_n_s_xmin, __pyx_k_xmin, sizeof(__pyx_k_xmin), 0, 0, 1, 1},
  {&__pyx_kp_s_xmin_1_1_xmax_1_1_ymin_6_ymax_1, __pyx_k_xmin_1_1_xmax_1_1_ymin_6_ymax_1, sizeof(__pyx_k_xmin_1_1_xmax_1_1_ymin_6_ymax_1), 0, 0, 1, 0},
  {&__pyx_n_s_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 0, 0, 1, 1},
  {&__pyx_kp_s_xx_small, __pyx_k_xx_small, sizeof(__pyx_k_xx_small), 0, 0, 1, 0},
  {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1},
  {&__pyx_n_s_yellow, __pyx_k_yellow, sizeof(__pyx_k_yellow), 0, 0, 1, 1},
  {&__pyx_n_s_ymax, __pyx_k_ymax, sizeof(__pyx_k_ymax), 0, 0, 1, 1},
  {&__pyx_n_s_ymin, __pyx_k_ymin, sizeof(__pyx_k_ymin), 0, 0, 1, 1},
  {&__pyx_n_s_yrange, __pyx_k_yrange, sizeof(__pyx_k_yrange), 0, 0, 1, 1},
  {&__pyx_n_s_z, __pyx_k_z, sizeof(__pyx_k_z), 0, 0, 1, 1},
  {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
  {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 138, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 240, __pyx_L1_error)
  __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) __PYX_ERR(0, 251, __pyx_L1_error)
  __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s_NotImplemented); if (!__pyx_builtin_NotImplemented) __PYX_ERR(0, 424, __pyx_L1_error)
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 460, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 526, __pyx_L1_error)
  __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_n_s_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(0, 1538, __pyx_L1_error)
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 1718, __pyx_L1_error)
  __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s_map); if (!__pyx_builtin_map) __PYX_ERR(0, 1826, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 14, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(1, 18, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "slabbe/mult_cont_frac.pyx":831
 * 
 *         if ndivs and float('inf') in [-xmin, -ymin, -umin, -vmin, xmax, ymax, umax, vmax]:
 *             raise ValueError("when ndivs is specified, you must provide a"             # <<<<<<<<<<<<<<
 *                     " value for xmin, xmax, ymin, ymax, umin, umax, vmin"
 *                     " and vmax")
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_when_ndivs_is_specified_you_must); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "slabbe/mult_cont_frac.pyx":1603
 *         L = prod(D[key] for key in reversed(keys))
 *         dual_sub = E1Star(L)
 *         cube = Patch([Face((1,0,0),1), Face((0,1,0),2), Face((0,0,1),3)])             # <<<<<<<<<<<<<<
 *         return dual_sub(cube)
 * 
 */
  __pyx_tuple__11 = PyTuple_Pack(3, __pyx_int_1, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);
  __pyx_tuple__12 = PyTuple_Pack(2, __pyx_tuple__11, __pyx_int_1); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);
  __pyx_tuple__13 = PyTuple_Pack(3, __pyx_int_0, __pyx_int_1, __pyx_int_0); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);
  __pyx_tuple__14 = PyTuple_Pack(2, __pyx_tuple__13, __pyx_int_2); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);
  __pyx_tuple__15 = PyTuple_Pack(3, __pyx_int_0, __pyx_int_0, __pyx_int_1); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);
  __pyx_tuple__16 = PyTuple_Pack(2, __pyx_tuple__15, __pyx_int_3); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "slabbe/mult_cont_frac.pyx":1639
 *         import matplotlib.pyplot as plt
 *         fig = plt.figure()
 *         ax = fig.add_subplot(111, projection='3d')             # <<<<<<<<<<<<<<
 *         ax.plot_wireframe(X, Y, Z, rstride=1, cstride=1)
 * 
 */
  __pyx_tuple__18 = PyTuple_Pack(1, __pyx_int_111); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 1639, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "slabbe/mult_cont_frac.pyx":1644
 *         ax.text(ndivs, 0, 0, "$(1,0,0)$", color='black', va='top', size=20)
 *         ax.text(0, ndivs, 0, "$(0,1,0)$", color='black', ha='left', size=20)
 *         ax.text(0, 0, 0, "$(0,0,1)$", color='black', ha='right', size=20)             # <<<<<<<<<<<<<<
 * 
 *         ax.set_xticklabels([])
 */
  __pyx_tuple__19 = PyTuple_Pack(4, __pyx_int_0, __pyx_int_0, __pyx_int_0, __pyx_kp_s_0_0_1); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 1644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "slabbe/mult_cont_frac.pyx":1648
 *         ax.set_xticklabels([])
 *         ax.set_yticklabels([])
 *         ax.set_zlabel('Frequency')             # <<<<<<<<<<<<<<
 * 
 *         title = "Density of an orbit for\n{} algorithm".format(self.name())
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_n_s_Frequency); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 1648, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "slabbe/mult_cont_frac.pyx":1686
 *         import matplotlib.pyplot as plt
 *         fig = plt.figure()
 *         ax = fig.add_subplot(111)             # <<<<<<<<<<<<<<
 *         CS = plt.contour(X, Y, Z, V)
 *         plt.clabel(CS, inline=1, fontsize=10)
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_int_111); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 1686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "slabbe/mult_cont_frac.pyx":1720
 *         c = dict(zip(domain_left.keys(), ['b','r','g','c','m','y','k']))
 * 
 *         def create_sub_plot(axx, D, title, norm):             # <<<<<<<<<<<<<<
 *             for key, value in D.iteritems():
 *                 value = D[key]
 */
  __pyx_tuple__22 = PyTuple_Pack(9, __pyx_n_s_axx, __pyx_n_s_D, __pyx_n_s_title, __pyx_n_s_norm, __pyx_n_s_key, __pyx_n_s_value, __pyx_n_s_X, __pyx_n_s_Y, __pyx_n_s_A); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 1720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);
  __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(4, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_slabbe_GitHgSvn_slabbe_0, __pyx_n_s_create_sub_plot, 1720, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 1720, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":1728
 *             axx.set_title(title)
 * 
 *         fig, (ax,bx,cx,dx) = plt.subplots(1,4,sharex=True,sharey=True)             # <<<<<<<<<<<<<<
 *         fig.set_figheight(2)
 *         fig.set_figwidth(12)
 */
  __pyx_tuple__24 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_4); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 1728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "slabbe/mult_cont_frac.pyx":1729
 * 
 *         fig, (ax,bx,cx,dx) = plt.subplots(1,4,sharex=True,sharey=True)
 *         fig.set_figheight(2)             # <<<<<<<<<<<<<<
 *         fig.set_figwidth(12)
 *         if axis_off:
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_int_2); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 1729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "slabbe/mult_cont_frac.pyx":1730
 *         fig, (ax,bx,cx,dx) = plt.subplots(1,4,sharex=True,sharey=True)
 *         fig.set_figheight(2)
 *         fig.set_figwidth(12)             # <<<<<<<<<<<<<<
 *         if axis_off:
 *             ax.set_axis_off()
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_int_12); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 1730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "slabbe/mult_cont_frac.pyx":1923
 *     def natural_extension_part_png(self, n_iterations, draw,
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     xrange=(-.866, .866),             # <<<<<<<<<<<<<<
 *                                     yrange=(-.5, 1.),
 *                                     urange=(-.866, .866),
 */
  __pyx_tuple__30 = PyTuple_Pack(2, __pyx_float_neg__866, __pyx_float__866); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 1923, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "slabbe/mult_cont_frac.pyx":1924
 *                                     norm_xyz='1', norm_uvw='1',
 *                                     xrange=(-.866, .866),
 *                                     yrange=(-.5, 1.),             # <<<<<<<<<<<<<<
 *                                     urange=(-.866, .866),
 *                                     vrange=(-.5, 1.),
 */
  __pyx_tuple__31 = PyTuple_Pack(2, __pyx_float_neg__5, __pyx_float_1_); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 1924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "slabbe/mult_cont_frac.pyx":1925
 *                                     xrange=(-.866, .866),
 *                                     yrange=(-.5, 1.),
 *                                     urange=(-.866, .866),             # <<<<<<<<<<<<<<
 *                                     vrange=(-.5, 1.),
 *                                     color_dict=None,
 */
  __pyx_tuple__32 = PyTuple_Pack(2, __pyx_float_neg__866, __pyx_float__866); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 1925, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "slabbe/mult_cont_frac.pyx":1926
 *                                     yrange=(-.5, 1.),
 *                                     urange=(-.866, .866),
 *                                     vrange=(-.5, 1.),             # <<<<<<<<<<<<<<
 *                                     color_dict=None,
 *                                     branch_order=None,
 */
  __pyx_tuple__33 = PyTuple_Pack(2, __pyx_float_neg__5, __pyx_float_1_); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 1926, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "slabbe/mult_cont_frac.pyx":2009
 *             color_dict = {}
 *             for key in branch_order:
 *                 color_dict[key] = [randint(0,255),randint(0,255),randint(0,255)]             # <<<<<<<<<<<<<<
 * 
 *         #http://stackoverflow.com/questions/434583/what-is-the-fastest-way-to-draw-an-image-from-discrete-pixel-values-in-python
 */
  __pyx_tuple__34 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_255); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 2009, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);
  __pyx_tuple__35 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_255); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 2009, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);
  __pyx_tuple__36 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_255); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 2009, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);

  /* "slabbe/mult_cont_frac.pyx":2019
 *         data += 255   # white as default color
 * 
 *         if draw.startswith('domain'):             # <<<<<<<<<<<<<<
 *             L.sort(key=lambda a:branch_order.index(a[5]))
 *         elif draw.startswith('image'):
 */
  __pyx_tuple__37 = PyTuple_Pack(1, __pyx_n_s_domain); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 2019, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);

  /* "slabbe/mult_cont_frac.pyx":2021
 *         if draw.startswith('domain'):
 *             L.sort(key=lambda a:branch_order.index(a[5]))
 *         elif draw.startswith('image'):             # <<<<<<<<<<<<<<
 *             L.sort(key=lambda a:branch_order.index(a[4]))
 *         else:
 */
  __pyx_tuple__38 = PyTuple_Pack(1, __pyx_n_s_image); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 2021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "slabbe/mult_cont_frac.pyx":2047
 *     def measure_evaluation(self, n_iterations, draw,
 *                                 norm_xyz='1', norm_uvw='1',
 *                                 xrange=(-.866, .866),             # <<<<<<<<<<<<<<
 *                                 yrange=(-.5, 1.),
 *                                 urange=(-.866, .866),
 */
  __pyx_tuple__39 = PyTuple_Pack(2, __pyx_float_neg__866, __pyx_float__866); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 2047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "slabbe/mult_cont_frac.pyx":2048
 *                                 norm_xyz='1', norm_uvw='1',
 *                                 xrange=(-.866, .866),
 *                                 yrange=(-.5, 1.),             # <<<<<<<<<<<<<<
 *                                 urange=(-.866, .866),
 *                                 vrange=(-.5, 1.),
 */
  __pyx_tuple__40 = PyTuple_Pack(2, __pyx_float_neg__5, __pyx_float_1_); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 2048, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "slabbe/mult_cont_frac.pyx":2049
 *                                 xrange=(-.866, .866),
 *                                 yrange=(-.5, 1.),
 *                                 urange=(-.866, .866),             # <<<<<<<<<<<<<<
 *                                 vrange=(-.5, 1.),
 *                                 ndivs=1024,
 */
  __pyx_tuple__41 = PyTuple_Pack(2, __pyx_float_neg__866, __pyx_float__866); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 2049, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "slabbe/mult_cont_frac.pyx":2050
 *                                 yrange=(-.5, 1.),
 *                                 urange=(-.866, .866),
 *                                 vrange=(-.5, 1.),             # <<<<<<<<<<<<<<
 *                                 ndivs=1024,
 *                                 verbose=False):
 */
  __pyx_tuple__42 = PyTuple_Pack(2, __pyx_float_neg__5, __pyx_float_1_); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 2050, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "slabbe/mult_cont_frac.pyx":2104
 *             ndivs=ndivs)
 * 
 *         if draw.endswith('left'):             # <<<<<<<<<<<<<<
 *             S = set((p[0],p[1]) for p in L)
 *         elif draw.endswith('right'):
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_n_s_left); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 2104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "slabbe/mult_cont_frac.pyx":2106
 *         if draw.endswith('left'):
 *             S = set((p[0],p[1]) for p in L)
 *         elif draw.endswith('right'):             # <<<<<<<<<<<<<<
 *             S = set((p[2],p[3]) for p in L)
 *         else:
 */
  __pyx_tuple__44 = PyTuple_Pack(1, __pyx_n_s_right); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 2106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "FromPyStructUtility":19
 *         value = obj['x']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'x'")             # <<<<<<<<<<<<<<
 *     result.x = value
 *     try:
 */
  __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_No_value_specified_for_struct_at); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(1, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "FromPyStructUtility":24
 *         value = obj['y']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'y'")             # <<<<<<<<<<<<<<
 *     result.y = value
 *     try:
 */
  __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_No_value_specified_for_struct_at_2); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(1, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);

  /* "FromPyStructUtility":29
 *         value = obj['z']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'z'")             # <<<<<<<<<<<<<<
 *     result.z = value
 *     try:
 */
  __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_No_value_specified_for_struct_at_3); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(1, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "FromPyStructUtility":34
 *         value = obj['u']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'u'")             # <<<<<<<<<<<<<<
 *     result.u = value
 *     try:
 */
  __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_No_value_specified_for_struct_at_4); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(1, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);

  /* "FromPyStructUtility":39
 *         value = obj['v']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'v'")             # <<<<<<<<<<<<<<
 *     result.v = value
 *     try:
 */
  __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_No_value_specified_for_struct_at_5); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);

  /* "FromPyStructUtility":44
 *         value = obj['w']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'w'")             # <<<<<<<<<<<<<<
 *     result.w = value
 *     try:
 */
  __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_No_value_specified_for_struct_at_6); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "FromPyStructUtility":49
 *         value = obj['branch']
 *     except KeyError:
 *         raise ValueError("No value specified for struct attribute 'branch'")             # <<<<<<<<<<<<<<
 *     result.branch = value
 *     return result
 */
  __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_s_No_value_specified_for_struct_at_7); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(1, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyList_Type_pop.type = (PyObject*)&PyList_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_float__5 = PyFloat_FromDouble(.5); if (unlikely(!__pyx_float__5)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float__8 = PyFloat_FromDouble(.8); if (unlikely(!__pyx_float__8)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_1_ = PyFloat_FromDouble(1.); if (unlikely(!__pyx_float_1_)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_0_2 = PyFloat_FromDouble(0.2); if (unlikely(!__pyx_float_0_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float__866 = PyFloat_FromDouble(.866); if (unlikely(!__pyx_float__866)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_0_0000001 = PyFloat_FromDouble(0.0000001); if (unlikely(!__pyx_float_0_0000001)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_neg__5 = PyFloat_FromDouble(-.5); if (unlikely(!__pyx_float_neg__5)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_neg__866 = PyFloat_FromDouble(-.866); if (unlikely(!__pyx_float_neg__866)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_20 = PyInt_FromLong(20); if (unlikely(!__pyx_int_20)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_111 = PyInt_FromLong(111); if (unlikely(!__pyx_int_111)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_123 = PyInt_FromLong(123); if (unlikely(!__pyx_int_123)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_132 = PyInt_FromLong(132); if (unlikely(!__pyx_int_132)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_213 = PyInt_FromLong(213); if (unlikely(!__pyx_int_213)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_231 = PyInt_FromLong(231); if (unlikely(!__pyx_int_231)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_255 = PyInt_FromLong(255); if (unlikely(!__pyx_int_255)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_312 = PyInt_FromLong(312); if (unlikely(!__pyx_int_312)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_321 = PyInt_FromLong(321); if (unlikely(!__pyx_int_321)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1024 = PyInt_FromLong(1024); if (unlikely(!__pyx_int_1024)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initmult_cont_frac(void); /*proto*/
PyMODINIT_FUNC initmult_cont_frac(void)
#else
PyMODINIT_FUNC PyInit_mult_cont_frac(void); /*proto*/
PyMODINIT_FUNC PyInit_mult_cont_frac(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  double __pyx_t_5;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_mult_cont_frac(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __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_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 PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("mult_cont_frac", __pyx_methods, __pyx_k_Multidimensional_Continued_Frac, 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)
  __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)
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  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_slabbe__mult_cont_frac) {
    if (PyObject_SetAttrString(__pyx_m, "__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, "slabbe.mult_cont_frac")) {
      if (unlikely(PyDict_SetItemString(modules, "slabbe.mult_cont_frac", __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 init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm = &__pyx_vtable_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_MCFAlgorithm.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_12MCFAlgorithm_call;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_MCFAlgorithm) < 0) __PYX_ERR(0, 127, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_MCFAlgorithm.tp_print = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_MCFAlgorithm, "__repr__"); if (unlikely(!wrapper)) __PYX_ERR(0, 127, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_6slabbe_14mult_cont_frac_12MCFAlgorithm_16__repr__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_6slabbe_14mult_cont_frac_12MCFAlgorithm_16__repr__.doc = __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_16__repr__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6slabbe_14mult_cont_frac_12MCFAlgorithm_16__repr__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_MCFAlgorithm, "__call__"); if (unlikely(!wrapper)) __PYX_ERR(0, 127, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_6slabbe_14mult_cont_frac_12MCFAlgorithm_18__call__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_6slabbe_14mult_cont_frac_12MCFAlgorithm_18__call__.doc = __pyx_doc_6slabbe_14mult_cont_frac_12MCFAlgorithm_18__call__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6slabbe_14mult_cont_frac_12MCFAlgorithm_18__call__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_MCFAlgorithm.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm) < 0) __PYX_ERR(0, 127, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "MCFAlgorithm", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_MCFAlgorithm) < 0) __PYX_ERR(0, 127, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm = &__pyx_type_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Brun = &__pyx_vtable_6slabbe_14mult_cont_frac_Brun;
  __pyx_vtable_6slabbe_14mult_cont_frac_Brun.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Brun.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_4Brun_call;
  __pyx_type_6slabbe_14mult_cont_frac_Brun.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Brun) < 0) __PYX_ERR(0, 2117, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Brun.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Brun.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Brun) < 0) __PYX_ERR(0, 2117, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Brun", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Brun) < 0) __PYX_ERR(0, 2117, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Brun = &__pyx_type_6slabbe_14mult_cont_frac_Brun;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Reverse = &__pyx_vtable_6slabbe_14mult_cont_frac_Reverse;
  __pyx_vtable_6slabbe_14mult_cont_frac_Reverse.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Reverse.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_7Reverse_call;
  __pyx_type_6slabbe_14mult_cont_frac_Reverse.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Reverse) < 0) __PYX_ERR(0, 2214, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Reverse.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Reverse.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Reverse) < 0) __PYX_ERR(0, 2214, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Reverse", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Reverse) < 0) __PYX_ERR(0, 2214, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Reverse = &__pyx_type_6slabbe_14mult_cont_frac_Reverse;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_ARP = &__pyx_vtable_6slabbe_14mult_cont_frac_ARP;
  __pyx_vtable_6slabbe_14mult_cont_frac_ARP.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_ARP.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_3ARP_call;
  __pyx_type_6slabbe_14mult_cont_frac_ARP.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_ARP) < 0) __PYX_ERR(0, 2312, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_ARP.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_ARP.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_ARP) < 0) __PYX_ERR(0, 2312, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "ARP", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_ARP) < 0) __PYX_ERR(0, 2312, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_ARP = &__pyx_type_6slabbe_14mult_cont_frac_ARP;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_ArnouxRauzy = &__pyx_vtable_6slabbe_14mult_cont_frac_ArnouxRauzy;
  __pyx_vtable_6slabbe_14mult_cont_frac_ArnouxRauzy.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_ArnouxRauzy.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_11ArnouxRauzy_call;
  __pyx_type_6slabbe_14mult_cont_frac_ArnouxRauzy.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_ArnouxRauzy) < 0) __PYX_ERR(0, 2424, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_ArnouxRauzy.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_ArnouxRauzy.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_ArnouxRauzy) < 0) __PYX_ERR(0, 2424, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "ArnouxRauzy", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_ArnouxRauzy) < 0) __PYX_ERR(0, 2424, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_ArnouxRauzy = &__pyx_type_6slabbe_14mult_cont_frac_ArnouxRauzy;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Poincare = &__pyx_vtable_6slabbe_14mult_cont_frac_Poincare;
  __pyx_vtable_6slabbe_14mult_cont_frac_Poincare.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Poincare.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_8Poincare_call;
  __pyx_type_6slabbe_14mult_cont_frac_Poincare.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Poincare) < 0) __PYX_ERR(0, 2510, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Poincare.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Poincare.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Poincare) < 0) __PYX_ERR(0, 2510, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Poincare", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Poincare) < 0) __PYX_ERR(0, 2510, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Poincare = &__pyx_type_6slabbe_14mult_cont_frac_Poincare;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Selmer = &__pyx_vtable_6slabbe_14mult_cont_frac_Selmer;
  __pyx_vtable_6slabbe_14mult_cont_frac_Selmer.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Selmer.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_6Selmer_call;
  __pyx_type_6slabbe_14mult_cont_frac_Selmer.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Selmer) < 0) __PYX_ERR(0, 2591, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Selmer.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Selmer.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Selmer) < 0) __PYX_ERR(0, 2591, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Selmer", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Selmer) < 0) __PYX_ERR(0, 2591, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Selmer = &__pyx_type_6slabbe_14mult_cont_frac_Selmer;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_FullySubtractive = &__pyx_vtable_6slabbe_14mult_cont_frac_FullySubtractive;
  __pyx_vtable_6slabbe_14mult_cont_frac_FullySubtractive.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_FullySubtractive.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_16FullySubtractive_call;
  __pyx_type_6slabbe_14mult_cont_frac_FullySubtractive.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_FullySubtractive) < 0) __PYX_ERR(0, 2688, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_FullySubtractive.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_FullySubtractive.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_FullySubtractive) < 0) __PYX_ERR(0, 2688, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "FullySubtractive", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_FullySubtractive) < 0) __PYX_ERR(0, 2688, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_FullySubtractive = &__pyx_type_6slabbe_14mult_cont_frac_FullySubtractive;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Cassaigne = &__pyx_vtable_6slabbe_14mult_cont_frac_Cassaigne;
  __pyx_vtable_6slabbe_14mult_cont_frac_Cassaigne.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Cassaigne.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_9Cassaigne_call;
  __pyx_type_6slabbe_14mult_cont_frac_Cassaigne.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Cassaigne) < 0) __PYX_ERR(0, 2774, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Cassaigne.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Cassaigne.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Cassaigne) < 0) __PYX_ERR(0, 2774, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Cassaigne", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Cassaigne) < 0) __PYX_ERR(0, 2774, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Cassaigne = &__pyx_type_6slabbe_14mult_cont_frac_Cassaigne;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Brun = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Brun;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Brun.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Brun.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_11Sorted_Brun_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_Brun.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_Brun) < 0) __PYX_ERR(0, 2855, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_Brun.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_Brun.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Brun) < 0) __PYX_ERR(0, 2855, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_Brun", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_Brun) < 0) __PYX_ERR(0, 2855, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_Brun = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_Brun;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_BrunMulti = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_BrunMulti;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_BrunMulti.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_BrunMulti.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_16Sorted_BrunMulti_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_BrunMulti.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_BrunMulti) < 0) __PYX_ERR(0, 2898, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_BrunMulti.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_BrunMulti.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_BrunMulti) < 0) __PYX_ERR(0, 2898, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_BrunMulti", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_BrunMulti) < 0) __PYX_ERR(0, 2898, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_BrunMulti = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_BrunMulti;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Selmer = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Selmer;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Selmer.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Selmer.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_13Sorted_Selmer_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_Selmer.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_Selmer) < 0) __PYX_ERR(0, 2921, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_Selmer.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_Selmer.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Selmer) < 0) __PYX_ERR(0, 2921, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_Selmer", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_Selmer) < 0) __PYX_ERR(0, 2921, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_Selmer = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_Selmer;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Meester = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Meester;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Meester.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Meester.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_14Sorted_Meester_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_Meester.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_Meester) < 0) __PYX_ERR(0, 2943, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_Meester.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_Meester.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Meester) < 0) __PYX_ERR(0, 2943, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_Meester", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_Meester) < 0) __PYX_ERR(0, 2943, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_Meester = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_Meester;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_18Sorted_ArnouxRauzy_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy) < 0) __PYX_ERR(0, 2967, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy) < 0) __PYX_ERR(0, 2967, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_ArnouxRauzy", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy) < 0) __PYX_ERR(0, 2967, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzy;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_23Sorted_ArnouxRauzyMulti_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti) < 0) __PYX_ERR(0, 3009, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti) < 0) __PYX_ERR(0, 3009, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_ArnouxRauzyMulti", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti) < 0) __PYX_ERR(0, 3009, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_ArnouxRauzyMulti;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARP = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARP;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARP.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARP.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_10Sorted_ARP_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARP.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARP) < 0) __PYX_ERR(0, 3024, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARP.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARP.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARP) < 0) __PYX_ERR(0, 3024, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_ARP", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARP) < 0) __PYX_ERR(0, 3024, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ARP = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARP;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARPMulti = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARPMulti;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARPMulti.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARPMulti.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_15Sorted_ARPMulti_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARPMulti.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARPMulti) < 0) __PYX_ERR(0, 3060, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARPMulti.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARPMulti.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARPMulti) < 0) __PYX_ERR(0, 3060, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_ARPMulti", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARPMulti) < 0) __PYX_ERR(0, 3060, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ARPMulti = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARPMulti;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Poincare = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Poincare;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Poincare.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Poincare.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_15Sorted_Poincare_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_Poincare.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_Poincare) < 0) __PYX_ERR(0, 3083, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_Poincare.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_Poincare.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Poincare) < 0) __PYX_ERR(0, 3083, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_Poincare", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_Poincare) < 0) __PYX_ERR(0, 3083, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_Poincare = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_Poincare;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARrevert = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARrevert;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARrevert.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARrevert.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_15Sorted_ARrevert_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevert.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevert) < 0) __PYX_ERR(0, 3124, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevert.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevert.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARrevert) < 0) __PYX_ERR(0, 3124, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_ARrevert", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevert) < 0) __PYX_ERR(0, 3124, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ARrevert = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevert;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_20Sorted_ARrevertMulti_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti) < 0) __PYX_ERR(0, 3178, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti) < 0) __PYX_ERR(0, 3178, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_ARrevertMulti", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti) < 0) __PYX_ERR(0, 3178, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARrevertMulti;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARMonteil = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARMonteil;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARMonteil.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_ARMonteil.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_16Sorted_ARMonteil_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARMonteil.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARMonteil) < 0) __PYX_ERR(0, 3233, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_ARMonteil.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARMonteil.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_ARMonteil) < 0) __PYX_ERR(0, 3233, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_ARMonteil", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARMonteil) < 0) __PYX_ERR(0, 3233, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_ARMonteil = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_ARMonteil;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Delaunay = &__pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Delaunay;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Delaunay.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_Sorted_Delaunay.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_15Sorted_Delaunay_call;
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_Delaunay.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_Sorted_Delaunay) < 0) __PYX_ERR(0, 3273, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_Sorted_Delaunay.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_Sorted_Delaunay.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_Sorted_Delaunay) < 0) __PYX_ERR(0, 3273, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Sorted_Delaunay", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_Sorted_Delaunay) < 0) __PYX_ERR(0, 3273, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_Sorted_Delaunay = &__pyx_type_6slabbe_14mult_cont_frac_Sorted_Delaunay;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerron = &__pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerron;
  __pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerron.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerron.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_12JacobiPerron_call;
  __pyx_type_6slabbe_14mult_cont_frac_JacobiPerron.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_JacobiPerron) < 0) __PYX_ERR(0, 3306, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_JacobiPerron.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_JacobiPerron.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerron) < 0) __PYX_ERR(0, 3306, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "JacobiPerron", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_JacobiPerron) < 0) __PYX_ERR(0, 3306, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_JacobiPerron = &__pyx_type_6slabbe_14mult_cont_frac_JacobiPerron;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerronAdditif = &__pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerronAdditif;
  __pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerronAdditif.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerronAdditif.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_19JacobiPerronAdditif_call;
  __pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditif.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditif) < 0) __PYX_ERR(0, 3349, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditif.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditif.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerronAdditif) < 0) __PYX_ERR(0, 3349, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "JacobiPerronAdditif", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditif) < 0) __PYX_ERR(0, 3349, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_JacobiPerronAdditif = &__pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditif;
  __pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 = &__pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2;
  __pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2.__pyx_base = *__pyx_vtabptr_6slabbe_14mult_cont_frac_MCFAlgorithm;
  __pyx_vtable_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2.__pyx_base.call = (struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d (*)(struct __pyx_obj_6slabbe_14mult_cont_frac_MCFAlgorithm *, struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d))__pyx_f_6slabbe_14mult_cont_frac_21JacobiPerronAdditifv2_call;
  __pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2.tp_base = __pyx_ptype_6slabbe_14mult_cont_frac_MCFAlgorithm;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2) < 0) __PYX_ERR(0, 3395, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2.tp_dict, __pyx_vtabptr_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2) < 0) __PYX_ERR(0, 3395, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "JacobiPerronAdditifv2", (PyObject *)&__pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2) < 0) __PYX_ERR(0, 3395, __pyx_L1_error)
  __pyx_ptype_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2 = &__pyx_type_6slabbe_14mult_cont_frac_JacobiPerronAdditifv2;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence) < 0) __PYX_ERR(0, 274, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct___test_coherence;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr) < 0) __PYX_ERR(0, 291, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_1_genexpr;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator) < 0) __PYX_ERR(0, 466, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_2_coding_iterator;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator) < 0) __PYX_ERR(0, 530, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_3_simplex_orbit_iterator;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_4_cone_orbit_iterator;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word) < 0) __PYX_ERR(0, 1425, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_5_s_adic_word;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr) < 0) __PYX_ERR(0, 1505, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_6_genexpr;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr) < 0) __PYX_ERR(0, 1511, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_7_genexpr;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch) < 0) __PYX_ERR(0, 1579, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_8_e_one_star_patch;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr) < 0) __PYX_ERR(0, 1601, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_9_genexpr;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot) < 0) __PYX_ERR(0, 1695, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_10_natural_extension_plot;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png) < 0) __PYX_ERR(0, 1921, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_11_natural_extension_part_png;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation) < 0) __PYX_ERR(0, 2045, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_12_measure_evaluation;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr) < 0) __PYX_ERR(0, 2105, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_13_genexpr;
  if (PyType_Ready(&__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr) < 0) __PYX_ERR(0, 2107, __pyx_L1_error)
  __pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr.tp_print = 0;
  __pyx_ptype_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr = &__pyx_type_6slabbe_14mult_cont_frac___pyx_scope_struct_14_genexpr;
  /*--- Type import code ---*/
  /*--- Variable import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("cysignals.signals"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "cysigs", (void **)&__pyx_vp_9cysignals_7signals_cysigs, "cysigs_t") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*--- Function import code ---*/
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "slabbe/mult_cont_frac.pyx":108
 * #                  http://www.gnu.org/licenses/
 * #*****************************************************************************
 * from sage.misc.prandom import random             # <<<<<<<<<<<<<<
 * 
 * include "cysignals/signals.pxi"   # ctrl-c interrupt block support
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_random);
  __Pyx_GIVEREF(__pyx_n_s_random);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_random);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_sage_misc_prandom, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __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_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_random, __pyx_t_2) < 0) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "../../Applications/sage-git/local/lib/python2.7/site-packages/cysignals/signals.pxi":24
 * # This *must* be done for every module using interrupt functions
 * # otherwise you will get segmentation faults.
 * import_cysignals__signals()             # <<<<<<<<<<<<<<
 */
  __pyx_t_4 = import_cysignals__signals(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(2, 24, __pyx_L1_error)

  /* "slabbe/mult_cont_frac.pyx":121
 *     int branch
 * 
 * cdef double SQRT3SUR2 = 0.866025403784439             # <<<<<<<<<<<<<<
 * 
 * PGF_COLORS = ["red", "green", "blue", "cyan", "brown", "gray", "orange", "pink",
 */
  __pyx_v_6slabbe_14mult_cont_frac_SQRT3SUR2 = 0.866025403784439;

  /* "slabbe/mult_cont_frac.pyx":123
 * cdef double SQRT3SUR2 = 0.866025403784439
 * 
 * PGF_COLORS = ["red", "green", "blue", "cyan", "brown", "gray", "orange", "pink",             # <<<<<<<<<<<<<<
 * "yellow", "black", "white", "darkgray", "lightgray",
 * "lime", "olive", "magenta", "purple", "teal", "violet"]
 */
  __pyx_t_3 = PyList_New(19); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_red);
  __Pyx_GIVEREF(__pyx_n_s_red);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_red);
  __Pyx_INCREF(__pyx_n_s_green);
  __Pyx_GIVEREF(__pyx_n_s_green);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_green);
  __Pyx_INCREF(__pyx_n_s_blue);
  __Pyx_GIVEREF(__pyx_n_s_blue);
  PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_blue);
  __Pyx_INCREF(__pyx_n_s_cyan);
  __Pyx_GIVEREF(__pyx_n_s_cyan);
  PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_cyan);
  __Pyx_INCREF(__pyx_n_s_brown);
  __Pyx_GIVEREF(__pyx_n_s_brown);
  PyList_SET_ITEM(__pyx_t_3, 4, __pyx_n_s_brown);
  __Pyx_INCREF(__pyx_n_s_gray);
  __Pyx_GIVEREF(__pyx_n_s_gray);
  PyList_SET_ITEM(__pyx_t_3, 5, __pyx_n_s_gray);
  __Pyx_INCREF(__pyx_n_s_orange);
  __Pyx_GIVEREF(__pyx_n_s_orange);
  PyList_SET_ITEM(__pyx_t_3, 6, __pyx_n_s_orange);
  __Pyx_INCREF(__pyx_n_s_pink);
  __Pyx_GIVEREF(__pyx_n_s_pink);
  PyList_SET_ITEM(__pyx_t_3, 7, __pyx_n_s_pink);
  __Pyx_INCREF(__pyx_n_s_yellow);
  __Pyx_GIVEREF(__pyx_n_s_yellow);
  PyList_SET_ITEM(__pyx_t_3, 8, __pyx_n_s_yellow);
  __Pyx_INCREF(__pyx_n_s_black);
  __Pyx_GIVEREF(__pyx_n_s_black);
  PyList_SET_ITEM(__pyx_t_3, 9, __pyx_n_s_black);
  __Pyx_INCREF(__pyx_n_s_white);
  __Pyx_GIVEREF(__pyx_n_s_white);
  PyList_SET_ITEM(__pyx_t_3, 10, __pyx_n_s_white);
  __Pyx_INCREF(__pyx_n_s_darkgray);
  __Pyx_GIVEREF(__pyx_n_s_darkgray);
  PyList_SET_ITEM(__pyx_t_3, 11, __pyx_n_s_darkgray);
  __Pyx_INCREF(__pyx_n_s_lightgray);
  __Pyx_GIVEREF(__pyx_n_s_lightgray);
  PyList_SET_ITEM(__pyx_t_3, 12, __pyx_n_s_lightgray);
  __Pyx_INCREF(__pyx_n_s_lime);
  __Pyx_GIVEREF(__pyx_n_s_lime);
  PyList_SET_ITEM(__pyx_t_3, 13, __pyx_n_s_lime);
  __Pyx_INCREF(__pyx_n_s_olive);
  __Pyx_GIVEREF(__pyx_n_s_olive);
  PyList_SET_ITEM(__pyx_t_3, 14, __pyx_n_s_olive);
  __Pyx_INCREF(__pyx_n_s_magenta);
  __Pyx_GIVEREF(__pyx_n_s_magenta);
  PyList_SET_ITEM(__pyx_t_3, 15, __pyx_n_s_magenta);
  __Pyx_INCREF(__pyx_n_s_purple);
  __Pyx_GIVEREF(__pyx_n_s_purple);
  PyList_SET_ITEM(__pyx_t_3, 16, __pyx_n_s_purple);
  __Pyx_INCREF(__pyx_n_s_teal);
  __Pyx_GIVEREF(__pyx_n_s_teal);
  PyList_SET_ITEM(__pyx_t_3, 17, __pyx_n_s_teal);
  __Pyx_INCREF(__pyx_n_s_violet);
  __Pyx_GIVEREF(__pyx_n_s_violet);
  PyList_SET_ITEM(__pyx_t_3, 18, __pyx_n_s_violet);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_PGF_COLORS, __pyx_t_3) < 0) __PYX_ERR(0, 123, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "slabbe/mult_cont_frac.pyx":725
 *     def simplex_orbit_filtered_list(self, start=None, int n_iterations=100,
 *             norm_xyz='1', norm_uvw='1',
 *             double xmin=-float('inf'), double xmax=float('inf'),             # <<<<<<<<<<<<<<
 *             double ymin=-float('inf'), double ymax=float('inf'),
 *             double umin=-float('inf'), double umax=float('inf'),
 */
  __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 725, __pyx_L1_error)
  __pyx_k__2 = (-__pyx_t_5);
  __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 725, __pyx_L1_error)
  __pyx_k__3 = __pyx_t_5;

  /* "slabbe/mult_cont_frac.pyx":726
 *             norm_xyz='1', norm_uvw='1',
 *             double xmin=-float('inf'), double xmax=float('inf'),
 *             double ymin=-float('inf'), double ymax=float('inf'),             # <<<<<<<<<<<<<<
 *             double umin=-float('inf'), double umax=float('inf'),
 *             double vmin=-float('inf'), double vmax=float('inf'),
 */
  __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 726, __pyx_L1_error)
  __pyx_k__4 = (-__pyx_t_5);
  __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 726, __pyx_L1_error)
  __pyx_k__5 = __pyx_t_5;

  /* "slabbe/mult_cont_frac.pyx":727
 *             double xmin=-float('inf'), double xmax=float('inf'),
 *             double ymin=-float('inf'), double ymax=float('inf'),
 *             double umin=-float('inf'), double umax=float('inf'),             # <<<<<<<<<<<<<<
 *             double vmin=-float('inf'), double vmax=float('inf'),
 *             int ndivs=0):
 */
  __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 727, __pyx_L1_error)
  __pyx_k__6 = (-__pyx_t_5);
  __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 727, __pyx_L1_error)
  __pyx_k__7 = __pyx_t_5;

  /* "slabbe/mult_cont_frac.pyx":728
 *             double ymin=-float('inf'), double ymax=float('inf'),
 *             double umin=-float('inf'), double umax=float('inf'),
 *             double vmin=-float('inf'), double vmax=float('inf'),             # <<<<<<<<<<<<<<
 *             int ndivs=0):
 *         r"""
 */
  __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 728, __pyx_L1_error)
  __pyx_k__8 = (-__pyx_t_5);
  __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 728, __pyx_L1_error)
  __pyx_k__9 = __pyx_t_5;

  /* "slabbe/mult_cont_frac.pyx":1
 * # -*- coding: utf-8 -*-             # <<<<<<<<<<<<<<
 * r"""
 * Multidimensional Continued Fraction Algorithms
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "FromPyStructUtility":11
 * 
 * @cname("__pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d")
 * cdef PairPoint3d __pyx_convert__from_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(obj) except *:             # <<<<<<<<<<<<<<
 *     cdef PairPoint3d result
 *     if not PyMapping_Check(obj):
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init slabbe.mult_cont_frac", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init slabbe.mult_cont_frac");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* 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_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
#if PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* RaiseDoubleKeywords */
  static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
  static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* RaiseArgTupleInvalid */
  static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* GetModuleGlobalName */
  static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

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

/* PyObjectCallMethO */
    #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
    #if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *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

/* PyObjectCallNoArg */
      #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* SaveResetException */
        #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    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;
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* PyErrExceptionMatches */
        #if CYTHON_COMPILING_IN_CPYTHON
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;
    return PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetException */
        #if CYTHON_COMPILING_IN_CPYTHON
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_COMPILING_IN_CPYTHON
    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_COMPILING_IN_CPYTHON
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* IterFinish */
          static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* PyObjectCallMethod0 */
          static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
    PyObject *method, *result = NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *function = PyMethod_GET_FUNCTION(method);
            result = __Pyx_PyObject_CallOneArg(function, self);
            Py_DECREF(method);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallNoArg(method);
    Py_DECREF(method);
bad:
    return result;
}

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

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

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

/* RaiseNoneIterError */
          static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* UnpackTupleError */
          static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
    if (t == Py_None) {
      __Pyx_RaiseNoneNotIterableError();
    } else if (PyTuple_GET_SIZE(t) < index) {
      __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
    } else {
      __Pyx_RaiseTooManyValuesError(index);
    }
}

/* UnpackTuple2 */
          static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
                                             int is_tuple, int has_known_size, int decref_tuple) {
    Py_ssize_t index;
    PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
    if (!is_tuple && unlikely(!PyTuple_Check(tuple))) {
        iternextfunc iternext;
        iter = PyObject_GetIter(tuple);
        if (unlikely(!iter)) goto bad;
        if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
        iternext = Py_TYPE(iter)->tp_iternext;
        value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
        value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
        if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
        Py_DECREF(iter);
    } else {
        if (!has_known_size && unlikely(PyTuple_GET_SIZE(tuple) != 2)) {
            __Pyx_UnpackTupleError(tuple, 2);
            goto bad;
        }
#if CYTHON_COMPILING_IN_PYPY
        value1 = PySequence_ITEM(tuple, 0);
        if (unlikely(!value1)) goto bad;
        value2 = PySequence_ITEM(tuple, 1);
        if (unlikely(!value2)) goto bad;
#else
        value1 = PyTuple_GET_ITEM(tuple, 0);
        value2 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(value1);
        Py_INCREF(value2);
#endif
        if (decref_tuple) { Py_DECREF(tuple); }
    }
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
unpacking_failed:
    if (!has_known_size && __Pyx_IterFinish() == 0)
        __Pyx_RaiseNeedMoreValuesError(index);
bad:
    Py_XDECREF(iter);
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
}

/* dict_iter */
          static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_source_is_dict) {
    is_dict = is_dict || likely(PyDict_CheckExact(iterable));
    *p_source_is_dict = is_dict;
#if !CYTHON_COMPILING_IN_PYPY
    if (is_dict) {
        *p_orig_length = PyDict_Size(iterable);
        Py_INCREF(iterable);
        return iterable;
    }
#endif
    *p_orig_length = 0;
    if (method_name) {
        PyObject* iter;
        iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
        if (!iterable)
            return NULL;
#if !CYTHON_COMPILING_IN_PYPY
        if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
            return iterable;
#endif
        iter = PyObject_GetIter(iterable);
        Py_DECREF(iterable);
        return iter;
    }
    return PyObject_GetIter(iterable);
}
static CYTHON_INLINE int __Pyx_dict_iter_next(
        PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
        PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
    PyObject* next_item;
#if !CYTHON_COMPILING_IN_PYPY
    if (source_is_dict) {
        PyObject *key, *value;
        if (unlikely(orig_length != PyDict_Size(iter_obj))) {
            PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
            return -1;
        }
        if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
            return 0;
        }
        if (pitem) {
            PyObject* tuple = PyTuple_New(2);
            if (unlikely(!tuple)) {
                return -1;
            }
            Py_INCREF(key);
            Py_INCREF(value);
            PyTuple_SET_ITEM(tuple, 0, key);
            PyTuple_SET_ITEM(tuple, 1, value);
            *pitem = tuple;
        } else {
            if (pkey) {
                Py_INCREF(key);
                *pkey = key;
            }
            if (pvalue) {
                Py_INCREF(value);
                *pvalue = value;
            }
        }
        return 1;
    } else if (PyTuple_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyTuple_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else if (PyList_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyList_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else
#endif
    {
        next_item = PyIter_Next(iter_obj);
        if (unlikely(!next_item)) {
            return __Pyx_IterFinish();
        }
    }
    if (pitem) {
        *pitem = next_item;
    } else if (pkey && pvalue) {
        if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
            return -1;
    } else if (pkey) {
        *pkey = next_item;
    } else {
        *pvalue = next_item;
    }
    return 1;
}

/* None */
          static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

/* 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_VERSION_HEX < 0x03030000
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

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

/* PyIntBinop */
          #if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) {
            Py_RETURN_TRUE;
        } else {
            Py_RETURN_FALSE;
        }
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                #if PyLong_SHIFT < 30 && PyLong_SHIFT != 15
                default: return PyLong_Type.tp_richcompare(op1, op2, Py_EQ);
                #else
                default: Py_RETURN_FALSE;
                #endif
            }
        }
            if (a == b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            if ((double)a == (double)b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    return PyObject_RichCompare(op1, op2, Py_EQ);
}
#endif

/* GetAttr */
          static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* IterNext */
          static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
    PyObject* next;
    iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
#if CYTHON_COMPILING_IN_CPYTHON
    if (unlikely(!iternext)) {
#else
    if (unlikely(!iternext) || unlikely(!PyIter_Check(iterator))) {
#endif
        PyErr_Format(PyExc_TypeError,
            "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
        return NULL;
    }
    next = iternext(iterator);
    if (likely(next))
        return next;
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_VERSION_HEX >= 0x02070000
    if (unlikely(iternext == &_PyObject_NextNotImplemented))
        return NULL;
#endif
#endif
    if (defval) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
            if (unlikely(exc_type != PyExc_StopIteration) &&
                    !PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))
                return NULL;
            PyErr_Clear();
        }
        Py_INCREF(defval);
        return defval;
    }
    if (!PyErr_Occurred())
        PyErr_SetNone(PyExc_StopIteration);
    return NULL;
}

/* GetItemInt */
            static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* BytesEquals */
            static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* UnicodeEquals */
            static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

/* pyobject_as_double */
            static double __Pyx__PyObject_AsDouble(PyObject* obj) {
    PyObject* float_value;
#if CYTHON_COMPILING_IN_PYPY
    float_value = PyNumber_Float(obj);  if (0) goto bad;
#else
    PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
    if (likely(nb) && likely(nb->nb_float)) {
        float_value = nb->nb_float(obj);
        if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) {
            PyErr_Format(PyExc_TypeError,
                "__float__ returned non-float (type %.200s)",
                Py_TYPE(float_value)->tp_name);
            Py_DECREF(float_value);
            goto bad;
        }
    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
#if PY_MAJOR_VERSION >= 3
        float_value = PyFloat_FromString(obj);
#else
        float_value = PyFloat_FromString(obj, 0);
#endif
    } else {
        PyObject* args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        PyTuple_SET_ITEM(args, 0, obj);
        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
        PyTuple_SET_ITEM(args, 0, 0);
        Py_DECREF(args);
    }
#endif
    if (likely(float_value)) {
        double value = PyFloat_AS_DOUBLE(float_value);
        Py_DECREF(float_value);
        return value;
    }
bad:
    return (double)-1;
}

/* ArgTypeTest */
            static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
}
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (likely(Py_TYPE(obj) == type)) return 1;
        #if PY_MAJOR_VERSION == 2
        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(PyObject_TypeCheck(obj, type))) return 1;
    }
    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
    return 0;
}

/* PyObjectCallMethod1 */
            static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method, *result = NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *args;
            PyObject *function = PyMethod_GET_FUNCTION(method);
            args = PyTuple_New(2);
            if (unlikely(!args)) goto bad;
            Py_INCREF(self);
            PyTuple_SET_ITEM(args, 0, self);
            Py_INCREF(arg);
            PyTuple_SET_ITEM(args, 1, arg);
            Py_INCREF(function);
            Py_DECREF(method); method = NULL;
            result = __Pyx_PyObject_Call(function, args, NULL);
            Py_DECREF(args);
            Py_DECREF(function);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallOneArg(method, arg);
bad:
    Py_XDECREF(method);
    return result;
}

/* append */
            static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

/* PyFloatBinop */
            #if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyFloat_SubtractObjC(PyObject *op1, PyObject *op2, double floatval, CYTHON_UNUSED int inplace) {
    const double b = floatval;
    double a, result;
    if (likely(PyFloat_CheckExact(op1))) {
        a = PyFloat_AS_DOUBLE(op1);
    } else
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        a = (double) PyInt_AS_LONG(op1);
    } else
    #endif
    if (likely(PyLong_CheckExact(op1))) {
        #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        switch (size) {
            case  0: a = 0.0; break;
            case -1: a = -(double) digits[0]; break;
            case  1: a = (double) digits[0]; break;
            case -2:
            case 2:
                if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) {
                    a = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (a < (double) (1L<<53))) {
                        if (size == -2)
                            a = -a;
                        break;
                    }
                }
            case -3:
            case 3:
                if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) {
                    a = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (a < (double) (1L<<53))) {
                        if (size == -3)
                            a = -a;
                        break;
                    }
                }
            case -4:
            case 4:
                if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) {
                    a = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (a < (double) (1L<<53))) {
                        if (size == -4)
                            a = -a;
                        break;
                    }
                }
            default:
        #else
        {
        #endif
            a = PyLong_AsDouble(op1);
            if (unlikely(a == -1.0 && PyErr_Occurred())) return NULL;
        }
    } else {
        return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
    }
        PyFPE_START_PROTECT("subtract", return NULL)
        result = a - b;
        PyFPE_END_PROTECT(result)
        return PyFloat_FromDouble(result);
}
#endif

/* None */
              static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

/* UnpackUnboundCMethod */
              static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(PyObject_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_O | METH_NOARGS);
    }
#endif
    return 0;
}

/* CallUnboundCMethod0 */
              static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    args = PyTuple_New(1);
    if (unlikely(!args)) goto bad;
    Py_INCREF(self);
    PyTuple_SET_ITEM(args, 0, self);
#else
    args = PyTuple_Pack(1, self);
    if (unlikely(!args)) goto bad;
#endif
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    Py_DECREF(args);
bad:
    return result;
}

/* pop */
              static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (Py_TYPE(L) == &PySet_Type) {
        return PySet_Pop(L);
    }
#endif
    return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop);
}
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
    if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
        Py_SIZE(L) -= 1;
        return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
    }
    return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyList_Type_pop, L);
}
#endif

/* PyIntBinop */
              #if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* None */
              static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
    Py_ssize_t q = a / b;
    Py_ssize_t r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

/* FetchCommonType */
              static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* CythonFunction */
              static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_COMPILING_IN_CPYTHON
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
#if CYTHON_COMPILING_IN_PYPY
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    PyObject *self = f->m_self;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0 = PySequence_ITEM(arg, 0);
                if (unlikely(!arg0)) return NULL;
                result = (*meth)(self, arg0);
                Py_DECREF(arg0);
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
#else
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
	return PyCFunction_Call(func, arg, kw);
}
#endif
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_Call,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
#if !CYTHON_COMPILING_IN_PYPY
    __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
#endif
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (__pyx_CyFunctionType == NULL) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (!m->defaults)
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* StringJoin */
                  #if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
    return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
}
#endif

/* SliceObject */
                  static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_COMPILING_IN_CPYTHON
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

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

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

/* 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;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        __pyx_d,      /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* 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_int(int value) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
                  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
    const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(unsigned int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(unsigned int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
                                     little, !is_unsigned);
    }
}

static PyObject* __pyx_convert__to_py_struct____pyx_t_6slabbe_14mult_cont_frac_PairPoint3d(struct __pyx_t_6slabbe_14mult_cont_frac_PairPoint3d s) {
                    PyObject* res;
                    PyObject* member;
                    res = PyDict_New(); if (unlikely(!res)) return NULL;
                    member = PyFloat_FromDouble(s.x); if (unlikely(!member)) goto bad;
                    if (unlikely(PyDict_SetItem(res, __pyx_n_s_x, member) < 0)) goto bad;
                    Py_DECREF(member);
                    member = PyFloat_FromDouble(s.y); if (unlikely(!member)) goto bad;
                    if (unlikely(PyDict_SetItem(res, __pyx_n_s_y, member) < 0)) goto bad;
                    Py_DECREF(member);
                    member = PyFloat_FromDouble(s.z); if (unlikely(!member)) goto bad;
                    if (unlikely(PyDict_SetItem(res, __pyx_n_s_z, member) < 0)) goto bad;
                    Py_DECREF(member);
                    member = PyFloat_FromDouble(s.u); if (unlikely(!member)) goto bad;
                    if (unlikely(PyDict_SetItem(res, __pyx_n_s_u, member) < 0)) goto bad;
                    Py_DECREF(member);
                    member = PyFloat_FromDouble(s.v); if (unlikely(!member)) goto bad;
                    if (unlikely(PyDict_SetItem(res, __pyx_n_s_v, member) < 0)) goto bad;
                    Py_DECREF(member);
                    member = PyFloat_FromDouble(s.w); if (unlikely(!member)) goto bad;
                    if (unlikely(PyDict_SetItem(res, __pyx_n_s_w, member) < 0)) goto bad;
                    Py_DECREF(member);
                    member = __Pyx_PyInt_From_int(s.branch); if (unlikely(!member)) goto bad;
                    if (unlikely(PyDict_SetItem(res, __pyx_n_s_branch, member) < 0)) goto bad;
                    Py_DECREF(member);
                    return res;
                    bad:
                    Py_XDECREF(member);
                    Py_DECREF(res);
                    return NULL;
                  }
                  /* CIntToPy */
                  static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* Print */
                  #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
static PyObject *__Pyx_GetStdout(void) {
    PyObject *f = PySys_GetObject((char *)"stdout");
    if (!f) {
        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
    }
    return f;
}
static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) {
    int i;
    if (!f) {
        if (!(f = __Pyx_GetStdout()))
            return -1;
    }
    Py_INCREF(f);
    for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
        PyObject* v;
        if (PyFile_SoftSpace(f, 1)) {
            if (PyFile_WriteString(" ", f) < 0)
                goto error;
        }
        v = PyTuple_GET_ITEM(arg_tuple, i);
        if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
            goto error;
        if (PyString_Check(v)) {
            char *s = PyString_AsString(v);
            Py_ssize_t len = PyString_Size(v);
            if (len > 0) {
                switch (s[len-1]) {
                    case ' ': break;
                    case '\f': case '\r': case '\n': case '\t': case '\v':
                        PyFile_SoftSpace(f, 0);
                        break;
                    default:  break;
                }
            }
        }
    }
    if (newline) {
        if (PyFile_WriteString("\n", f) < 0)
            goto error;
        PyFile_SoftSpace(f, 0);
    }
    Py_DECREF(f);
    return 0;
error:
    Py_DECREF(f);
    return -1;
}
#else
static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
    PyObject* kwargs = 0;
    PyObject* result = 0;
    PyObject* end_string;
    if (unlikely(!__pyx_print)) {
        __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print);
        if (!__pyx_print)
            return -1;
    }
    if (stream) {
        kwargs = PyDict_New();
        if (unlikely(!kwargs))
            return -1;
        if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0))
            goto bad;
        if (!newline) {
            end_string = PyUnicode_FromStringAndSize(" ", 1);
            if (unlikely(!end_string))
                goto bad;
            if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) {
                Py_DECREF(end_string);
                goto bad;
            }
            Py_DECREF(end_string);
        }
    } else if (!newline) {
        if (unlikely(!__pyx_print_kwargs)) {
            __pyx_print_kwargs = PyDict_New();
            if (unlikely(!__pyx_print_kwargs))
                return -1;
            end_string = PyUnicode_FromStringAndSize(" ", 1);
            if (unlikely(!end_string))
                return -1;
            if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) {
                Py_DECREF(end_string);
                return -1;
            }
            Py_DECREF(end_string);
        }
        kwargs = __pyx_print_kwargs;
    }
    result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
    if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs))
        Py_DECREF(kwargs);
    if (!result)
        return -1;
    Py_DECREF(result);
    return 0;
bad:
    if (kwargs != __pyx_print_kwargs)
        Py_XDECREF(kwargs);
    return -1;
}
#endif

/* CIntFromPy */
                  static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } 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))
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_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;
}

/* PrintOne */
                  #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
    if (!f) {
        if (!(f = __Pyx_GetStdout()))
            return -1;
    }
    Py_INCREF(f);
    if (PyFile_SoftSpace(f, 0)) {
        if (PyFile_WriteString(" ", f) < 0)
            goto error;
    }
    if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
        goto error;
    if (PyFile_WriteString("\n", f) < 0)
        goto error;
    Py_DECREF(f);
    return 0;
error:
    Py_DECREF(f);
    return -1;
    /* the line below is just to avoid C compiler
     * warnings about unused functions */
    return __Pyx_Print(f, NULL, 0);
}
#else
static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
    int res;
    PyObject* arg_tuple = PyTuple_Pack(1, o);
    if (unlikely(!arg_tuple))
        return -1;
    res = __Pyx_Print(stream, arg_tuple, 1);
    Py_DECREF(arg_tuple);
    return res;
}
#endif

/* CIntFromPy */
                  static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } 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))
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_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;
}

/* SwapException */
                  #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    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;
    *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

/* CoroutineBase */
                  #include <structmember.h>
#include <frameobject.h>
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Coroutine_Close(PyObject *self);
static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
#if 1 || PY_VERSION_HEX < 0x030300B0
static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (likely(et == PyExc_StopIteration)) {
#if PY_VERSION_HEX >= 0x030300A0
        if (ev && Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            Py_DECREF(ev);
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
#endif
        if (!ev || !PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            if (!ev) {
                Py_INCREF(Py_None);
                ev = Py_None;
            } else if (PyTuple_Check(ev)) {
                if (PyTuple_GET_SIZE(ev) >= 1) {
                    PyObject *value;
#if CYTHON_COMPILING_IN_CPYTHON
                    value = PySequence_ITEM(ev, 0);
#else
                    value = PyTuple_GET_ITEM(ev, 0);
                    Py_INCREF(value);
#endif
                    Py_DECREF(ev);
                    ev = value;
                } else {
                    Py_INCREF(Py_None);
                    Py_DECREF(ev);
                    ev = Py_None;
                }
            }
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = ev;
            return 0;
        }
    } else if (!PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    Py_XDECREF(tb);
    Py_DECREF(et);
#if PY_VERSION_HEX >= 0x030300A0
    value = ((PyStopIterationObject *)ev)->value;
    Py_INCREF(value);
    Py_DECREF(ev);
#else
    {
        PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
        Py_DECREF(ev);
        if (likely(args)) {
            value = PySequence_GetItem(args, 0);
            Py_DECREF(args);
        }
        if (unlikely(!value)) {
            __Pyx_ErrRestore(NULL, NULL, NULL);
            Py_INCREF(Py_None);
            value = Py_None;
        }
    }
#endif
    *pvalue = value;
    return 0;
}
#endif
static CYTHON_INLINE
void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
    PyObject *exc_type = self->exc_type;
    PyObject *exc_value = self->exc_value;
    PyObject *exc_traceback = self->exc_traceback;
    self->exc_type = NULL;
    self->exc_value = NULL;
    self->exc_traceback = NULL;
    Py_XDECREF(exc_type);
    Py_XDECREF(exc_value);
    Py_XDECREF(exc_traceback);
}
static CYTHON_INLINE
int __Pyx_Coroutine_CheckRunning(__pyx_CoroutineObject *gen) {
    if (unlikely(gen->is_running)) {
        PyErr_SetString(PyExc_ValueError,
                        "generator already executing");
        return 1;
    }
    return 0;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) {
    PyObject *retval;
    __Pyx_PyThreadState_declare
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            PyErr_SetString(PyExc_TypeError,
                            "can't send non-None value to a "
                            "just-started generator");
            return NULL;
        }
    }
    if (unlikely(self->resume_label == -1)) {
        PyErr_SetNone(PyExc_StopIteration);
        return NULL;
    }
    __Pyx_PyThreadState_assign
    if (value) {
#if CYTHON_COMPILING_IN_PYPY
#else
        if (self->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_XINCREF(__pyx_tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = __pyx_tstate->frame;
        }
#endif
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(self);
    }
    self->is_running = 1;
    retval = self->body((PyObject *) self, value);
    self->is_running = 0;
    if (retval) {
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
#if CYTHON_COMPILING_IN_PYPY
#else
        if (self->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_CLEAR(f->f_back);
        }
#endif
    } else {
        __Pyx_Coroutine_ExceptionClear(self);
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(PyObject *retval) {
    if (unlikely(!retval && !PyErr_Occurred())) {
        PyErr_SetNone(PyExc_StopIteration);
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen_FetchStopIterationValue(&val);
    ret = __Pyx_Coroutine_SendEx(gen, val);
    Py_XDECREF(val);
    return ret;
}
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
    PyObject *retval;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        {
            if (value == Py_None)
                ret = Py_TYPE(yf)->tp_iternext(yf);
            else
                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
        }
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        retval = __Pyx_Coroutine_FinishDelegation(gen);
    } else {
        retval = __Pyx_Coroutine_SendEx(gen, value);
    }
    return __Pyx_Coroutine_MethodReturn(retval);
}
static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;
    #ifdef __Pyx_Generator_USED
    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    {
        PyObject *meth;
        gen->is_running = 1;
        meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
        if (unlikely(!meth)) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_WriteUnraisable(yf);
            }
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, NULL);
            Py_DECREF(meth);
            if (!retval)
                err = -1;
        }
        gen->is_running = 0;
    }
    Py_XDECREF(retval);
    return err;
}
static PyObject *__Pyx_Generator_Next(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        ret = Py_TYPE(yf)->tp_iternext(yf);
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Coroutine_FinishDelegation(gen);
    }
    return __Pyx_Coroutine_SendEx(gen, Py_None);
}
static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *retval, *raised_exception;
    PyObject *yf = gen->yieldfrom;
    int err = 0;
    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Coroutine_CloseIter(gen, yf);
        __Pyx_Coroutine_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
        PyErr_SetNone(PyExc_GeneratorExit);
    retval = __Pyx_Coroutine_SendEx(gen, NULL);
    if (retval) {
        Py_DECREF(retval);
        PyErr_SetString(PyExc_RuntimeError,
                        "generator ignored GeneratorExit");
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (!raised_exception
        || raised_exception == PyExc_StopIteration
        || raised_exception == PyExc_GeneratorExit
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit)
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration))
    {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *typ;
    PyObject *tb = NULL;
    PyObject *val = NULL;
    PyObject *yf = gen->yieldfrom;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL));
            goto throw_here;
        }
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Throw(yf, args);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Throw(yf, args);
        } else
        #endif
        {
            PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Coroutine_Undelegate(gen);
                gen->is_running = 0;
                goto throw_here;
            }
            ret = PyObject_CallObject(meth, args);
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL));
}
static int __Pyx_Coroutine_traverse(PyObject *self, visitproc visit, void *arg) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    Py_VISIT(gen->closure);
    Py_VISIT(gen->classobj);
    Py_VISIT(gen->yieldfrom);
    Py_VISIT(gen->exc_type);
    Py_VISIT(gen->exc_value);
    Py_VISIT(gen->exc_traceback);
    return 0;
}
static int __Pyx_Coroutine_clear(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    Py_CLEAR(gen->closure);
    Py_CLEAR(gen->classobj);
    Py_CLEAR(gen->yieldfrom);
    Py_CLEAR(gen->exc_type);
    Py_CLEAR(gen->exc_value);
    Py_CLEAR(gen->exc_traceback);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    return 0;
}
static void __Pyx_Coroutine_dealloc(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject_GC_UnTrack(gen);
    if (gen->gi_weakreflist != NULL)
        PyObject_ClearWeakRefs(self);
    if (gen->resume_label > 0) {
        PyObject_GC_Track(self);
#if PY_VERSION_HEX >= 0x030400a1
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (self->ob_refcnt > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *res;
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PyThreadState_declare
    if (gen->resume_label <= 0)
        return ;
#if PY_VERSION_HEX < 0x030400a1
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
    res = __Pyx_Coroutine_Close(self);
    if (res == NULL)
        PyErr_WriteUnraisable(self);
    else
        Py_DECREF(res);
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if PY_VERSION_HEX < 0x030400a1
    assert(self->ob_refcnt > 0);
    if (--self->ob_refcnt == 0) {
        return;
    }
    {
        Py_ssize_t refcnt = self->ob_refcnt;
        _Py_NewReference(self);
        self->ob_refcnt = refcnt;
    }
#if CYTHON_COMPILING_IN_CPYTHON
    assert(PyType_IS_GC(self->ob_type) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
    _Py_DEC_REFTOTAL;
#endif
#ifdef COUNT_ALLOCS
    --Py_TYPE(self)->tp_frees;
    --Py_TYPE(self)->tp_allocs;
#endif
#endif
}
static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
{
    Py_INCREF(self->gi_name);
    return self->gi_name;
}
static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_name;
    Py_INCREF(value);
    self->gi_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
{
    Py_INCREF(self->gi_qualname);
    return self->gi_qualname;
}
static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_qualname;
    Py_INCREF(value);
    self->gi_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static __pyx_CoroutineObject *__Pyx__Coroutine_New(PyTypeObject* type, __pyx_coroutine_body_t body,
                                                   PyObject *closure, PyObject *name, PyObject *qualname) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
    if (gen == NULL)
        return NULL;
    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->exc_type = NULL;
    gen->exc_value = NULL;
    gen->exc_traceback = NULL;
    gen->gi_weakreflist = NULL;
    Py_XINCREF(qualname);
    gen->gi_qualname = qualname;
    Py_XINCREF(name);
    gen->gi_name = name;
    PyObject_GC_Track(gen);
    return gen;
}

/* PatchModuleWithCoroutine */
                      static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    int result;
    PyObject *globals, *result_obj;
    globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_coroutine_type",
    #ifdef __Pyx_Coroutine_USED
        (PyObject*)__pyx_CoroutineType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_generator_type",
    #ifdef __Pyx_Generator_USED
        (PyObject*)__pyx_GeneratorType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
    result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
    if (unlikely(!result_obj)) goto ignore;
    Py_DECREF(result_obj);
    Py_DECREF(globals);
    return module;
ignore:
    Py_XDECREF(globals);
    PyErr_WriteUnraisable(module);
    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
        Py_DECREF(module);
        module = NULL;
    }
#else
    py_code++;
#endif
    return module;
}

/* PatchGeneratorABC */
                      #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
static PyObject* __Pyx_patch_abc_module(PyObject *module);
static PyObject* __Pyx_patch_abc_module(PyObject *module) {
    module = __Pyx_Coroutine_patch_module(
        module, ""
"if _cython_generator_type is not None:\n"
"    try: Generator = _module.Generator\n"
"    except AttributeError: pass\n"
"    else: Generator.register(_cython_generator_type)\n"
"if _cython_coroutine_type is not None:\n"
"    try: Coroutine = _module.Coroutine\n"
"    except AttributeError: pass\n"
"    else: Coroutine.register(_cython_coroutine_type)\n"
    );
    return module;
}
#endif
static int __Pyx_patch_abc(void) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    static int abc_patched = 0;
    if (!abc_patched) {
        PyObject *module;
        module = PyImport_ImportModule((PY_VERSION_HEX >= 0x03030000) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_VERSION_HEX >= 0x03030000) ?
                        "Cython module failed to register with collections.abc module" :
                        "Cython module failed to register with collections module"), 1) < 0)) {
                return -1;
            }
        } else {
            module = __Pyx_patch_abc_module(module);
            abc_patched = 1;
            if (unlikely(!module))
                return -1;
            Py_DECREF(module);
        }
        module = PyImport_ImportModule("backports_abc");
        if (module) {
            module = __Pyx_patch_abc_module(module);
            Py_XDECREF(module);
        }
        if (!module) {
            PyErr_Clear();
        }
    }
#else
    if (0) __Pyx_Coroutine_patch_module(NULL, NULL);
#endif
    return 0;
}

/* Generator */
                      static PyMethodDef __pyx_Generator_methods[] = {
    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
     (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS,
     (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
    {0, 0, 0, 0}
};
static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
    {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
     (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
    {0, 0, 0, 0, 0}
};
static PyGetSetDef __pyx_Generator_getsets[] = {
    {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
     (char*) PyDoc_STR("name of the generator"), 0},
    {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
     (char*) PyDoc_STR("qualified name of the generator"), 0},
    {0, 0, 0, 0, 0}
};
static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "generator",
    sizeof(__pyx_CoroutineObject),
    0,
    (destructor) __Pyx_Coroutine_dealloc,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
    0,
    (traverseproc) __Pyx_Coroutine_traverse,
    0,
    0,
    offsetof(__pyx_CoroutineObject, gi_weakreflist),
    0,
    (iternextfunc) __Pyx_Generator_Next,
    __pyx_Generator_methods,
    __pyx_Generator_memberlist,
    __pyx_Generator_getsets,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if PY_VERSION_HEX >= 0x030400a1
    __Pyx_Coroutine_del,
#endif
};
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr;
    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
    if (unlikely(!__pyx_GeneratorType)) {
        return -1;
    }
    return 0;
}

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

/* ModuleImport */
                      #ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

/* VoidPtrImport */
                      #ifndef __PYX_HAVE_RT_ImportVoidPtr
#define __PYX_HAVE_RT_ImportVoidPtr
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, name);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C variable %.200s",
                PyModule_GetName(module), name);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    *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 variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, desc);
        goto bad;
    }
    *p = PyCObject_AsVoidPtr(cobj);}
#endif
    if (!(*p))
        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;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else
        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_LENGTH(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else
        return PyUnicode_AsUTF8AndSize(o, length);
#endif
#endif
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (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 PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return __Pyx_NewRef(x);
  m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%.4s__ returned non-%.4s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(x);
  }
#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_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
