/* Generated by Cython 0.19.1 on Sun Aug 04 15:59:48 2013 */

#define PY_SSIZE_T_CLEAN
#ifndef CYTHON_USE_PYLONG_INTERNALS
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 0
#else
#include "pyconfig.h"
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 1
#else
#define CYTHON_USE_PYLONG_INTERNALS 0
#endif
#endif
#endif
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02040000
    #error Cython requires Python 2.4+.
#else
#include <stddef.h> /* For offsetof */
#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 PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define CYTHON_FORMAT_SSIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
  #define PyNumber_Index(o)    ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
                                (PyErr_Format(PyExc_TypeError, \
                                              "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
                                 (PyObject*)0))
  #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
                                  !PyComplex_Check(o))
  #define PyIndex_Check __Pyx_PyIndex_Check
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  #define __PYX_BUILD_PY_SSIZE_T "i"
#else
  #define __PYX_BUILD_PY_SSIZE_T "n"
  #define CYTHON_FORMAT_SSIZE_T "z"
  #define __Pyx_PyIndex_Check PyIndex_Check
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)
  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;
  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
  typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
#endif
#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, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#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)
#endif
#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6
  #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
#endif
#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_TPFLAGS_HAVE_VERSION_TAG 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_READ(k, d, i)   PyUnicode_READ(k, d, i)
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#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_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#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_CheckExact(obj) || PyUnicode_CheckExact(obj) || \
                                         PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type)
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#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
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_VERSION_HEX < 0x03020000
  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) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER)
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
   a quiet NaN. */
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif


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

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

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__kivy__graphics__transformation
#define __PYX_HAVE_API__kivy__graphics__transformation
#include "math.h"
#include "string.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

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

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING "utf-8"
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(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_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromUString(s)  __Pyx_PyObject_FromString((char*)s)
#define __Pyx_PyBytes_FromUString(s)   __Pyx_PyBytes_FromString((char*)s)
#define __Pyx_PyStr_FromUString(s)     __Pyx_PyStr_FromString((char*)s)
#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((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 u_end - u - 1;
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params() {
    PyObject* sys = NULL;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    sys = PyImport_ImportModule("sys");
    if (sys == NULL) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    if (default_encoding == NULL) goto bad;
    if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        const char* default_encoding_c = PyBytes_AS_STRING(default_encoding);
        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 == NULL) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (ascii_chars_b == NULL || strncmp(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 '%s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
    }
    Py_XDECREF(sys);
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return 0;
bad:
    Py_XDECREF(sys);
    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() {
    PyObject* sys = NULL;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (sys == NULL) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    if (default_encoding == NULL) goto bad;
    default_encoding_c = PyBytes_AS_STRING(default_encoding);
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(sys);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(sys);
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


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

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


static const char *__pyx_f[] = {
  "transformation.pyx",
};

/*--- Type declarations ---*/
struct __pyx_obj_4kivy_8graphics_14transformation_Matrix;
struct __pyx_opt_args_4kivy_8graphics_14transformation_6Matrix_transform_point;

/* "kivy\graphics\transformation.pxd":1
 * ctypedef double matrix_t[16]             # <<<<<<<<<<<<<<
 * 
 * cdef class Matrix:
 */
typedef double __pyx_t_4kivy_8graphics_14transformation_matrix_t[16];

/* "kivy\graphics\transformation.pxd":34
 *     cpdef Matrix normal_matrix(self)
 * 
 *     cpdef tuple transform_point(Matrix self, double x, double y, double z,             # <<<<<<<<<<<<<<
 *             t=?)
 * 
 */
struct __pyx_opt_args_4kivy_8graphics_14transformation_6Matrix_transform_point {
  int __pyx_n;
  PyObject *t;
};

/* "kivy\graphics\transformation.pxd":3
 * ctypedef double matrix_t[16]
 * 
 * cdef class Matrix:             # <<<<<<<<<<<<<<
 *     cdef matrix_t mat
 * 
 */
struct __pyx_obj_4kivy_8graphics_14transformation_Matrix {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *__pyx_vtab;
  __pyx_t_4kivy_8graphics_14transformation_matrix_t mat;
};



/* "kivy\graphics\transformation.pyx":35
 * cdef double _EPS = 8.8817841970012523e-16
 * 
 * cdef class Matrix:             # <<<<<<<<<<<<<<
 *     '''
 *     Optimized matrix class for OpenGL::
 */

struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix {
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*identity)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*inverse)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*transpose)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*multiply)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*scale)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*translate)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*rotate)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*view_clip)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, double, double, int, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*perspective)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, int __pyx_skip_dispatch);
  PyObject *(*look_at)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, double, double, double, double, double, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*normal_matrix)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  PyObject *(*transform_point)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch, struct __pyx_opt_args_4kivy_8graphics_14transformation_6Matrix_transform_point *__pyx_optional_args);
  PyObject *(*project)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *__pyx_vtabptr_4kivy_8graphics_14transformation_Matrix;
#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); /*proto*/
  #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 /* CYTHON_REFNANNY */
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

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

static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*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); /*proto*/

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

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

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

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

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

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

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

#define __Pyx_GetItemInt(o, i, size, to_py_func, is_list, wraparound, boundscheck) \
    (((size) <= sizeof(Py_ssize_t)) ? \
    __Pyx_GetItemInt_Fast(o, i, is_list, wraparound, boundscheck) : \
    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
#define __Pyx_GetItemInt_List(o, i, size, to_py_func, is_list, wraparound, boundscheck) \
    (((size) <= sizeof(Py_ssize_t)) ? \
    __Pyx_GetItemInt_List_Fast(o, i, wraparound, boundscheck) : \
    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func, is_list, wraparound, boundscheck) \
    (((size) <= sizeof(Py_ssize_t)) ? \
    __Pyx_GetItemInt_Tuple_Fast(o, i, wraparound, boundscheck) : \
    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
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);

#define __Pyx_SetItemInt(o, i, v, size, to_py_func, is_list, wraparound, boundscheck) \
    (((size) <= sizeof(Py_ssize_t)) ? \
    __Pyx_SetItemInt_Fast(o, i, v, is_list, wraparound, boundscheck) : \
    __Pyx_SetItemInt_Generic(o, to_py_func(i), v))
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

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

#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static int __Pyx_check_binary_version(void);

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

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

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


/* Module declarations from 'kivy.graphics.transformation' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_14transformation_Matrix = 0;
static double __pyx_v_4kivy_8graphics_14transformation__EPS;
#define __Pyx_MODULE_NAME "kivy.graphics.transformation"
int __pyx_module_is_main_kivy__graphics__transformation = 0;

/* Implementation of 'kivy.graphics.transformation' */
static PyObject *__pyx_builtin_ValueError;
static int __pyx_pf_4kivy_8graphics_14transformation_6Matrix___cinit__(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_14transformation_6Matrix_2__init__(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_4rotate(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_angle, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_6scale(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_8translate(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_10perspective(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_fovy, double __pyx_v_aspect, double __pyx_v_zNear, double __pyx_v_zFar); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_12view_clip(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_left, double __pyx_v_right, double __pyx_v_bottom, double __pyx_v_top, double __pyx_v_near, double __pyx_v_far, int __pyx_v_perspective); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_14look_at(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_eyex, double __pyx_v_eyey, double __pyx_v_eyez, double __pyx_v_centerx, double __pyx_v_centery, double __pyx_v_centerz, double __pyx_v_upx, double __pyx_v_upy, double __pyx_v_upz); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_16transform_point(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z, PyObject *__pyx_v_t); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_18identity(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_20transpose(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_22inverse(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_24normal_matrix(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_26multiply(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_mb, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_ma); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_28project(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_objx, double __pyx_v_objy, double __pyx_v_objz, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_model, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_proj, double __pyx_v_vx, double __pyx_v_vy, double __pyx_v_vw, double __pyx_v_vh); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_30__str__(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self); /* proto */
static PyObject *__pyx_tp_new_4kivy_8graphics_14transformation_Matrix(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static char __pyx_k_1[] = "invalid frustrum";
static char __pyx_k_3[] = "invalid frustrum: near <= 0";
static char __pyx_k_5[] = "[[ %f %f %f %f ]\n[ %f %f %f %f ]\n[ %f %f %f %f ]\n[ %f %f %f %f ]]";
static char __pyx_k_6[] = "\nTransformation\n==============\n\nThis module contain a Matrix class, used for our Graphics calculation. We are\nsupporting:\n\n- rotation, translation, scaling matrix\n- multiply matrix\n- create clip matrix (with or without perspective)\n- transform 3d touch on a matrix\n\n.. versionchanged:: 1.6.0\n   Added :meth:`Matrix.perspective`, :meth:`Matrix.look_at`,\n   :meth:`Matrix.transpose`\n";
static char __pyx_k__t[] = "t";
static char __pyx_k__x[] = "x";
static char __pyx_k__y[] = "y";
static char __pyx_k__z[] = "z";
static char __pyx_k__vh[] = "vh";
static char __pyx_k__vw[] = "vw";
static char __pyx_k__vx[] = "vx";
static char __pyx_k__vy[] = "vy";
static char __pyx_k__far[] = "far";
static char __pyx_k__top[] = "top";
static char __pyx_k__upx[] = "upx";
static char __pyx_k__upy[] = "upy";
static char __pyx_k__upz[] = "upz";
static char __pyx_k__eyex[] = "eyex";
static char __pyx_k__eyey[] = "eyey";
static char __pyx_k__eyez[] = "eyez";
static char __pyx_k__fovy[] = "fovy";
static char __pyx_k__left[] = "left";
static char __pyx_k__near[] = "near";
static char __pyx_k__objx[] = "objx";
static char __pyx_k__objy[] = "objy";
static char __pyx_k__objz[] = "objz";
static char __pyx_k__proj[] = "proj";
static char __pyx_k__zFar[] = "zFar";
static char __pyx_k__angle[] = "angle";
static char __pyx_k__model[] = "model";
static char __pyx_k__right[] = "right";
static char __pyx_k__scale[] = "scale";
static char __pyx_k__zNear[] = "zNear";
static char __pyx_k__Matrix[] = "Matrix";
static char __pyx_k__aspect[] = "aspect";
static char __pyx_k__bottom[] = "bottom";
static char __pyx_k__rotate[] = "rotate";
static char __pyx_k____all__[] = "__all__";
static char __pyx_k__centerx[] = "centerx";
static char __pyx_k__centery[] = "centery";
static char __pyx_k__centerz[] = "centerz";
static char __pyx_k__inverse[] = "inverse";
static char __pyx_k__look_at[] = "look_at";
static char __pyx_k__project[] = "project";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__identity[] = "identity";
static char __pyx_k__multiply[] = "multiply";
static char __pyx_k__translate[] = "translate";
static char __pyx_k__transpose[] = "transpose";
static char __pyx_k__view_clip[] = "view_clip";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__perspective[] = "perspective";
static char __pyx_k__normal_matrix[] = "normal_matrix";
static char __pyx_k____pyx_vtable__[] = "__pyx_vtable__";
static char __pyx_k__transform_point[] = "transform_point";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_n_s__Matrix;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____all__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____pyx_vtable__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s__angle;
static PyObject *__pyx_n_s__aspect;
static PyObject *__pyx_n_s__bottom;
static PyObject *__pyx_n_s__centerx;
static PyObject *__pyx_n_s__centery;
static PyObject *__pyx_n_s__centerz;
static PyObject *__pyx_n_s__eyex;
static PyObject *__pyx_n_s__eyey;
static PyObject *__pyx_n_s__eyez;
static PyObject *__pyx_n_s__far;
static PyObject *__pyx_n_s__fovy;
static PyObject *__pyx_n_s__identity;
static PyObject *__pyx_n_s__inverse;
static PyObject *__pyx_n_s__left;
static PyObject *__pyx_n_s__look_at;
static PyObject *__pyx_n_s__model;
static PyObject *__pyx_n_s__multiply;
static PyObject *__pyx_n_s__near;
static PyObject *__pyx_n_s__normal_matrix;
static PyObject *__pyx_n_s__objx;
static PyObject *__pyx_n_s__objy;
static PyObject *__pyx_n_s__objz;
static PyObject *__pyx_n_s__perspective;
static PyObject *__pyx_n_s__proj;
static PyObject *__pyx_n_s__project;
static PyObject *__pyx_n_s__right;
static PyObject *__pyx_n_s__rotate;
static PyObject *__pyx_n_s__scale;
static PyObject *__pyx_n_s__t;
static PyObject *__pyx_n_s__top;
static PyObject *__pyx_n_s__transform_point;
static PyObject *__pyx_n_s__translate;
static PyObject *__pyx_n_s__transpose;
static PyObject *__pyx_n_s__upx;
static PyObject *__pyx_n_s__upy;
static PyObject *__pyx_n_s__upz;
static PyObject *__pyx_n_s__vh;
static PyObject *__pyx_n_s__view_clip;
static PyObject *__pyx_n_s__vw;
static PyObject *__pyx_n_s__vx;
static PyObject *__pyx_n_s__vy;
static PyObject *__pyx_n_s__x;
static PyObject *__pyx_n_s__y;
static PyObject *__pyx_n_s__z;
static PyObject *__pyx_n_s__zFar;
static PyObject *__pyx_n_s__zNear;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_k_tuple_2;
static PyObject *__pyx_k_tuple_4;
static PyObject *__pyx_k_tuple_7;

/* Python wrapper */
static int __pyx_pw_4kivy_8graphics_14transformation_6Matrix_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4kivy_8graphics_14transformation_6Matrix_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix___cinit__(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":53
 *     '''
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         memset(self.mat, 0, sizeof(matrix_t))
 * 
 */

static int __pyx_pf_4kivy_8graphics_14transformation_6Matrix___cinit__(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "kivy\graphics\transformation.pyx":54
 * 
 *     def __cinit__(self):
 *         memset(self.mat, 0, sizeof(matrix_t))             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self):
 */
  memset(__pyx_v_self->mat, 0, (sizeof(__pyx_t_4kivy_8graphics_14transformation_matrix_t)));

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4kivy_8graphics_14transformation_6Matrix_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4kivy_8graphics_14transformation_6Matrix_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_2__init__(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":56
 *         memset(self.mat, 0, sizeof(matrix_t))
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.identity()
 * 
 */

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

  /* "kivy\graphics\transformation.pyx":57
 * 
 *     def __init__(self):
 *         self.identity()             # <<<<<<<<<<<<<<
 * 
 *     cpdef Matrix rotate(Matrix self, double angle, double x, double y, double z):
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->identity(__pyx_v_self, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":59
 *         self.identity()
 * 
 *     cpdef Matrix rotate(Matrix self, double angle, double x, double y, double z):             # <<<<<<<<<<<<<<
 *         '''Rotate the matrix with the angle, around the axis (x, y, z)
 *         '''
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_5rotate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_f_4kivy_8graphics_14transformation_6Matrix_rotate(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_angle, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z, int __pyx_skip_dispatch) {
  double __pyx_v_d;
  double __pyx_v_c;
  double __pyx_v_s;
  double __pyx_v_co;
  double __pyx_v_ox;
  double __pyx_v_oy;
  double __pyx_v_oz;
  double __pyx_v_f1;
  double __pyx_v_f2;
  double __pyx_v_f3;
  double __pyx_v_f4;
  double __pyx_v_f5;
  double __pyx_v_f6;
  double __pyx_v_f7;
  double __pyx_v_f8;
  double __pyx_v_f9;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rotate", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__rotate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_5rotate)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_angle); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_z); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4kivy_8graphics_14transformation_Matrix))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_5);
      __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":63
 *         '''
 *         cdef double d, c, s, co, ox, oy, oz, f1, f2, f3, f4, f5, f6, f7, f8, f9
 *         with nogil:             # <<<<<<<<<<<<<<
 *             d = sqrt(x * x + y * y + z * z)
 *             if (d != 1.0):
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "kivy\graphics\transformation.pyx":64
 *         cdef double d, c, s, co, ox, oy, oz, f1, f2, f3, f4, f5, f6, f7, f8, f9
 *         with nogil:
 *             d = sqrt(x * x + y * y + z * z)             # <<<<<<<<<<<<<<
 *             if (d != 1.0):
 *                 x /= d
 */
        __pyx_v_d = sqrt((((__pyx_v_x * __pyx_v_x) + (__pyx_v_y * __pyx_v_y)) + (__pyx_v_z * __pyx_v_z)));

        /* "kivy\graphics\transformation.pyx":65
 *         with nogil:
 *             d = sqrt(x * x + y * y + z * z)
 *             if (d != 1.0):             # <<<<<<<<<<<<<<
 *                 x /= d
 *                 y /= d
 */
        __pyx_t_7 = ((__pyx_v_d != 1.0) != 0);
        if (__pyx_t_7) {

          /* "kivy\graphics\transformation.pyx":66
 *             d = sqrt(x * x + y * y + z * z)
 *             if (d != 1.0):
 *                 x /= d             # <<<<<<<<<<<<<<
 *                 y /= d
 *                 z /= d
 */
          __pyx_v_x = (__pyx_v_x / __pyx_v_d);

          /* "kivy\graphics\transformation.pyx":67
 *             if (d != 1.0):
 *                 x /= d
 *                 y /= d             # <<<<<<<<<<<<<<
 *                 z /= d
 *             c = cos(angle)
 */
          __pyx_v_y = (__pyx_v_y / __pyx_v_d);

          /* "kivy\graphics\transformation.pyx":68
 *                 x /= d
 *                 y /= d
 *                 z /= d             # <<<<<<<<<<<<<<
 *             c = cos(angle)
 *             s = sin(angle)
 */
          __pyx_v_z = (__pyx_v_z / __pyx_v_d);
          goto __pyx_L6;
        }
        __pyx_L6:;

        /* "kivy\graphics\transformation.pyx":69
 *                 y /= d
 *                 z /= d
 *             c = cos(angle)             # <<<<<<<<<<<<<<
 *             s = sin(angle)
 *             co = 1.0 - c
 */
        __pyx_v_c = cos(__pyx_v_angle);

        /* "kivy\graphics\transformation.pyx":70
 *                 z /= d
 *             c = cos(angle)
 *             s = sin(angle)             # <<<<<<<<<<<<<<
 *             co = 1.0 - c
 *             ox = x * co
 */
        __pyx_v_s = sin(__pyx_v_angle);

        /* "kivy\graphics\transformation.pyx":71
 *             c = cos(angle)
 *             s = sin(angle)
 *             co = 1.0 - c             # <<<<<<<<<<<<<<
 *             ox = x * co
 *             oy = y * co
 */
        __pyx_v_co = (1.0 - __pyx_v_c);

        /* "kivy\graphics\transformation.pyx":72
 *             s = sin(angle)
 *             co = 1.0 - c
 *             ox = x * co             # <<<<<<<<<<<<<<
 *             oy = y * co
 *             oz = z * co
 */
        __pyx_v_ox = (__pyx_v_x * __pyx_v_co);

        /* "kivy\graphics\transformation.pyx":73
 *             co = 1.0 - c
 *             ox = x * co
 *             oy = y * co             # <<<<<<<<<<<<<<
 *             oz = z * co
 *             f1 = x * ox + c
 */
        __pyx_v_oy = (__pyx_v_y * __pyx_v_co);

        /* "kivy\graphics\transformation.pyx":74
 *             ox = x * co
 *             oy = y * co
 *             oz = z * co             # <<<<<<<<<<<<<<
 *             f1 = x * ox + c
 *             f5 = y * oy + c
 */
        __pyx_v_oz = (__pyx_v_z * __pyx_v_co);

        /* "kivy\graphics\transformation.pyx":75
 *             oy = y * co
 *             oz = z * co
 *             f1 = x * ox + c             # <<<<<<<<<<<<<<
 *             f5 = y * oy + c
 *             f9 = z * oz + c
 */
        __pyx_v_f1 = ((__pyx_v_x * __pyx_v_ox) + __pyx_v_c);

        /* "kivy\graphics\transformation.pyx":76
 *             oz = z * co
 *             f1 = x * ox + c
 *             f5 = y * oy + c             # <<<<<<<<<<<<<<
 *             f9 = z * oz + c
 *             d = z * s
 */
        __pyx_v_f5 = ((__pyx_v_y * __pyx_v_oy) + __pyx_v_c);

        /* "kivy\graphics\transformation.pyx":77
 *             f1 = x * ox + c
 *             f5 = y * oy + c
 *             f9 = z * oz + c             # <<<<<<<<<<<<<<
 *             d = z * s
 *             f2 = x * oy - d
 */
        __pyx_v_f9 = ((__pyx_v_z * __pyx_v_oz) + __pyx_v_c);

        /* "kivy\graphics\transformation.pyx":78
 *             f5 = y * oy + c
 *             f9 = z * oz + c
 *             d = z * s             # <<<<<<<<<<<<<<
 *             f2 = x * oy - d
 *             f4 = y * ox + d
 */
        __pyx_v_d = (__pyx_v_z * __pyx_v_s);

        /* "kivy\graphics\transformation.pyx":79
 *             f9 = z * oz + c
 *             d = z * s
 *             f2 = x * oy - d             # <<<<<<<<<<<<<<
 *             f4 = y * ox + d
 *             d = y * s
 */
        __pyx_v_f2 = ((__pyx_v_x * __pyx_v_oy) - __pyx_v_d);

        /* "kivy\graphics\transformation.pyx":80
 *             d = z * s
 *             f2 = x * oy - d
 *             f4 = y * ox + d             # <<<<<<<<<<<<<<
 *             d = y * s
 *             f3 = x * oz + d
 */
        __pyx_v_f4 = ((__pyx_v_y * __pyx_v_ox) + __pyx_v_d);

        /* "kivy\graphics\transformation.pyx":81
 *             f2 = x * oy - d
 *             f4 = y * ox + d
 *             d = y * s             # <<<<<<<<<<<<<<
 *             f3 = x * oz + d
 *             f7 = z * ox - d
 */
        __pyx_v_d = (__pyx_v_y * __pyx_v_s);

        /* "kivy\graphics\transformation.pyx":82
 *             f4 = y * ox + d
 *             d = y * s
 *             f3 = x * oz + d             # <<<<<<<<<<<<<<
 *             f7 = z * ox - d
 *             d = x * s
 */
        __pyx_v_f3 = ((__pyx_v_x * __pyx_v_oz) + __pyx_v_d);

        /* "kivy\graphics\transformation.pyx":83
 *             d = y * s
 *             f3 = x * oz + d
 *             f7 = z * ox - d             # <<<<<<<<<<<<<<
 *             d = x * s
 *             f6 = y * oz - d
 */
        __pyx_v_f7 = ((__pyx_v_z * __pyx_v_ox) - __pyx_v_d);

        /* "kivy\graphics\transformation.pyx":84
 *             f3 = x * oz + d
 *             f7 = z * ox - d
 *             d = x * s             # <<<<<<<<<<<<<<
 *             f6 = y * oz - d
 *             f8 = z * oy + d
 */
        __pyx_v_d = (__pyx_v_x * __pyx_v_s);

        /* "kivy\graphics\transformation.pyx":85
 *             f7 = z * ox - d
 *             d = x * s
 *             f6 = y * oz - d             # <<<<<<<<<<<<<<
 *             f8 = z * oy + d
 *             ox = self.mat[0]
 */
        __pyx_v_f6 = ((__pyx_v_y * __pyx_v_oz) - __pyx_v_d);

        /* "kivy\graphics\transformation.pyx":86
 *             d = x * s
 *             f6 = y * oz - d
 *             f8 = z * oy + d             # <<<<<<<<<<<<<<
 *             ox = self.mat[0]
 *             oy = self.mat[1]
 */
        __pyx_v_f8 = ((__pyx_v_z * __pyx_v_oy) + __pyx_v_d);

        /* "kivy\graphics\transformation.pyx":87
 *             f6 = y * oz - d
 *             f8 = z * oy + d
 *             ox = self.mat[0]             # <<<<<<<<<<<<<<
 *             oy = self.mat[1]
 *             oz = self.mat[2]
 */
        __pyx_v_ox = (__pyx_v_self->mat[0]);

        /* "kivy\graphics\transformation.pyx":88
 *             f8 = z * oy + d
 *             ox = self.mat[0]
 *             oy = self.mat[1]             # <<<<<<<<<<<<<<
 *             oz = self.mat[2]
 *             self.mat[0] = ox * f1 + oy * f2 + oz * f3
 */
        __pyx_v_oy = (__pyx_v_self->mat[1]);

        /* "kivy\graphics\transformation.pyx":89
 *             ox = self.mat[0]
 *             oy = self.mat[1]
 *             oz = self.mat[2]             # <<<<<<<<<<<<<<
 *             self.mat[0] = ox * f1 + oy * f2 + oz * f3
 *             self.mat[1] = ox * f4 + oy * f5 + oz * f6
 */
        __pyx_v_oz = (__pyx_v_self->mat[2]);

        /* "kivy\graphics\transformation.pyx":90
 *             oy = self.mat[1]
 *             oz = self.mat[2]
 *             self.mat[0] = ox * f1 + oy * f2 + oz * f3             # <<<<<<<<<<<<<<
 *             self.mat[1] = ox * f4 + oy * f5 + oz * f6
 *             self.mat[2] = ox * f7 + oy * f8 + oz * f9
 */
        (__pyx_v_self->mat[0]) = (((__pyx_v_ox * __pyx_v_f1) + (__pyx_v_oy * __pyx_v_f2)) + (__pyx_v_oz * __pyx_v_f3));

        /* "kivy\graphics\transformation.pyx":91
 *             oz = self.mat[2]
 *             self.mat[0] = ox * f1 + oy * f2 + oz * f3
 *             self.mat[1] = ox * f4 + oy * f5 + oz * f6             # <<<<<<<<<<<<<<
 *             self.mat[2] = ox * f7 + oy * f8 + oz * f9
 *             ox = self.mat[4]
 */
        (__pyx_v_self->mat[1]) = (((__pyx_v_ox * __pyx_v_f4) + (__pyx_v_oy * __pyx_v_f5)) + (__pyx_v_oz * __pyx_v_f6));

        /* "kivy\graphics\transformation.pyx":92
 *             self.mat[0] = ox * f1 + oy * f2 + oz * f3
 *             self.mat[1] = ox * f4 + oy * f5 + oz * f6
 *             self.mat[2] = ox * f7 + oy * f8 + oz * f9             # <<<<<<<<<<<<<<
 *             ox = self.mat[4]
 *             oy = self.mat[5]
 */
        (__pyx_v_self->mat[2]) = (((__pyx_v_ox * __pyx_v_f7) + (__pyx_v_oy * __pyx_v_f8)) + (__pyx_v_oz * __pyx_v_f9));

        /* "kivy\graphics\transformation.pyx":93
 *             self.mat[1] = ox * f4 + oy * f5 + oz * f6
 *             self.mat[2] = ox * f7 + oy * f8 + oz * f9
 *             ox = self.mat[4]             # <<<<<<<<<<<<<<
 *             oy = self.mat[5]
 *             oz = self.mat[6]
 */
        __pyx_v_ox = (__pyx_v_self->mat[4]);

        /* "kivy\graphics\transformation.pyx":94
 *             self.mat[2] = ox * f7 + oy * f8 + oz * f9
 *             ox = self.mat[4]
 *             oy = self.mat[5]             # <<<<<<<<<<<<<<
 *             oz = self.mat[6]
 *             self.mat[4] = ox * f1 + oy * f2 + oz * f3
 */
        __pyx_v_oy = (__pyx_v_self->mat[5]);

        /* "kivy\graphics\transformation.pyx":95
 *             ox = self.mat[4]
 *             oy = self.mat[5]
 *             oz = self.mat[6]             # <<<<<<<<<<<<<<
 *             self.mat[4] = ox * f1 + oy * f2 + oz * f3
 *             self.mat[5] = ox * f4 + oy * f5 + oz * f6
 */
        __pyx_v_oz = (__pyx_v_self->mat[6]);

        /* "kivy\graphics\transformation.pyx":96
 *             oy = self.mat[5]
 *             oz = self.mat[6]
 *             self.mat[4] = ox * f1 + oy * f2 + oz * f3             # <<<<<<<<<<<<<<
 *             self.mat[5] = ox * f4 + oy * f5 + oz * f6
 *             self.mat[6] = ox * f7 + oy * f8 + oz * f9
 */
        (__pyx_v_self->mat[4]) = (((__pyx_v_ox * __pyx_v_f1) + (__pyx_v_oy * __pyx_v_f2)) + (__pyx_v_oz * __pyx_v_f3));

        /* "kivy\graphics\transformation.pyx":97
 *             oz = self.mat[6]
 *             self.mat[4] = ox * f1 + oy * f2 + oz * f3
 *             self.mat[5] = ox * f4 + oy * f5 + oz * f6             # <<<<<<<<<<<<<<
 *             self.mat[6] = ox * f7 + oy * f8 + oz * f9
 *             ox = self.mat[ 8]
 */
        (__pyx_v_self->mat[5]) = (((__pyx_v_ox * __pyx_v_f4) + (__pyx_v_oy * __pyx_v_f5)) + (__pyx_v_oz * __pyx_v_f6));

        /* "kivy\graphics\transformation.pyx":98
 *             self.mat[4] = ox * f1 + oy * f2 + oz * f3
 *             self.mat[5] = ox * f4 + oy * f5 + oz * f6
 *             self.mat[6] = ox * f7 + oy * f8 + oz * f9             # <<<<<<<<<<<<<<
 *             ox = self.mat[ 8]
 *             oy = self.mat[ 9]
 */
        (__pyx_v_self->mat[6]) = (((__pyx_v_ox * __pyx_v_f7) + (__pyx_v_oy * __pyx_v_f8)) + (__pyx_v_oz * __pyx_v_f9));

        /* "kivy\graphics\transformation.pyx":99
 *             self.mat[5] = ox * f4 + oy * f5 + oz * f6
 *             self.mat[6] = ox * f7 + oy * f8 + oz * f9
 *             ox = self.mat[ 8]             # <<<<<<<<<<<<<<
 *             oy = self.mat[ 9]
 *             oz = self.mat[10]
 */
        __pyx_v_ox = (__pyx_v_self->mat[8]);

        /* "kivy\graphics\transformation.pyx":100
 *             self.mat[6] = ox * f7 + oy * f8 + oz * f9
 *             ox = self.mat[ 8]
 *             oy = self.mat[ 9]             # <<<<<<<<<<<<<<
 *             oz = self.mat[10]
 *             self.mat[ 8] = ox * f1 + oy * f2 + oz * f3
 */
        __pyx_v_oy = (__pyx_v_self->mat[9]);

        /* "kivy\graphics\transformation.pyx":101
 *             ox = self.mat[ 8]
 *             oy = self.mat[ 9]
 *             oz = self.mat[10]             # <<<<<<<<<<<<<<
 *             self.mat[ 8] = ox * f1 + oy * f2 + oz * f3
 *             self.mat[ 9] = ox * f4 + oy * f5 + oz * f6
 */
        __pyx_v_oz = (__pyx_v_self->mat[10]);

        /* "kivy\graphics\transformation.pyx":102
 *             oy = self.mat[ 9]
 *             oz = self.mat[10]
 *             self.mat[ 8] = ox * f1 + oy * f2 + oz * f3             # <<<<<<<<<<<<<<
 *             self.mat[ 9] = ox * f4 + oy * f5 + oz * f6
 *             self.mat[10] = ox * f7 + oy * f8 + oz * f9
 */
        (__pyx_v_self->mat[8]) = (((__pyx_v_ox * __pyx_v_f1) + (__pyx_v_oy * __pyx_v_f2)) + (__pyx_v_oz * __pyx_v_f3));

        /* "kivy\graphics\transformation.pyx":103
 *             oz = self.mat[10]
 *             self.mat[ 8] = ox * f1 + oy * f2 + oz * f3
 *             self.mat[ 9] = ox * f4 + oy * f5 + oz * f6             # <<<<<<<<<<<<<<
 *             self.mat[10] = ox * f7 + oy * f8 + oz * f9
 *         return self
 */
        (__pyx_v_self->mat[9]) = (((__pyx_v_ox * __pyx_v_f4) + (__pyx_v_oy * __pyx_v_f5)) + (__pyx_v_oz * __pyx_v_f6));

        /* "kivy\graphics\transformation.pyx":104
 *             self.mat[ 8] = ox * f1 + oy * f2 + oz * f3
 *             self.mat[ 9] = ox * f4 + oy * f5 + oz * f6
 *             self.mat[10] = ox * f7 + oy * f8 + oz * f9             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
        (__pyx_v_self->mat[10]) = (((__pyx_v_ox * __pyx_v_f7) + (__pyx_v_oy * __pyx_v_f8)) + (__pyx_v_oz * __pyx_v_f9));
      }

      /* "kivy\graphics\transformation.pyx":63
 *         '''
 *         cdef double d, c, s, co, ox, oy, oz, f1, f2, f3, f4, f5, f6, f7, f8, f9
 *         with nogil:             # <<<<<<<<<<<<<<
 *             d = sqrt(x * x + y * y + z * z)
 *             if (d != 1.0):
 */
      /*finally:*/ {
        #ifdef WITH_THREAD
        Py_BLOCK_THREADS
        #endif
      }
  }

  /* "kivy\graphics\transformation.pyx":105
 *             self.mat[ 9] = ox * f4 + oy * f5 + oz * f6
 *             self.mat[10] = ox * f7 + oy * f8 + oz * f9
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     cpdef Matrix scale(Matrix self, double x, double y, double z):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.rotate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_5rotate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_4rotate[] = "Rotate the matrix with the angle, around the axis (x, y, z)\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_5rotate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_angle;
  double __pyx_v_x;
  double __pyx_v_y;
  double __pyx_v_z;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rotate (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__angle,&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__z,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__angle)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rotate", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rotate", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__z)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rotate", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rotate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __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_angle = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_angle == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_x = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_x == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_y = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_y == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_z = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_z == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rotate", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.rotate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_4rotate(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self), __pyx_v_angle, __pyx_v_x, __pyx_v_y, __pyx_v_z);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":59
 *         self.identity()
 * 
 *     cpdef Matrix rotate(Matrix self, double angle, double x, double y, double z):             # <<<<<<<<<<<<<<
 *         '''Rotate the matrix with the angle, around the axis (x, y, z)
 *         '''
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_4rotate(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_angle, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rotate", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->rotate(__pyx_v_self, __pyx_v_angle, __pyx_v_x, __pyx_v_y, __pyx_v_z, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.rotate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":107
 *         return self
 * 
 *     cpdef Matrix scale(Matrix self, double x, double y, double z):             # <<<<<<<<<<<<<<
 *         '''Scale the matrix current Matrix (inplace).
 *         '''
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_7scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_f_4kivy_8graphics_14transformation_6Matrix_scale(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z, int __pyx_skip_dispatch) {
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__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;
  long __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("scale", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__scale); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_7scale)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_z); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4kivy_8graphics_14transformation_Matrix))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":110
 *         '''Scale the matrix current Matrix (inplace).
 *         '''
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self.mat[ 0] *= x;
 *             self.mat[ 5] *= y;
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "kivy\graphics\transformation.pyx":111
 *         '''
 *         with nogil:
 *             self.mat[ 0] *= x;             # <<<<<<<<<<<<<<
 *             self.mat[ 5] *= y;
 *             self.mat[10] *= z;
 */
        __pyx_t_6 = 0;
        (__pyx_v_self->mat[__pyx_t_6]) = ((__pyx_v_self->mat[__pyx_t_6]) * __pyx_v_x);

        /* "kivy\graphics\transformation.pyx":112
 *         with nogil:
 *             self.mat[ 0] *= x;
 *             self.mat[ 5] *= y;             # <<<<<<<<<<<<<<
 *             self.mat[10] *= z;
 *         return self
 */
        __pyx_t_6 = 5;
        (__pyx_v_self->mat[__pyx_t_6]) = ((__pyx_v_self->mat[__pyx_t_6]) * __pyx_v_y);

        /* "kivy\graphics\transformation.pyx":113
 *             self.mat[ 0] *= x;
 *             self.mat[ 5] *= y;
 *             self.mat[10] *= z;             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
        __pyx_t_6 = 10;
        (__pyx_v_self->mat[__pyx_t_6]) = ((__pyx_v_self->mat[__pyx_t_6]) * __pyx_v_z);
      }

      /* "kivy\graphics\transformation.pyx":110
 *         '''Scale the matrix current Matrix (inplace).
 *         '''
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self.mat[ 0] *= x;
 *             self.mat[ 5] *= y;
 */
      /*finally:*/ {
        #ifdef WITH_THREAD
        Py_BLOCK_THREADS
        #endif
      }
  }

  /* "kivy\graphics\transformation.pyx":114
 *             self.mat[ 5] *= y;
 *             self.mat[10] *= z;
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     cpdef Matrix translate(Matrix self, double x, double y, double z):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.scale", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_7scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_6scale[] = "Scale the matrix current Matrix (inplace).\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_7scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_x;
  double __pyx_v_y;
  double __pyx_v_z;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("scale (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__z,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("scale", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__z)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("scale", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scale") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_x = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_x == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_y = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_y == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_z = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_z == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("scale", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.scale", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_6scale(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self), __pyx_v_x, __pyx_v_y, __pyx_v_z);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":107
 *         return self
 * 
 *     cpdef Matrix scale(Matrix self, double x, double y, double z):             # <<<<<<<<<<<<<<
 *         '''Scale the matrix current Matrix (inplace).
 *         '''
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_6scale(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("scale", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->scale(__pyx_v_self, __pyx_v_x, __pyx_v_y, __pyx_v_z, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.scale", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":116
 *         return self
 * 
 *     cpdef Matrix translate(Matrix self, double x, double y, double z):             # <<<<<<<<<<<<<<
 *         '''Translate the matrix
 *         '''
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_9translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_f_4kivy_8graphics_14transformation_6Matrix_translate(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z, int __pyx_skip_dispatch) {
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__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;
  long __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("translate", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__translate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_9translate)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_z); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4kivy_8graphics_14transformation_Matrix))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":119
 *         '''Translate the matrix
 *         '''
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self.mat[12] += x
 *             self.mat[13] += y
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "kivy\graphics\transformation.pyx":120
 *         '''
 *         with nogil:
 *             self.mat[12] += x             # <<<<<<<<<<<<<<
 *             self.mat[13] += y
 *             self.mat[14] += z
 */
        __pyx_t_6 = 12;
        (__pyx_v_self->mat[__pyx_t_6]) = ((__pyx_v_self->mat[__pyx_t_6]) + __pyx_v_x);

        /* "kivy\graphics\transformation.pyx":121
 *         with nogil:
 *             self.mat[12] += x
 *             self.mat[13] += y             # <<<<<<<<<<<<<<
 *             self.mat[14] += z
 *         return self
 */
        __pyx_t_6 = 13;
        (__pyx_v_self->mat[__pyx_t_6]) = ((__pyx_v_self->mat[__pyx_t_6]) + __pyx_v_y);

        /* "kivy\graphics\transformation.pyx":122
 *             self.mat[12] += x
 *             self.mat[13] += y
 *             self.mat[14] += z             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
        __pyx_t_6 = 14;
        (__pyx_v_self->mat[__pyx_t_6]) = ((__pyx_v_self->mat[__pyx_t_6]) + __pyx_v_z);
      }

      /* "kivy\graphics\transformation.pyx":119
 *         '''Translate the matrix
 *         '''
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self.mat[12] += x
 *             self.mat[13] += y
 */
      /*finally:*/ {
        #ifdef WITH_THREAD
        Py_BLOCK_THREADS
        #endif
      }
  }

  /* "kivy\graphics\transformation.pyx":123
 *             self.mat[13] += y
 *             self.mat[14] += z
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     cpdef Matrix perspective(Matrix self, double fovy, double aspect,
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.translate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_9translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_8translate[] = "Translate the matrix\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_9translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_x;
  double __pyx_v_y;
  double __pyx_v_z;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("translate (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__z,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__z)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "translate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_x = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_x == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_y = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_y == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_z = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_z == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("translate", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.translate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_8translate(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self), __pyx_v_x, __pyx_v_y, __pyx_v_z);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":116
 *         return self
 * 
 *     cpdef Matrix translate(Matrix self, double x, double y, double z):             # <<<<<<<<<<<<<<
 *         '''Translate the matrix
 *         '''
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_8translate(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("translate", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->translate(__pyx_v_self, __pyx_v_x, __pyx_v_y, __pyx_v_z, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.translate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":125
 *         return self
 * 
 *     cpdef Matrix perspective(Matrix self, double fovy, double aspect,             # <<<<<<<<<<<<<<
 *             double zNear, double zFar):
 *         '''Creates a perspective matrix (inplace)
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_11perspective(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_f_4kivy_8graphics_14transformation_6Matrix_perspective(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_fovy, double __pyx_v_aspect, double __pyx_v_zNear, double __pyx_v_zFar, int __pyx_skip_dispatch) {
  double __pyx_v_f;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("perspective", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__perspective); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_11perspective)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_fovy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_aspect); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_zNear); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_zFar); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4kivy_8graphics_14transformation_Matrix))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_5);
      __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":131
 *         .. versionadded:: 1.6.0
 *         '''
 *         cdef double f = 1 / tan(fovy / 2. / 360. * 2 * 3.141592653589793)             # <<<<<<<<<<<<<<
 *         self.mat[0]  = f / aspect
 *         self.mat[1]  = 0.0
 */
  __pyx_v_f = (1.0 / tan(((((__pyx_v_fovy / 2.) / 360.) * 2.0) * 3.141592653589793)));

  /* "kivy\graphics\transformation.pyx":132
 *         '''
 *         cdef double f = 1 / tan(fovy / 2. / 360. * 2 * 3.141592653589793)
 *         self.mat[0]  = f / aspect             # <<<<<<<<<<<<<<
 *         self.mat[1]  = 0.0
 *         self.mat[2]  = 0.0
 */
  (__pyx_v_self->mat[0]) = (__pyx_v_f / __pyx_v_aspect);

  /* "kivy\graphics\transformation.pyx":133
 *         cdef double f = 1 / tan(fovy / 2. / 360. * 2 * 3.141592653589793)
 *         self.mat[0]  = f / aspect
 *         self.mat[1]  = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[2]  = 0.0
 *         self.mat[3]  = 0.0
 */
  (__pyx_v_self->mat[1]) = 0.0;

  /* "kivy\graphics\transformation.pyx":134
 *         self.mat[0]  = f / aspect
 *         self.mat[1]  = 0.0
 *         self.mat[2]  = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[3]  = 0.0
 *         self.mat[4]  = 0.0
 */
  (__pyx_v_self->mat[2]) = 0.0;

  /* "kivy\graphics\transformation.pyx":135
 *         self.mat[1]  = 0.0
 *         self.mat[2]  = 0.0
 *         self.mat[3]  = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[4]  = 0.0
 *         self.mat[5]  = f
 */
  (__pyx_v_self->mat[3]) = 0.0;

  /* "kivy\graphics\transformation.pyx":136
 *         self.mat[2]  = 0.0
 *         self.mat[3]  = 0.0
 *         self.mat[4]  = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[5]  = f
 *         self.mat[6]  = 0.0
 */
  (__pyx_v_self->mat[4]) = 0.0;

  /* "kivy\graphics\transformation.pyx":137
 *         self.mat[3]  = 0.0
 *         self.mat[4]  = 0.0
 *         self.mat[5]  = f             # <<<<<<<<<<<<<<
 *         self.mat[6]  = 0.0
 *         self.mat[7]  = 0.0
 */
  (__pyx_v_self->mat[5]) = __pyx_v_f;

  /* "kivy\graphics\transformation.pyx":138
 *         self.mat[4]  = 0.0
 *         self.mat[5]  = f
 *         self.mat[6]  = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[7]  = 0.0
 *         self.mat[8]  = 0.0
 */
  (__pyx_v_self->mat[6]) = 0.0;

  /* "kivy\graphics\transformation.pyx":139
 *         self.mat[5]  = f
 *         self.mat[6]  = 0.0
 *         self.mat[7]  = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[8]  = 0.0
 *         self.mat[9]  = 0.0
 */
  (__pyx_v_self->mat[7]) = 0.0;

  /* "kivy\graphics\transformation.pyx":140
 *         self.mat[6]  = 0.0
 *         self.mat[7]  = 0.0
 *         self.mat[8]  = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[9]  = 0.0
 *         self.mat[10] = (zFar + zNear) / (zNear - zFar)
 */
  (__pyx_v_self->mat[8]) = 0.0;

  /* "kivy\graphics\transformation.pyx":141
 *         self.mat[7]  = 0.0
 *         self.mat[8]  = 0.0
 *         self.mat[9]  = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[10] = (zFar + zNear) / (zNear - zFar)
 *         self.mat[11] = (2 * zFar * zNear) / (zNear - zFar)
 */
  (__pyx_v_self->mat[9]) = 0.0;

  /* "kivy\graphics\transformation.pyx":142
 *         self.mat[8]  = 0.0
 *         self.mat[9]  = 0.0
 *         self.mat[10] = (zFar + zNear) / (zNear - zFar)             # <<<<<<<<<<<<<<
 *         self.mat[11] = (2 * zFar * zNear) / (zNear - zFar)
 *         self.mat[12] = 0.0
 */
  (__pyx_v_self->mat[10]) = ((__pyx_v_zFar + __pyx_v_zNear) / (__pyx_v_zNear - __pyx_v_zFar));

  /* "kivy\graphics\transformation.pyx":143
 *         self.mat[9]  = 0.0
 *         self.mat[10] = (zFar + zNear) / (zNear - zFar)
 *         self.mat[11] = (2 * zFar * zNear) / (zNear - zFar)             # <<<<<<<<<<<<<<
 *         self.mat[12] = 0.0
 *         self.mat[13] = 0.0
 */
  (__pyx_v_self->mat[11]) = (((2.0 * __pyx_v_zFar) * __pyx_v_zNear) / (__pyx_v_zNear - __pyx_v_zFar));

  /* "kivy\graphics\transformation.pyx":144
 *         self.mat[10] = (zFar + zNear) / (zNear - zFar)
 *         self.mat[11] = (2 * zFar * zNear) / (zNear - zFar)
 *         self.mat[12] = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[13] = 0.0
 *         self.mat[14] = -1.0
 */
  (__pyx_v_self->mat[12]) = 0.0;

  /* "kivy\graphics\transformation.pyx":145
 *         self.mat[11] = (2 * zFar * zNear) / (zNear - zFar)
 *         self.mat[12] = 0.0
 *         self.mat[13] = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[14] = -1.0
 *         self.mat[15] = 0.0
 */
  (__pyx_v_self->mat[13]) = 0.0;

  /* "kivy\graphics\transformation.pyx":146
 *         self.mat[12] = 0.0
 *         self.mat[13] = 0.0
 *         self.mat[14] = -1.0             # <<<<<<<<<<<<<<
 *         self.mat[15] = 0.0
 * 
 */
  (__pyx_v_self->mat[14]) = -1.0;

  /* "kivy\graphics\transformation.pyx":147
 *         self.mat[13] = 0.0
 *         self.mat[14] = -1.0
 *         self.mat[15] = 0.0             # <<<<<<<<<<<<<<
 * 
 *     cpdef Matrix view_clip(Matrix self, double left, double right,
 */
  (__pyx_v_self->mat[15]) = 0.0;

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.perspective", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_11perspective(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_10perspective[] = "Creates a perspective matrix (inplace)\n\n        .. versionadded:: 1.6.0\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_11perspective(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_fovy;
  double __pyx_v_aspect;
  double __pyx_v_zNear;
  double __pyx_v_zFar;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("perspective (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fovy,&__pyx_n_s__aspect,&__pyx_n_s__zNear,&__pyx_n_s__zFar,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__fovy)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__aspect)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("perspective", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__zNear)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("perspective", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__zFar)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("perspective", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "perspective") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __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_fovy = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_fovy == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_aspect = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_aspect == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_zNear = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_zNear == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_zFar = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_zFar == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("perspective", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.perspective", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_10perspective(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self), __pyx_v_fovy, __pyx_v_aspect, __pyx_v_zNear, __pyx_v_zFar);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":125
 *         return self
 * 
 *     cpdef Matrix perspective(Matrix self, double fovy, double aspect,             # <<<<<<<<<<<<<<
 *             double zNear, double zFar):
 *         '''Creates a perspective matrix (inplace)
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_10perspective(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_fovy, double __pyx_v_aspect, double __pyx_v_zNear, double __pyx_v_zFar) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("perspective", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->perspective(__pyx_v_self, __pyx_v_fovy, __pyx_v_aspect, __pyx_v_zNear, __pyx_v_zFar, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.perspective", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":149
 *         self.mat[15] = 0.0
 * 
 *     cpdef Matrix view_clip(Matrix self, double left, double right,             # <<<<<<<<<<<<<<
 *             double bottom, double top,
 *             double near, double far, int perspective):
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_13view_clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_f_4kivy_8graphics_14transformation_6Matrix_view_clip(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_left, double __pyx_v_right, double __pyx_v_bottom, double __pyx_v_top, double __pyx_v_near, double __pyx_v_far, int __pyx_v_perspective, int __pyx_skip_dispatch) {
  double __pyx_v_t;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("view_clip", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__view_clip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_13view_clip)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_left); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_right); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_bottom); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_top); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyFloat_FromDouble(__pyx_v_near); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyFloat_FromDouble(__pyx_v_far); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyInt_FromLong(__pyx_v_perspective); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyTuple_New(7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 5, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_9, 6, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_4kivy_8graphics_14transformation_Matrix))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_8);
      __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":158
 *         '''
 *         cdef double t
 *         if left >= right or bottom >= top or near >= far:             # <<<<<<<<<<<<<<
 *             raise ValueError('invalid frustrum')
 *         if perspective and near <= _EPS:
 */
  __pyx_t_10 = ((__pyx_v_left >= __pyx_v_right) != 0);
  if (!__pyx_t_10) {
    __pyx_t_11 = ((__pyx_v_bottom >= __pyx_v_top) != 0);
    if (!__pyx_t_11) {
      __pyx_t_12 = ((__pyx_v_near >= __pyx_v_far) != 0);
      __pyx_t_13 = __pyx_t_12;
    } else {
      __pyx_t_13 = __pyx_t_11;
    }
    __pyx_t_11 = __pyx_t_13;
  } else {
    __pyx_t_11 = __pyx_t_10;
  }
  if (__pyx_t_11) {

    /* "kivy\graphics\transformation.pyx":159
 *         cdef double t
 *         if left >= right or bottom >= top or near >= far:
 *             raise ValueError('invalid frustrum')             # <<<<<<<<<<<<<<
 *         if perspective and near <= _EPS:
 *             raise ValueError('invalid frustrum: near <= 0')
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\transformation.pyx":160
 *         if left >= right or bottom >= top or near >= far:
 *             raise ValueError('invalid frustrum')
 *         if perspective and near <= _EPS:             # <<<<<<<<<<<<<<
 *             raise ValueError('invalid frustrum: near <= 0')
 * 
 */
  if ((__pyx_v_perspective != 0)) {
    __pyx_t_11 = (__pyx_v_near <= __pyx_v_4kivy_8graphics_14transformation__EPS);
    __pyx_t_10 = __pyx_t_11;
  } else {
    __pyx_t_10 = (__pyx_v_perspective != 0);
  }
  if (__pyx_t_10) {

    /* "kivy\graphics\transformation.pyx":161
 *             raise ValueError('invalid frustrum')
 *         if perspective and near <= _EPS:
 *             raise ValueError('invalid frustrum: near <= 0')             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "kivy\graphics\transformation.pyx":163
 *             raise ValueError('invalid frustrum: near <= 0')
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if perspective:
 *                 t = 2.0 * near
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "kivy\graphics\transformation.pyx":164
 * 
 *         with nogil:
 *             if perspective:             # <<<<<<<<<<<<<<
 *                 t = 2.0 * near
 *                 self.mat[0]  = t/(right-left)
 */
        __pyx_t_10 = (__pyx_v_perspective != 0);
        if (__pyx_t_10) {

          /* "kivy\graphics\transformation.pyx":165
 *         with nogil:
 *             if perspective:
 *                 t = 2.0 * near             # <<<<<<<<<<<<<<
 *                 self.mat[0]  = t/(right-left)
 *                 self.mat[4]  = 0.0
 */
          __pyx_v_t = (2.0 * __pyx_v_near);

          /* "kivy\graphics\transformation.pyx":166
 *             if perspective:
 *                 t = 2.0 * near
 *                 self.mat[0]  = t/(right-left)             # <<<<<<<<<<<<<<
 *                 self.mat[4]  = 0.0
 *                 self.mat[8]  = (right+left)/(right-left)
 */
          (__pyx_v_self->mat[0]) = (__pyx_v_t / (__pyx_v_right - __pyx_v_left));

          /* "kivy\graphics\transformation.pyx":167
 *                 t = 2.0 * near
 *                 self.mat[0]  = t/(right-left)
 *                 self.mat[4]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[8]  = (right+left)/(right-left)
 *                 self.mat[12] = 0.0
 */
          (__pyx_v_self->mat[4]) = 0.0;

          /* "kivy\graphics\transformation.pyx":168
 *                 self.mat[0]  = t/(right-left)
 *                 self.mat[4]  = 0.0
 *                 self.mat[8]  = (right+left)/(right-left)             # <<<<<<<<<<<<<<
 *                 self.mat[12] = 0.0
 *                 self.mat[1]  = 0.0
 */
          (__pyx_v_self->mat[8]) = ((__pyx_v_right + __pyx_v_left) / (__pyx_v_right - __pyx_v_left));

          /* "kivy\graphics\transformation.pyx":169
 *                 self.mat[4]  = 0.0
 *                 self.mat[8]  = (right+left)/(right-left)
 *                 self.mat[12] = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[1]  = 0.0
 *                 self.mat[5]  = t/(top-bottom)
 */
          (__pyx_v_self->mat[12]) = 0.0;

          /* "kivy\graphics\transformation.pyx":170
 *                 self.mat[8]  = (right+left)/(right-left)
 *                 self.mat[12] = 0.0
 *                 self.mat[1]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[5]  = t/(top-bottom)
 *                 self.mat[9]  = (top+bottom)/(top-bottom)
 */
          (__pyx_v_self->mat[1]) = 0.0;

          /* "kivy\graphics\transformation.pyx":171
 *                 self.mat[12] = 0.0
 *                 self.mat[1]  = 0.0
 *                 self.mat[5]  = t/(top-bottom)             # <<<<<<<<<<<<<<
 *                 self.mat[9]  = (top+bottom)/(top-bottom)
 *                 self.mat[13] = 0.0
 */
          (__pyx_v_self->mat[5]) = (__pyx_v_t / (__pyx_v_top - __pyx_v_bottom));

          /* "kivy\graphics\transformation.pyx":172
 *                 self.mat[1]  = 0.0
 *                 self.mat[5]  = t/(top-bottom)
 *                 self.mat[9]  = (top+bottom)/(top-bottom)             # <<<<<<<<<<<<<<
 *                 self.mat[13] = 0.0
 *                 self.mat[2]  = 0.0
 */
          (__pyx_v_self->mat[9]) = ((__pyx_v_top + __pyx_v_bottom) / (__pyx_v_top - __pyx_v_bottom));

          /* "kivy\graphics\transformation.pyx":173
 *                 self.mat[5]  = t/(top-bottom)
 *                 self.mat[9]  = (top+bottom)/(top-bottom)
 *                 self.mat[13] = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[2]  = 0.0
 *                 self.mat[6]  = 0.0
 */
          (__pyx_v_self->mat[13]) = 0.0;

          /* "kivy\graphics\transformation.pyx":174
 *                 self.mat[9]  = (top+bottom)/(top-bottom)
 *                 self.mat[13] = 0.0
 *                 self.mat[2]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[6]  = 0.0
 *                 self.mat[10] = -(far+near)/(far-near)
 */
          (__pyx_v_self->mat[2]) = 0.0;

          /* "kivy\graphics\transformation.pyx":175
 *                 self.mat[13] = 0.0
 *                 self.mat[2]  = 0.0
 *                 self.mat[6]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[10] = -(far+near)/(far-near)
 *                 self.mat[14] = (-t*far)/(far-near)
 */
          (__pyx_v_self->mat[6]) = 0.0;

          /* "kivy\graphics\transformation.pyx":176
 *                 self.mat[2]  = 0.0
 *                 self.mat[6]  = 0.0
 *                 self.mat[10] = -(far+near)/(far-near)             # <<<<<<<<<<<<<<
 *                 self.mat[14] = (-t*far)/(far-near)
 *                 self.mat[3]  = 0.0
 */
          (__pyx_v_self->mat[10]) = ((-(__pyx_v_far + __pyx_v_near)) / (__pyx_v_far - __pyx_v_near));

          /* "kivy\graphics\transformation.pyx":177
 *                 self.mat[6]  = 0.0
 *                 self.mat[10] = -(far+near)/(far-near)
 *                 self.mat[14] = (-t*far)/(far-near)             # <<<<<<<<<<<<<<
 *                 self.mat[3]  = 0.0
 *                 self.mat[7]  = 0.0
 */
          (__pyx_v_self->mat[14]) = (((-__pyx_v_t) * __pyx_v_far) / (__pyx_v_far - __pyx_v_near));

          /* "kivy\graphics\transformation.pyx":178
 *                 self.mat[10] = -(far+near)/(far-near)
 *                 self.mat[14] = (-t*far)/(far-near)
 *                 self.mat[3]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[7]  = 0.0
 *                 self.mat[11] = -1.0
 */
          (__pyx_v_self->mat[3]) = 0.0;

          /* "kivy\graphics\transformation.pyx":179
 *                 self.mat[14] = (-t*far)/(far-near)
 *                 self.mat[3]  = 0.0
 *                 self.mat[7]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[11] = -1.0
 *                 self.mat[15] = 0.0
 */
          (__pyx_v_self->mat[7]) = 0.0;

          /* "kivy\graphics\transformation.pyx":180
 *                 self.mat[3]  = 0.0
 *                 self.mat[7]  = 0.0
 *                 self.mat[11] = -1.0             # <<<<<<<<<<<<<<
 *                 self.mat[15] = 0.0
 *             else:
 */
          (__pyx_v_self->mat[11]) = -1.0;

          /* "kivy\graphics\transformation.pyx":181
 *                 self.mat[7]  = 0.0
 *                 self.mat[11] = -1.0
 *                 self.mat[15] = 0.0             # <<<<<<<<<<<<<<
 *             else:
 *                 #(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15)
 */
          (__pyx_v_self->mat[15]) = 0.0;
          goto __pyx_L8;
        }
        /*else*/ {

          /* "kivy\graphics\transformation.pyx":184
 *             else:
 *                 #(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15)
 *                 self.mat[0]  = 2.0/(right-left)             # <<<<<<<<<<<<<<
 *                 self.mat[4]  = 0.0
 *                 self.mat[8]  = 0.0
 */
          (__pyx_v_self->mat[0]) = (2.0 / (__pyx_v_right - __pyx_v_left));

          /* "kivy\graphics\transformation.pyx":185
 *                 #(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15)
 *                 self.mat[0]  = 2.0/(right-left)
 *                 self.mat[4]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[8]  = 0.0
 *                 self.mat[12] = (right+left)/(left-right)
 */
          (__pyx_v_self->mat[4]) = 0.0;

          /* "kivy\graphics\transformation.pyx":186
 *                 self.mat[0]  = 2.0/(right-left)
 *                 self.mat[4]  = 0.0
 *                 self.mat[8]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[12] = (right+left)/(left-right)
 *                 self.mat[1]  = 0.0
 */
          (__pyx_v_self->mat[8]) = 0.0;

          /* "kivy\graphics\transformation.pyx":187
 *                 self.mat[4]  = 0.0
 *                 self.mat[8]  = 0.0
 *                 self.mat[12] = (right+left)/(left-right)             # <<<<<<<<<<<<<<
 *                 self.mat[1]  = 0.0
 *                 self.mat[5]  = 2.0/(top-bottom)
 */
          (__pyx_v_self->mat[12]) = ((__pyx_v_right + __pyx_v_left) / (__pyx_v_left - __pyx_v_right));

          /* "kivy\graphics\transformation.pyx":188
 *                 self.mat[8]  = 0.0
 *                 self.mat[12] = (right+left)/(left-right)
 *                 self.mat[1]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[5]  = 2.0/(top-bottom)
 *                 self.mat[9]  = 0.0
 */
          (__pyx_v_self->mat[1]) = 0.0;

          /* "kivy\graphics\transformation.pyx":189
 *                 self.mat[12] = (right+left)/(left-right)
 *                 self.mat[1]  = 0.0
 *                 self.mat[5]  = 2.0/(top-bottom)             # <<<<<<<<<<<<<<
 *                 self.mat[9]  = 0.0
 *                 self.mat[13] = (top+bottom)/(bottom-top)
 */
          (__pyx_v_self->mat[5]) = (2.0 / (__pyx_v_top - __pyx_v_bottom));

          /* "kivy\graphics\transformation.pyx":190
 *                 self.mat[1]  = 0.0
 *                 self.mat[5]  = 2.0/(top-bottom)
 *                 self.mat[9]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[13] = (top+bottom)/(bottom-top)
 *                 self.mat[2]  = 0.0
 */
          (__pyx_v_self->mat[9]) = 0.0;

          /* "kivy\graphics\transformation.pyx":191
 *                 self.mat[5]  = 2.0/(top-bottom)
 *                 self.mat[9]  = 0.0
 *                 self.mat[13] = (top+bottom)/(bottom-top)             # <<<<<<<<<<<<<<
 *                 self.mat[2]  = 0.0
 *                 self.mat[6]  = 0.0
 */
          (__pyx_v_self->mat[13]) = ((__pyx_v_top + __pyx_v_bottom) / (__pyx_v_bottom - __pyx_v_top));

          /* "kivy\graphics\transformation.pyx":192
 *                 self.mat[9]  = 0.0
 *                 self.mat[13] = (top+bottom)/(bottom-top)
 *                 self.mat[2]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[6]  = 0.0
 *                 self.mat[10] = 2.0/(far-near)
 */
          (__pyx_v_self->mat[2]) = 0.0;

          /* "kivy\graphics\transformation.pyx":193
 *                 self.mat[13] = (top+bottom)/(bottom-top)
 *                 self.mat[2]  = 0.0
 *                 self.mat[6]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[10] = 2.0/(far-near)
 *                 self.mat[14] = (far+near)/(near-far)
 */
          (__pyx_v_self->mat[6]) = 0.0;

          /* "kivy\graphics\transformation.pyx":194
 *                 self.mat[2]  = 0.0
 *                 self.mat[6]  = 0.0
 *                 self.mat[10] = 2.0/(far-near)             # <<<<<<<<<<<<<<
 *                 self.mat[14] = (far+near)/(near-far)
 *                 self.mat[3]  = 0.0
 */
          (__pyx_v_self->mat[10]) = (2.0 / (__pyx_v_far - __pyx_v_near));

          /* "kivy\graphics\transformation.pyx":195
 *                 self.mat[6]  = 0.0
 *                 self.mat[10] = 2.0/(far-near)
 *                 self.mat[14] = (far+near)/(near-far)             # <<<<<<<<<<<<<<
 *                 self.mat[3]  = 0.0
 *                 self.mat[7]  = 0.0
 */
          (__pyx_v_self->mat[14]) = ((__pyx_v_far + __pyx_v_near) / (__pyx_v_near - __pyx_v_far));

          /* "kivy\graphics\transformation.pyx":196
 *                 self.mat[10] = 2.0/(far-near)
 *                 self.mat[14] = (far+near)/(near-far)
 *                 self.mat[3]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[7]  = 0.0
 *                 self.mat[11] = 0.0
 */
          (__pyx_v_self->mat[3]) = 0.0;

          /* "kivy\graphics\transformation.pyx":197
 *                 self.mat[14] = (far+near)/(near-far)
 *                 self.mat[3]  = 0.0
 *                 self.mat[7]  = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[11] = 0.0
 *                 self.mat[15] = 1.0
 */
          (__pyx_v_self->mat[7]) = 0.0;

          /* "kivy\graphics\transformation.pyx":198
 *                 self.mat[3]  = 0.0
 *                 self.mat[7]  = 0.0
 *                 self.mat[11] = 0.0             # <<<<<<<<<<<<<<
 *                 self.mat[15] = 1.0
 *         return self
 */
          (__pyx_v_self->mat[11]) = 0.0;

          /* "kivy\graphics\transformation.pyx":199
 *                 self.mat[7]  = 0.0
 *                 self.mat[11] = 0.0
 *                 self.mat[15] = 1.0             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
          (__pyx_v_self->mat[15]) = 1.0;
        }
        __pyx_L8:;
      }

      /* "kivy\graphics\transformation.pyx":163
 *             raise ValueError('invalid frustrum: near <= 0')
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if perspective:
 *                 t = 2.0 * near
 */
      /*finally:*/ {
        #ifdef WITH_THREAD
        Py_BLOCK_THREADS
        #endif
      }
  }

  /* "kivy\graphics\transformation.pyx":200
 *                 self.mat[11] = 0.0
 *                 self.mat[15] = 1.0
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     cpdef look_at(Matrix self, double eyex, double eyey, double eyez,
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.view_clip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_13view_clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_12view_clip[] = "Create a clip matrix (inplace)\n\n        .. versionchanged:: 1.6.0\n            Enable support for perspective parameter\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_13view_clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_left;
  double __pyx_v_right;
  double __pyx_v_bottom;
  double __pyx_v_top;
  double __pyx_v_near;
  double __pyx_v_far;
  int __pyx_v_perspective;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("view_clip (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__left,&__pyx_n_s__right,&__pyx_n_s__bottom,&__pyx_n_s__top,&__pyx_n_s__near,&__pyx_n_s__far,&__pyx_n_s__perspective,0};
    PyObject* values[7] = {0,0,0,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  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__left)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__right)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("view_clip", 1, 7, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bottom)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("view_clip", 1, 7, 7, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__top)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("view_clip", 1, 7, 7, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__near)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("view_clip", 1, 7, 7, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__far)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("view_clip", 1, 7, 7, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__perspective)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("view_clip", 1, 7, 7, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "view_clip") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
      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);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
    }
    __pyx_v_left = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_left == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_right = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_right == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_bottom = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_bottom == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_top = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_top == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_near = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_near == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_far = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_far == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_perspective = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_perspective == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("view_clip", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.view_clip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_12view_clip(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self), __pyx_v_left, __pyx_v_right, __pyx_v_bottom, __pyx_v_top, __pyx_v_near, __pyx_v_far, __pyx_v_perspective);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":149
 *         self.mat[15] = 0.0
 * 
 *     cpdef Matrix view_clip(Matrix self, double left, double right,             # <<<<<<<<<<<<<<
 *             double bottom, double top,
 *             double near, double far, int perspective):
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_12view_clip(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_left, double __pyx_v_right, double __pyx_v_bottom, double __pyx_v_top, double __pyx_v_near, double __pyx_v_far, int __pyx_v_perspective) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("view_clip", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->view_clip(__pyx_v_self, __pyx_v_left, __pyx_v_right, __pyx_v_bottom, __pyx_v_top, __pyx_v_near, __pyx_v_far, __pyx_v_perspective, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.view_clip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":202
 *         return self
 * 
 *     cpdef look_at(Matrix self, double eyex, double eyey, double eyez,             # <<<<<<<<<<<<<<
 *           double centerx, double centery, double centerz,
 *           double upx, double upy, double upz):
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_15look_at(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4kivy_8graphics_14transformation_6Matrix_look_at(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_eyex, double __pyx_v_eyey, double __pyx_v_eyez, double __pyx_v_centerx, double __pyx_v_centery, double __pyx_v_centerz, double __pyx_v_upx, double __pyx_v_upy, double __pyx_v_upz, int __pyx_skip_dispatch) {
  double __pyx_v_x[3];
  double __pyx_v_y[3];
  double __pyx_v_z[3];
  double __pyx_v_mag;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_m = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  long __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("look_at", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__look_at); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_15look_at)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_eyex); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_eyey); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_eyez); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_centerx); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyFloat_FromDouble(__pyx_v_centery); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyFloat_FromDouble(__pyx_v_centerz); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyFloat_FromDouble(__pyx_v_upx); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_upy); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyFloat_FromDouble(__pyx_v_upz); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = PyTuple_New(9); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 4, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 6, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_11, 7, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_11, 8, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_8 = 0;
      __pyx_t_9 = 0;
      __pyx_t_10 = 0;
      __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
      __pyx_r = __pyx_t_10;
      __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":215
 *         # Make rotation matrix
 *         # Z vector
 *         z[0] = eyex - centerx             # <<<<<<<<<<<<<<
 *         z[1] = eyey - centery
 *         z[2] = eyez - centerz
 */
  (__pyx_v_z[0]) = (__pyx_v_eyex - __pyx_v_centerx);

  /* "kivy\graphics\transformation.pyx":216
 *         # Z vector
 *         z[0] = eyex - centerx
 *         z[1] = eyey - centery             # <<<<<<<<<<<<<<
 *         z[2] = eyez - centerz
 *         mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2])
 */
  (__pyx_v_z[1]) = (__pyx_v_eyey - __pyx_v_centery);

  /* "kivy\graphics\transformation.pyx":217
 *         z[0] = eyex - centerx
 *         z[1] = eyey - centery
 *         z[2] = eyez - centerz             # <<<<<<<<<<<<<<
 *         mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2])
 *         if (mag):          # mpichler, 19950515
 */
  (__pyx_v_z[2]) = (__pyx_v_eyez - __pyx_v_centerz);

  /* "kivy\graphics\transformation.pyx":218
 *         z[1] = eyey - centery
 *         z[2] = eyez - centerz
 *         mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2])             # <<<<<<<<<<<<<<
 *         if (mag):          # mpichler, 19950515
 *             z[0] /= mag
 */
  __pyx_v_mag = sqrt(((((__pyx_v_z[0]) * (__pyx_v_z[0])) + ((__pyx_v_z[1]) * (__pyx_v_z[1]))) + ((__pyx_v_z[2]) * (__pyx_v_z[2]))));

  /* "kivy\graphics\transformation.pyx":219
 *         z[2] = eyez - centerz
 *         mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2])
 *         if (mag):          # mpichler, 19950515             # <<<<<<<<<<<<<<
 *             z[0] /= mag
 *             z[1] /= mag
 */
  __pyx_t_12 = (__pyx_v_mag != 0);
  if (__pyx_t_12) {

    /* "kivy\graphics\transformation.pyx":220
 *         mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2])
 *         if (mag):          # mpichler, 19950515
 *             z[0] /= mag             # <<<<<<<<<<<<<<
 *             z[1] /= mag
 *             z[2] /= mag
 */
    __pyx_t_13 = 0;
    (__pyx_v_z[__pyx_t_13]) = ((__pyx_v_z[__pyx_t_13]) / __pyx_v_mag);

    /* "kivy\graphics\transformation.pyx":221
 *         if (mag):          # mpichler, 19950515
 *             z[0] /= mag
 *             z[1] /= mag             # <<<<<<<<<<<<<<
 *             z[2] /= mag
 * 
 */
    __pyx_t_13 = 1;
    (__pyx_v_z[__pyx_t_13]) = ((__pyx_v_z[__pyx_t_13]) / __pyx_v_mag);

    /* "kivy\graphics\transformation.pyx":222
 *             z[0] /= mag
 *             z[1] /= mag
 *             z[2] /= mag             # <<<<<<<<<<<<<<
 * 
 *         # Y vector
 */
    __pyx_t_13 = 2;
    (__pyx_v_z[__pyx_t_13]) = ((__pyx_v_z[__pyx_t_13]) / __pyx_v_mag);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\transformation.pyx":225
 * 
 *         # Y vector
 *         y[0] = upx             # <<<<<<<<<<<<<<
 *         y[1] = upy
 *         y[2] = upz
 */
  (__pyx_v_y[0]) = __pyx_v_upx;

  /* "kivy\graphics\transformation.pyx":226
 *         # Y vector
 *         y[0] = upx
 *         y[1] = upy             # <<<<<<<<<<<<<<
 *         y[2] = upz
 * 
 */
  (__pyx_v_y[1]) = __pyx_v_upy;

  /* "kivy\graphics\transformation.pyx":227
 *         y[0] = upx
 *         y[1] = upy
 *         y[2] = upz             # <<<<<<<<<<<<<<
 * 
 *         # X vector = Y cross Z
 */
  (__pyx_v_y[2]) = __pyx_v_upz;

  /* "kivy\graphics\transformation.pyx":230
 * 
 *         # X vector = Y cross Z
 *         x[0] = y[1] * z[2] - y[2] * z[1]             # <<<<<<<<<<<<<<
 *         x[1] = -y[0] * z[2] + y[2] * z[0]
 *         x[2] = y[0] * z[1] - y[1] * z[0]
 */
  (__pyx_v_x[0]) = (((__pyx_v_y[1]) * (__pyx_v_z[2])) - ((__pyx_v_y[2]) * (__pyx_v_z[1])));

  /* "kivy\graphics\transformation.pyx":231
 *         # X vector = Y cross Z
 *         x[0] = y[1] * z[2] - y[2] * z[1]
 *         x[1] = -y[0] * z[2] + y[2] * z[0]             # <<<<<<<<<<<<<<
 *         x[2] = y[0] * z[1] - y[1] * z[0]
 * 
 */
  (__pyx_v_x[1]) = (((-(__pyx_v_y[0])) * (__pyx_v_z[2])) + ((__pyx_v_y[2]) * (__pyx_v_z[0])));

  /* "kivy\graphics\transformation.pyx":232
 *         x[0] = y[1] * z[2] - y[2] * z[1]
 *         x[1] = -y[0] * z[2] + y[2] * z[0]
 *         x[2] = y[0] * z[1] - y[1] * z[0]             # <<<<<<<<<<<<<<
 * 
 *         # Recompute Y = Z cross X
 */
  (__pyx_v_x[2]) = (((__pyx_v_y[0]) * (__pyx_v_z[1])) - ((__pyx_v_y[1]) * (__pyx_v_z[0])));

  /* "kivy\graphics\transformation.pyx":235
 * 
 *         # Recompute Y = Z cross X
 *         y[0] = z[1] * x[2] - z[2] * x[1]             # <<<<<<<<<<<<<<
 *         y[1] = -z[0] * x[2] + z[2] * x[0]
 *         y[2] = z[0] * x[1] - z[1] * x[0]
 */
  (__pyx_v_y[0]) = (((__pyx_v_z[1]) * (__pyx_v_x[2])) - ((__pyx_v_z[2]) * (__pyx_v_x[1])));

  /* "kivy\graphics\transformation.pyx":236
 *         # Recompute Y = Z cross X
 *         y[0] = z[1] * x[2] - z[2] * x[1]
 *         y[1] = -z[0] * x[2] + z[2] * x[0]             # <<<<<<<<<<<<<<
 *         y[2] = z[0] * x[1] - z[1] * x[0]
 * 
 */
  (__pyx_v_y[1]) = (((-(__pyx_v_z[0])) * (__pyx_v_x[2])) + ((__pyx_v_z[2]) * (__pyx_v_x[0])));

  /* "kivy\graphics\transformation.pyx":237
 *         y[0] = z[1] * x[2] - z[2] * x[1]
 *         y[1] = -z[0] * x[2] + z[2] * x[0]
 *         y[2] = z[0] * x[1] - z[1] * x[0]             # <<<<<<<<<<<<<<
 * 
 *         # mpichler, 19950515
 */
  (__pyx_v_y[2]) = (((__pyx_v_z[0]) * (__pyx_v_x[1])) - ((__pyx_v_z[1]) * (__pyx_v_x[0])));

  /* "kivy\graphics\transformation.pyx":242
 *         # cross product gives area of parallelogram, which is < 1.0 for
 *         # non-perpendicular unit-length vectors so normalize x, y here
 *         mag = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2])             # <<<<<<<<<<<<<<
 *         if (mag):
 *             x[0] /= mag
 */
  __pyx_v_mag = sqrt(((((__pyx_v_x[0]) * (__pyx_v_x[0])) + ((__pyx_v_x[1]) * (__pyx_v_x[1]))) + ((__pyx_v_x[2]) * (__pyx_v_x[2]))));

  /* "kivy\graphics\transformation.pyx":243
 *         # non-perpendicular unit-length vectors so normalize x, y here
 *         mag = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2])
 *         if (mag):             # <<<<<<<<<<<<<<
 *             x[0] /= mag
 *             x[1] /= mag
 */
  __pyx_t_12 = (__pyx_v_mag != 0);
  if (__pyx_t_12) {

    /* "kivy\graphics\transformation.pyx":244
 *         mag = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2])
 *         if (mag):
 *             x[0] /= mag             # <<<<<<<<<<<<<<
 *             x[1] /= mag
 *             x[2] /= mag
 */
    __pyx_t_13 = 0;
    (__pyx_v_x[__pyx_t_13]) = ((__pyx_v_x[__pyx_t_13]) / __pyx_v_mag);

    /* "kivy\graphics\transformation.pyx":245
 *         if (mag):
 *             x[0] /= mag
 *             x[1] /= mag             # <<<<<<<<<<<<<<
 *             x[2] /= mag
 * 
 */
    __pyx_t_13 = 1;
    (__pyx_v_x[__pyx_t_13]) = ((__pyx_v_x[__pyx_t_13]) / __pyx_v_mag);

    /* "kivy\graphics\transformation.pyx":246
 *             x[0] /= mag
 *             x[1] /= mag
 *             x[2] /= mag             # <<<<<<<<<<<<<<
 * 
 *         mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2])
 */
    __pyx_t_13 = 2;
    (__pyx_v_x[__pyx_t_13]) = ((__pyx_v_x[__pyx_t_13]) / __pyx_v_mag);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "kivy\graphics\transformation.pyx":248
 *             x[2] /= mag
 * 
 *         mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2])             # <<<<<<<<<<<<<<
 *         if (mag):
 *             y[0] /= mag
 */
  __pyx_v_mag = sqrt(((((__pyx_v_y[0]) * (__pyx_v_y[0])) + ((__pyx_v_y[1]) * (__pyx_v_y[1]))) + ((__pyx_v_y[2]) * (__pyx_v_y[2]))));

  /* "kivy\graphics\transformation.pyx":249
 * 
 *         mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2])
 *         if (mag):             # <<<<<<<<<<<<<<
 *             y[0] /= mag
 *             y[1] /= mag
 */
  __pyx_t_12 = (__pyx_v_mag != 0);
  if (__pyx_t_12) {

    /* "kivy\graphics\transformation.pyx":250
 *         mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2])
 *         if (mag):
 *             y[0] /= mag             # <<<<<<<<<<<<<<
 *             y[1] /= mag
 *             y[2] /= mag
 */
    __pyx_t_13 = 0;
    (__pyx_v_y[__pyx_t_13]) = ((__pyx_v_y[__pyx_t_13]) / __pyx_v_mag);

    /* "kivy\graphics\transformation.pyx":251
 *         if (mag):
 *             y[0] /= mag
 *             y[1] /= mag             # <<<<<<<<<<<<<<
 *             y[2] /= mag
 * 
 */
    __pyx_t_13 = 1;
    (__pyx_v_y[__pyx_t_13]) = ((__pyx_v_y[__pyx_t_13]) / __pyx_v_mag);

    /* "kivy\graphics\transformation.pyx":252
 *             y[0] /= mag
 *             y[1] /= mag
 *             y[2] /= mag             # <<<<<<<<<<<<<<
 * 
 *         self.mat[0 + 0 * 4] = x[0]
 */
    __pyx_t_13 = 2;
    (__pyx_v_y[__pyx_t_13]) = ((__pyx_v_y[__pyx_t_13]) / __pyx_v_mag);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "kivy\graphics\transformation.pyx":254
 *             y[2] /= mag
 * 
 *         self.mat[0 + 0 * 4] = x[0]             # <<<<<<<<<<<<<<
 *         self.mat[0 + 1 * 4] = x[1]
 *         self.mat[0 + 2 * 4] = x[2]
 */
  (__pyx_v_self->mat[0]) = (__pyx_v_x[0]);

  /* "kivy\graphics\transformation.pyx":255
 * 
 *         self.mat[0 + 0 * 4] = x[0]
 *         self.mat[0 + 1 * 4] = x[1]             # <<<<<<<<<<<<<<
 *         self.mat[0 + 2 * 4] = x[2]
 *         self.mat[0 + 3 * 4] = 0.0
 */
  (__pyx_v_self->mat[4]) = (__pyx_v_x[1]);

  /* "kivy\graphics\transformation.pyx":256
 *         self.mat[0 + 0 * 4] = x[0]
 *         self.mat[0 + 1 * 4] = x[1]
 *         self.mat[0 + 2 * 4] = x[2]             # <<<<<<<<<<<<<<
 *         self.mat[0 + 3 * 4] = 0.0
 *         self.mat[1 + 0 * 4] = y[0]
 */
  (__pyx_v_self->mat[8]) = (__pyx_v_x[2]);

  /* "kivy\graphics\transformation.pyx":257
 *         self.mat[0 + 1 * 4] = x[1]
 *         self.mat[0 + 2 * 4] = x[2]
 *         self.mat[0 + 3 * 4] = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[1 + 0 * 4] = y[0]
 *         self.mat[1 + 1 * 4] = y[1]
 */
  (__pyx_v_self->mat[12]) = 0.0;

  /* "kivy\graphics\transformation.pyx":258
 *         self.mat[0 + 2 * 4] = x[2]
 *         self.mat[0 + 3 * 4] = 0.0
 *         self.mat[1 + 0 * 4] = y[0]             # <<<<<<<<<<<<<<
 *         self.mat[1 + 1 * 4] = y[1]
 *         self.mat[1 + 2 * 4] = y[2]
 */
  (__pyx_v_self->mat[1]) = (__pyx_v_y[0]);

  /* "kivy\graphics\transformation.pyx":259
 *         self.mat[0 + 3 * 4] = 0.0
 *         self.mat[1 + 0 * 4] = y[0]
 *         self.mat[1 + 1 * 4] = y[1]             # <<<<<<<<<<<<<<
 *         self.mat[1 + 2 * 4] = y[2]
 *         self.mat[1 + 3 * 4] = 0.0
 */
  (__pyx_v_self->mat[5]) = (__pyx_v_y[1]);

  /* "kivy\graphics\transformation.pyx":260
 *         self.mat[1 + 0 * 4] = y[0]
 *         self.mat[1 + 1 * 4] = y[1]
 *         self.mat[1 + 2 * 4] = y[2]             # <<<<<<<<<<<<<<
 *         self.mat[1 + 3 * 4] = 0.0
 *         self.mat[2 + 0 * 4] = z[0]
 */
  (__pyx_v_self->mat[9]) = (__pyx_v_y[2]);

  /* "kivy\graphics\transformation.pyx":261
 *         self.mat[1 + 1 * 4] = y[1]
 *         self.mat[1 + 2 * 4] = y[2]
 *         self.mat[1 + 3 * 4] = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[2 + 0 * 4] = z[0]
 *         self.mat[2 + 1 * 4] = z[1]
 */
  (__pyx_v_self->mat[13]) = 0.0;

  /* "kivy\graphics\transformation.pyx":262
 *         self.mat[1 + 2 * 4] = y[2]
 *         self.mat[1 + 3 * 4] = 0.0
 *         self.mat[2 + 0 * 4] = z[0]             # <<<<<<<<<<<<<<
 *         self.mat[2 + 1 * 4] = z[1]
 *         self.mat[2 + 2 * 4] = z[2]
 */
  (__pyx_v_self->mat[2]) = (__pyx_v_z[0]);

  /* "kivy\graphics\transformation.pyx":263
 *         self.mat[1 + 3 * 4] = 0.0
 *         self.mat[2 + 0 * 4] = z[0]
 *         self.mat[2 + 1 * 4] = z[1]             # <<<<<<<<<<<<<<
 *         self.mat[2 + 2 * 4] = z[2]
 *         self.mat[2 + 3 * 4] = 0.0
 */
  (__pyx_v_self->mat[6]) = (__pyx_v_z[1]);

  /* "kivy\graphics\transformation.pyx":264
 *         self.mat[2 + 0 * 4] = z[0]
 *         self.mat[2 + 1 * 4] = z[1]
 *         self.mat[2 + 2 * 4] = z[2]             # <<<<<<<<<<<<<<
 *         self.mat[2 + 3 * 4] = 0.0
 *         self.mat[3 + 0 * 4] = 0.0
 */
  (__pyx_v_self->mat[10]) = (__pyx_v_z[2]);

  /* "kivy\graphics\transformation.pyx":265
 *         self.mat[2 + 1 * 4] = z[1]
 *         self.mat[2 + 2 * 4] = z[2]
 *         self.mat[2 + 3 * 4] = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[3 + 0 * 4] = 0.0
 *         self.mat[3 + 1 * 4] = 0.0
 */
  (__pyx_v_self->mat[14]) = 0.0;

  /* "kivy\graphics\transformation.pyx":266
 *         self.mat[2 + 2 * 4] = z[2]
 *         self.mat[2 + 3 * 4] = 0.0
 *         self.mat[3 + 0 * 4] = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[3 + 1 * 4] = 0.0
 *         self.mat[3 + 2 * 4] = 0.0
 */
  (__pyx_v_self->mat[3]) = 0.0;

  /* "kivy\graphics\transformation.pyx":267
 *         self.mat[2 + 3 * 4] = 0.0
 *         self.mat[3 + 0 * 4] = 0.0
 *         self.mat[3 + 1 * 4] = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[3 + 2 * 4] = 0.0
 *         self.mat[3 + 3 * 4] = 1.0
 */
  (__pyx_v_self->mat[7]) = 0.0;

  /* "kivy\graphics\transformation.pyx":268
 *         self.mat[3 + 0 * 4] = 0.0
 *         self.mat[3 + 1 * 4] = 0.0
 *         self.mat[3 + 2 * 4] = 0.0             # <<<<<<<<<<<<<<
 *         self.mat[3 + 3 * 4] = 1.0
 * 
 */
  (__pyx_v_self->mat[11]) = 0.0;

  /* "kivy\graphics\transformation.pyx":269
 *         self.mat[3 + 1 * 4] = 0.0
 *         self.mat[3 + 2 * 4] = 0.0
 *         self.mat[3 + 3 * 4] = 1.0             # <<<<<<<<<<<<<<
 * 
 *         cdef Matrix m = Matrix()
 */
  (__pyx_v_self->mat[15]) = 1.0;

  /* "kivy\graphics\transformation.pyx":271
 *         self.mat[3 + 3 * 4] = 1.0
 * 
 *         cdef Matrix m = Matrix()             # <<<<<<<<<<<<<<
 *         m = self.multiply(m)
 *         m = m.multiply(Matrix().translate(-eyex, -eyey, -eyez))
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_14transformation_Matrix)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_m = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "kivy\graphics\transformation.pyx":272
 * 
 *         cdef Matrix m = Matrix()
 *         m = self.multiply(m)             # <<<<<<<<<<<<<<
 *         m = m.multiply(Matrix().translate(-eyex, -eyey, -eyez))
 *         return m
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->multiply(__pyx_v_self, __pyx_v_m, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_v_m));
  __pyx_v_m = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "kivy\graphics\transformation.pyx":273
 *         cdef Matrix m = Matrix()
 *         m = self.multiply(m)
 *         m = m.multiply(Matrix().translate(-eyex, -eyey, -eyez))             # <<<<<<<<<<<<<<
 *         return m
 * 
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_14transformation_Matrix)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_10 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_1)->__pyx_vtab)->translate(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_1), (-__pyx_v_eyex), (-__pyx_v_eyey), (-__pyx_v_eyez), 0)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_m->__pyx_vtab)->multiply(__pyx_v_m, ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_10), 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_v_m));
  __pyx_v_m = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "kivy\graphics\transformation.pyx":274
 *         m = self.multiply(m)
 *         m = m.multiply(Matrix().translate(-eyex, -eyey, -eyez))
 *         return m             # <<<<<<<<<<<<<<
 * 
 *     cpdef tuple transform_point(Matrix self, double x, double y, double z,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_m));
  __pyx_r = ((PyObject *)__pyx_v_m);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.look_at", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_m);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_15look_at(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_14look_at[] = "returns a new lookat Matrix (simmilar to gluLookAt)\n\n        .. versionadded:: 1.6.0\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_15look_at(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_eyex;
  double __pyx_v_eyey;
  double __pyx_v_eyez;
  double __pyx_v_centerx;
  double __pyx_v_centery;
  double __pyx_v_centerz;
  double __pyx_v_upx;
  double __pyx_v_upy;
  double __pyx_v_upz;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("look_at (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__eyex,&__pyx_n_s__eyey,&__pyx_n_s__eyez,&__pyx_n_s__centerx,&__pyx_n_s__centery,&__pyx_n_s__centerz,&__pyx_n_s__upx,&__pyx_n_s__upy,&__pyx_n_s__upz,0};
    PyObject* values[9] = {0,0,0,0,0,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  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__eyex)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__eyey)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("look_at", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__eyez)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("look_at", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__centerx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("look_at", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__centery)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("look_at", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__centerz)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("look_at", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__upx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("look_at", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__upy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("look_at", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  8:
        if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__upz)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("look_at", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "look_at") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 9) {
      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);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
    }
    __pyx_v_eyex = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_eyex == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_eyey = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_eyey == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_eyez = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_eyez == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_centerx = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_centerx == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_centery = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_centery == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_centerz = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_centerz == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_upx = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_upx == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_upy = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_upy == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_upz = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_upz == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("look_at", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.look_at", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_14look_at(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self), __pyx_v_eyex, __pyx_v_eyey, __pyx_v_eyez, __pyx_v_centerx, __pyx_v_centery, __pyx_v_centerz, __pyx_v_upx, __pyx_v_upy, __pyx_v_upz);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":202
 *         return self
 * 
 *     cpdef look_at(Matrix self, double eyex, double eyey, double eyez,             # <<<<<<<<<<<<<<
 *           double centerx, double centery, double centerz,
 *           double upx, double upy, double upz):
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_14look_at(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_eyex, double __pyx_v_eyey, double __pyx_v_eyez, double __pyx_v_centerx, double __pyx_v_centery, double __pyx_v_centerz, double __pyx_v_upx, double __pyx_v_upy, double __pyx_v_upz) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("look_at", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->look_at(__pyx_v_self, __pyx_v_eyex, __pyx_v_eyey, __pyx_v_eyez, __pyx_v_centerx, __pyx_v_centery, __pyx_v_centerz, __pyx_v_upx, __pyx_v_upy, __pyx_v_upz, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.look_at", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":276
 *         return m
 * 
 *     cpdef tuple transform_point(Matrix self, double x, double y, double z,             # <<<<<<<<<<<<<<
 *             t=None):
 *         cdef double tx, ty, tz, tt
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_17transform_point(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4kivy_8graphics_14transformation_6Matrix_transform_point(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z, int __pyx_skip_dispatch, struct __pyx_opt_args_4kivy_8graphics_14transformation_6Matrix_transform_point *__pyx_optional_args) {

  /* "kivy\graphics\transformation.pyx":277
 * 
 *     cpdef tuple transform_point(Matrix self, double x, double y, double z,
 *             t=None):             # <<<<<<<<<<<<<<
 *         cdef double tx, ty, tz, tt
 *         tx = x * self.mat[0] + y * self.mat[4] + z * self.mat[ 8] + self.mat[12];
 */
  PyObject *__pyx_v_t = ((PyObject *)Py_None);
  double __pyx_v_tx;
  double __pyx_v_ty;
  double __pyx_v_tz;
  double __pyx_v_tt;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_point", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_t = __pyx_optional_args->t;
    }
  }

  /* "kivy\graphics\transformation.pyx":276
 *         return m
 * 
 *     cpdef tuple transform_point(Matrix self, double x, double y, double z,             # <<<<<<<<<<<<<<
 *             t=None):
 *         cdef double tx, ty, tz, tt
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__transform_point); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_17transform_point)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_z); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      if (!(likely(PyTuple_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":279
 *             t=None):
 *         cdef double tx, ty, tz, tt
 *         tx = x * self.mat[0] + y * self.mat[4] + z * self.mat[ 8] + self.mat[12];             # <<<<<<<<<<<<<<
 *         ty = x * self.mat[1] + y * self.mat[5] + z * self.mat[ 9] + self.mat[13];
 *         tz = x * self.mat[2] + y * self.mat[6] + z * self.mat[10] + self.mat[14];
 */
  __pyx_v_tx = ((((__pyx_v_x * (__pyx_v_self->mat[0])) + (__pyx_v_y * (__pyx_v_self->mat[4]))) + (__pyx_v_z * (__pyx_v_self->mat[8]))) + (__pyx_v_self->mat[12]));

  /* "kivy\graphics\transformation.pyx":280
 *         cdef double tx, ty, tz, tt
 *         tx = x * self.mat[0] + y * self.mat[4] + z * self.mat[ 8] + self.mat[12];
 *         ty = x * self.mat[1] + y * self.mat[5] + z * self.mat[ 9] + self.mat[13];             # <<<<<<<<<<<<<<
 *         tz = x * self.mat[2] + y * self.mat[6] + z * self.mat[10] + self.mat[14];
 *         if t is not None:
 */
  __pyx_v_ty = ((((__pyx_v_x * (__pyx_v_self->mat[1])) + (__pyx_v_y * (__pyx_v_self->mat[5]))) + (__pyx_v_z * (__pyx_v_self->mat[9]))) + (__pyx_v_self->mat[13]));

  /* "kivy\graphics\transformation.pyx":281
 *         tx = x * self.mat[0] + y * self.mat[4] + z * self.mat[ 8] + self.mat[12];
 *         ty = x * self.mat[1] + y * self.mat[5] + z * self.mat[ 9] + self.mat[13];
 *         tz = x * self.mat[2] + y * self.mat[6] + z * self.mat[10] + self.mat[14];             # <<<<<<<<<<<<<<
 *         if t is not None:
 *             tt = x * self.mat[3] + y * self.mat[7] + z * self.mat[11] + self.mat[15];
 */
  __pyx_v_tz = ((((__pyx_v_x * (__pyx_v_self->mat[2])) + (__pyx_v_y * (__pyx_v_self->mat[6]))) + (__pyx_v_z * (__pyx_v_self->mat[10]))) + (__pyx_v_self->mat[14]));

  /* "kivy\graphics\transformation.pyx":282
 *         ty = x * self.mat[1] + y * self.mat[5] + z * self.mat[ 9] + self.mat[13];
 *         tz = x * self.mat[2] + y * self.mat[6] + z * self.mat[10] + self.mat[14];
 *         if t is not None:             # <<<<<<<<<<<<<<
 *             tt = x * self.mat[3] + y * self.mat[7] + z * self.mat[11] + self.mat[15];
 *             return (tx, ty, tz, tt)
 */
  __pyx_t_6 = (__pyx_v_t != Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "kivy\graphics\transformation.pyx":283
 *         tz = x * self.mat[2] + y * self.mat[6] + z * self.mat[10] + self.mat[14];
 *         if t is not None:
 *             tt = x * self.mat[3] + y * self.mat[7] + z * self.mat[11] + self.mat[15];             # <<<<<<<<<<<<<<
 *             return (tx, ty, tz, tt)
 *         else:
 */
    __pyx_v_tt = ((((__pyx_v_x * (__pyx_v_self->mat[3])) + (__pyx_v_y * (__pyx_v_self->mat[7]))) + (__pyx_v_z * (__pyx_v_self->mat[11]))) + (__pyx_v_self->mat[15]));

    /* "kivy\graphics\transformation.pyx":284
 *         if t is not None:
 *             tt = x * self.mat[3] + y * self.mat[7] + z * self.mat[11] + self.mat[15];
 *             return (tx, ty, tz, tt)             # <<<<<<<<<<<<<<
 *         else:
 *             return (tx, ty, tz)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_tx); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_ty); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_tz); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyFloat_FromDouble(__pyx_v_tt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_3 = 0;
    __pyx_r = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "kivy\graphics\transformation.pyx":286
 *             return (tx, ty, tz, tt)
 *         else:
 *             return (tx, ty, tz)             # <<<<<<<<<<<<<<
 * 
 *     cpdef Matrix identity(self):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = PyFloat_FromDouble(__pyx_v_tx); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_tz); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_5 = 0;
    __pyx_r = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.transform_point", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_17transform_point(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_17transform_point(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_x;
  double __pyx_v_y;
  double __pyx_v_z;
  PyObject *__pyx_v_t = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transform_point (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__z,&__pyx_n_s__t,0};
    PyObject* values[4] = {0,0,0,0};

    /* "kivy\graphics\transformation.pyx":277
 * 
 *     cpdef tuple transform_point(Matrix self, double x, double y, double z,
 *             t=None):             # <<<<<<<<<<<<<<
 *         cdef double tx, ty, tz, tt
 *         tx = x * self.mat[0] + y * self.mat[4] + z * self.mat[ 8] + self.mat[12];
 */
    values[3] = ((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  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__x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("transform_point", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__z)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("transform_point", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__t);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "transform_point") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_x = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_x == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_y = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_y == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_z = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_z == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_t = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("transform_point", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.transform_point", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_16transform_point(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self), __pyx_v_x, __pyx_v_y, __pyx_v_z, __pyx_v_t);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":276
 *         return m
 * 
 *     cpdef tuple transform_point(Matrix self, double x, double y, double z,             # <<<<<<<<<<<<<<
 *             t=None):
 *         cdef double tx, ty, tz, tt
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_16transform_point(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double __pyx_v_z, PyObject *__pyx_v_t) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4kivy_8graphics_14transformation_6Matrix_transform_point __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transform_point", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.t = __pyx_v_t;
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->transform_point(__pyx_v_self, __pyx_v_x, __pyx_v_y, __pyx_v_z, 1, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.transform_point", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":288
 *             return (tx, ty, tz)
 * 
 *     cpdef Matrix identity(self):             # <<<<<<<<<<<<<<
 *         '''Reset matrix to identity matrix (inplace)
 *         '''
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_19identity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_f_4kivy_8graphics_14transformation_6Matrix_identity(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, int __pyx_skip_dispatch) {
  double *__pyx_v_m;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("identity", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__identity); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_19identity)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4kivy_8graphics_14transformation_Matrix))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":291
 *         '''Reset matrix to identity matrix (inplace)
 *         '''
 *         cdef double *m = <double *>self.mat             # <<<<<<<<<<<<<<
 *         with nogil:
 *             m[0] = m[5] = m[10] = m[15] = 1
 */
  __pyx_v_m = ((double *)__pyx_v_self->mat);

  /* "kivy\graphics\transformation.pyx":292
 *         '''
 *         cdef double *m = <double *>self.mat
 *         with nogil:             # <<<<<<<<<<<<<<
 *             m[0] = m[5] = m[10] = m[15] = 1
 *             m[1] = m[2] = m[3] = m[4] = m[6] = m[7] = \
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "kivy\graphics\transformation.pyx":293
 *         cdef double *m = <double *>self.mat
 *         with nogil:
 *             m[0] = m[5] = m[10] = m[15] = 1             # <<<<<<<<<<<<<<
 *             m[1] = m[2] = m[3] = m[4] = m[6] = m[7] = \
 *             m[8] = m[9] = m[11] = m[12] = m[13] = m[14] = 0
 */
        (__pyx_v_m[0]) = 1;
        (__pyx_v_m[5]) = 1;
        (__pyx_v_m[10]) = 1;
        (__pyx_v_m[15]) = 1;

        /* "kivy\graphics\transformation.pyx":294
 *         with nogil:
 *             m[0] = m[5] = m[10] = m[15] = 1
 *             m[1] = m[2] = m[3] = m[4] = m[6] = m[7] = \             # <<<<<<<<<<<<<<
 *             m[8] = m[9] = m[11] = m[12] = m[13] = m[14] = 0
 *         return self
 */
        (__pyx_v_m[1]) = 0;
        (__pyx_v_m[2]) = 0;
        (__pyx_v_m[3]) = 0;
        (__pyx_v_m[4]) = 0;
        (__pyx_v_m[6]) = 0;
        (__pyx_v_m[7]) = 0;

        /* "kivy\graphics\transformation.pyx":295
 *             m[0] = m[5] = m[10] = m[15] = 1
 *             m[1] = m[2] = m[3] = m[4] = m[6] = m[7] = \
 *             m[8] = m[9] = m[11] = m[12] = m[13] = m[14] = 0             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
        (__pyx_v_m[8]) = 0;
        (__pyx_v_m[9]) = 0;
        (__pyx_v_m[11]) = 0;
        (__pyx_v_m[12]) = 0;
        (__pyx_v_m[13]) = 0;
        (__pyx_v_m[14]) = 0;
      }

      /* "kivy\graphics\transformation.pyx":292
 *         '''
 *         cdef double *m = <double *>self.mat
 *         with nogil:             # <<<<<<<<<<<<<<
 *             m[0] = m[5] = m[10] = m[15] = 1
 *             m[1] = m[2] = m[3] = m[4] = m[6] = m[7] = \
 */
      /*finally:*/ {
        #ifdef WITH_THREAD
        Py_BLOCK_THREADS
        #endif
      }
  }

  /* "kivy\graphics\transformation.pyx":296
 *             m[1] = m[2] = m[3] = m[4] = m[6] = m[7] = \
 *             m[8] = m[9] = m[11] = m[12] = m[13] = m[14] = 0
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     cpdef Matrix transpose(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.identity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_19identity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_18identity[] = "Reset matrix to identity matrix (inplace)\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_19identity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("identity (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_18identity(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":288
 *             return (tx, ty, tz)
 * 
 *     cpdef Matrix identity(self):             # <<<<<<<<<<<<<<
 *         '''Reset matrix to identity matrix (inplace)
 *         '''
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_18identity(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("identity", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->identity(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.identity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":298
 *         return self
 * 
 *     cpdef Matrix transpose(self):             # <<<<<<<<<<<<<<
 *         '''Return the transposed of the matrix as a new Matrix.
 * 
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_21transpose(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_f_4kivy_8graphics_14transformation_6Matrix_transpose(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_mm = 0;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transpose", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__transpose); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_21transpose)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4kivy_8graphics_14transformation_Matrix))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":303
 *         .. versionadded:: 1.6.0
 *         '''
 *         cdef Matrix mm = Matrix()             # <<<<<<<<<<<<<<
 *         mm.mat[0]  = self.mat[0]
 *         mm.mat[4]  = self.mat[1]
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_14transformation_Matrix)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mm = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "kivy\graphics\transformation.pyx":304
 *         '''
 *         cdef Matrix mm = Matrix()
 *         mm.mat[0]  = self.mat[0]             # <<<<<<<<<<<<<<
 *         mm.mat[4]  = self.mat[1]
 *         mm.mat[8]  = self.mat[2]
 */
  (__pyx_v_mm->mat[0]) = (__pyx_v_self->mat[0]);

  /* "kivy\graphics\transformation.pyx":305
 *         cdef Matrix mm = Matrix()
 *         mm.mat[0]  = self.mat[0]
 *         mm.mat[4]  = self.mat[1]             # <<<<<<<<<<<<<<
 *         mm.mat[8]  = self.mat[2]
 *         mm.mat[12] = self.mat[3]
 */
  (__pyx_v_mm->mat[4]) = (__pyx_v_self->mat[1]);

  /* "kivy\graphics\transformation.pyx":306
 *         mm.mat[0]  = self.mat[0]
 *         mm.mat[4]  = self.mat[1]
 *         mm.mat[8]  = self.mat[2]             # <<<<<<<<<<<<<<
 *         mm.mat[12] = self.mat[3]
 *         mm.mat[1]  = self.mat[4]
 */
  (__pyx_v_mm->mat[8]) = (__pyx_v_self->mat[2]);

  /* "kivy\graphics\transformation.pyx":307
 *         mm.mat[4]  = self.mat[1]
 *         mm.mat[8]  = self.mat[2]
 *         mm.mat[12] = self.mat[3]             # <<<<<<<<<<<<<<
 *         mm.mat[1]  = self.mat[4]
 *         mm.mat[5]  = self.mat[5]
 */
  (__pyx_v_mm->mat[12]) = (__pyx_v_self->mat[3]);

  /* "kivy\graphics\transformation.pyx":308
 *         mm.mat[8]  = self.mat[2]
 *         mm.mat[12] = self.mat[3]
 *         mm.mat[1]  = self.mat[4]             # <<<<<<<<<<<<<<
 *         mm.mat[5]  = self.mat[5]
 *         mm.mat[9]  = self.mat[6]
 */
  (__pyx_v_mm->mat[1]) = (__pyx_v_self->mat[4]);

  /* "kivy\graphics\transformation.pyx":309
 *         mm.mat[12] = self.mat[3]
 *         mm.mat[1]  = self.mat[4]
 *         mm.mat[5]  = self.mat[5]             # <<<<<<<<<<<<<<
 *         mm.mat[9]  = self.mat[6]
 *         mm.mat[13] = self.mat[7]
 */
  (__pyx_v_mm->mat[5]) = (__pyx_v_self->mat[5]);

  /* "kivy\graphics\transformation.pyx":310
 *         mm.mat[1]  = self.mat[4]
 *         mm.mat[5]  = self.mat[5]
 *         mm.mat[9]  = self.mat[6]             # <<<<<<<<<<<<<<
 *         mm.mat[13] = self.mat[7]
 *         mm.mat[2]  = self.mat[8]
 */
  (__pyx_v_mm->mat[9]) = (__pyx_v_self->mat[6]);

  /* "kivy\graphics\transformation.pyx":311
 *         mm.mat[5]  = self.mat[5]
 *         mm.mat[9]  = self.mat[6]
 *         mm.mat[13] = self.mat[7]             # <<<<<<<<<<<<<<
 *         mm.mat[2]  = self.mat[8]
 *         mm.mat[6]  = self.mat[9]
 */
  (__pyx_v_mm->mat[13]) = (__pyx_v_self->mat[7]);

  /* "kivy\graphics\transformation.pyx":312
 *         mm.mat[9]  = self.mat[6]
 *         mm.mat[13] = self.mat[7]
 *         mm.mat[2]  = self.mat[8]             # <<<<<<<<<<<<<<
 *         mm.mat[6]  = self.mat[9]
 *         mm.mat[10] = self.mat[10]
 */
  (__pyx_v_mm->mat[2]) = (__pyx_v_self->mat[8]);

  /* "kivy\graphics\transformation.pyx":313
 *         mm.mat[13] = self.mat[7]
 *         mm.mat[2]  = self.mat[8]
 *         mm.mat[6]  = self.mat[9]             # <<<<<<<<<<<<<<
 *         mm.mat[10] = self.mat[10]
 *         mm.mat[14] = self.mat[11]
 */
  (__pyx_v_mm->mat[6]) = (__pyx_v_self->mat[9]);

  /* "kivy\graphics\transformation.pyx":314
 *         mm.mat[2]  = self.mat[8]
 *         mm.mat[6]  = self.mat[9]
 *         mm.mat[10] = self.mat[10]             # <<<<<<<<<<<<<<
 *         mm.mat[14] = self.mat[11]
 *         mm.mat[3]  = self.mat[12]
 */
  (__pyx_v_mm->mat[10]) = (__pyx_v_self->mat[10]);

  /* "kivy\graphics\transformation.pyx":315
 *         mm.mat[6]  = self.mat[9]
 *         mm.mat[10] = self.mat[10]
 *         mm.mat[14] = self.mat[11]             # <<<<<<<<<<<<<<
 *         mm.mat[3]  = self.mat[12]
 *         mm.mat[7]  = self.mat[13]
 */
  (__pyx_v_mm->mat[14]) = (__pyx_v_self->mat[11]);

  /* "kivy\graphics\transformation.pyx":316
 *         mm.mat[10] = self.mat[10]
 *         mm.mat[14] = self.mat[11]
 *         mm.mat[3]  = self.mat[12]             # <<<<<<<<<<<<<<
 *         mm.mat[7]  = self.mat[13]
 *         mm.mat[11] = self.mat[14]
 */
  (__pyx_v_mm->mat[3]) = (__pyx_v_self->mat[12]);

  /* "kivy\graphics\transformation.pyx":317
 *         mm.mat[14] = self.mat[11]
 *         mm.mat[3]  = self.mat[12]
 *         mm.mat[7]  = self.mat[13]             # <<<<<<<<<<<<<<
 *         mm.mat[11] = self.mat[14]
 *         mm.mat[15] = self.mat[15]
 */
  (__pyx_v_mm->mat[7]) = (__pyx_v_self->mat[13]);

  /* "kivy\graphics\transformation.pyx":318
 *         mm.mat[3]  = self.mat[12]
 *         mm.mat[7]  = self.mat[13]
 *         mm.mat[11] = self.mat[14]             # <<<<<<<<<<<<<<
 *         mm.mat[15] = self.mat[15]
 *         return mm
 */
  (__pyx_v_mm->mat[11]) = (__pyx_v_self->mat[14]);

  /* "kivy\graphics\transformation.pyx":319
 *         mm.mat[7]  = self.mat[13]
 *         mm.mat[11] = self.mat[14]
 *         mm.mat[15] = self.mat[15]             # <<<<<<<<<<<<<<
 *         return mm
 * 
 */
  (__pyx_v_mm->mat[15]) = (__pyx_v_self->mat[15]);

  /* "kivy\graphics\transformation.pyx":320
 *         mm.mat[11] = self.mat[14]
 *         mm.mat[15] = self.mat[15]
 *         return mm             # <<<<<<<<<<<<<<
 * 
 *     cpdef Matrix inverse(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_mm));
  __pyx_r = __pyx_v_mm;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.transpose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mm);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_21transpose(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_20transpose[] = "Return the transposed of the matrix as a new Matrix.\n\n        .. versionadded:: 1.6.0\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_21transpose(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transpose (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_20transpose(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":298
 *         return self
 * 
 *     cpdef Matrix transpose(self):             # <<<<<<<<<<<<<<
 *         '''Return the transposed of the matrix as a new Matrix.
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_20transpose(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transpose", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->transpose(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.transpose", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":322
 *         return mm
 * 
 *     cpdef Matrix inverse(self):             # <<<<<<<<<<<<<<
 *         '''Return the inverse of the matrix as a new Matrix.
 *         '''
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_23inverse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_f_4kivy_8graphics_14transformation_6Matrix_inverse(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_mr = 0;
  double *__pyx_v_m;
  double *__pyx_v_r;
  double __pyx_v_det;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("inverse", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__inverse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_23inverse)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4kivy_8graphics_14transformation_Matrix))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":325
 *         '''Return the inverse of the matrix as a new Matrix.
 *         '''
 *         cdef Matrix mr = Matrix()             # <<<<<<<<<<<<<<
 *         cdef double *m = <double *>self.mat, *r = <double *>mr.mat
 *         cdef double det
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_14transformation_Matrix)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mr = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "kivy\graphics\transformation.pyx":326
 *         '''
 *         cdef Matrix mr = Matrix()
 *         cdef double *m = <double *>self.mat, *r = <double *>mr.mat             # <<<<<<<<<<<<<<
 *         cdef double det
 *         with nogil:
 */
  __pyx_v_m = ((double *)__pyx_v_self->mat);
  __pyx_v_r = ((double *)__pyx_v_mr->mat);

  /* "kivy\graphics\transformation.pyx":328
 *         cdef double *m = <double *>self.mat, *r = <double *>mr.mat
 *         cdef double det
 *         with nogil:             # <<<<<<<<<<<<<<
 *             det = m[0] * (m[5] * m[10] - m[9] * m[6]) \
 *                     - m[4] * (m[1] * m[10] - m[9] * m[2]) \
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "kivy\graphics\transformation.pyx":331
 *             det = m[0] * (m[5] * m[10] - m[9] * m[6]) \
 *                     - m[4] * (m[1] * m[10] - m[9] * m[2]) \
 *                     + m[8] * (m[1] * m[ 6] - m[5] * m[2])             # <<<<<<<<<<<<<<
 *         if det == 0:
 *             return
 */
        __pyx_v_det = ((((__pyx_v_m[0]) * (((__pyx_v_m[5]) * (__pyx_v_m[10])) - ((__pyx_v_m[9]) * (__pyx_v_m[6])))) - ((__pyx_v_m[4]) * (((__pyx_v_m[1]) * (__pyx_v_m[10])) - ((__pyx_v_m[9]) * (__pyx_v_m[2]))))) + ((__pyx_v_m[8]) * (((__pyx_v_m[1]) * (__pyx_v_m[6])) - ((__pyx_v_m[5]) * (__pyx_v_m[2])))));
      }

      /* "kivy\graphics\transformation.pyx":328
 *         cdef double *m = <double *>self.mat, *r = <double *>mr.mat
 *         cdef double det
 *         with nogil:             # <<<<<<<<<<<<<<
 *             det = m[0] * (m[5] * m[10] - m[9] * m[6]) \
 *                     - m[4] * (m[1] * m[10] - m[9] * m[2]) \
 */
      /*finally:*/ {
        #ifdef WITH_THREAD
        Py_BLOCK_THREADS
        #endif
      }
  }

  /* "kivy\graphics\transformation.pyx":332
 *                     - m[4] * (m[1] * m[10] - m[9] * m[2]) \
 *                     + m[8] * (m[1] * m[ 6] - m[5] * m[2])
 *         if det == 0:             # <<<<<<<<<<<<<<
 *             return
 *         with nogil:
 */
  __pyx_t_3 = ((__pyx_v_det == 0.0) != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\transformation.pyx":333
 *                     + m[8] * (m[1] * m[ 6] - m[5] * m[2])
 *         if det == 0:
 *             return             # <<<<<<<<<<<<<<
 *         with nogil:
 *             det = 1.0 / det
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "kivy\graphics\transformation.pyx":334
 *         if det == 0:
 *             return
 *         with nogil:             # <<<<<<<<<<<<<<
 *             det = 1.0 / det
 *             r[ 0] =   det * (m[5] * m[10] - m[9] * m[6])
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "kivy\graphics\transformation.pyx":335
 *             return
 *         with nogil:
 *             det = 1.0 / det             # <<<<<<<<<<<<<<
 *             r[ 0] =   det * (m[5] * m[10] - m[9] * m[6])
 *             r[ 4] = - det * (m[4] * m[10] - m[8] * m[6])
 */
        __pyx_v_det = (1.0 / __pyx_v_det);

        /* "kivy\graphics\transformation.pyx":336
 *         with nogil:
 *             det = 1.0 / det
 *             r[ 0] =   det * (m[5] * m[10] - m[9] * m[6])             # <<<<<<<<<<<<<<
 *             r[ 4] = - det * (m[4] * m[10] - m[8] * m[6])
 *             r[ 8] =   det * (m[4] * m[ 9] - m[8] * m[5])
 */
        (__pyx_v_r[0]) = (__pyx_v_det * (((__pyx_v_m[5]) * (__pyx_v_m[10])) - ((__pyx_v_m[9]) * (__pyx_v_m[6]))));

        /* "kivy\graphics\transformation.pyx":337
 *             det = 1.0 / det
 *             r[ 0] =   det * (m[5] * m[10] - m[9] * m[6])
 *             r[ 4] = - det * (m[4] * m[10] - m[8] * m[6])             # <<<<<<<<<<<<<<
 *             r[ 8] =   det * (m[4] * m[ 9] - m[8] * m[5])
 *             r[ 1] = - det * (m[1] * m[10] - m[9] * m[2])
 */
        (__pyx_v_r[4]) = ((-__pyx_v_det) * (((__pyx_v_m[4]) * (__pyx_v_m[10])) - ((__pyx_v_m[8]) * (__pyx_v_m[6]))));

        /* "kivy\graphics\transformation.pyx":338
 *             r[ 0] =   det * (m[5] * m[10] - m[9] * m[6])
 *             r[ 4] = - det * (m[4] * m[10] - m[8] * m[6])
 *             r[ 8] =   det * (m[4] * m[ 9] - m[8] * m[5])             # <<<<<<<<<<<<<<
 *             r[ 1] = - det * (m[1] * m[10] - m[9] * m[2])
 *             r[ 5] =   det * (m[0] * m[10] - m[8] * m[2])
 */
        (__pyx_v_r[8]) = (__pyx_v_det * (((__pyx_v_m[4]) * (__pyx_v_m[9])) - ((__pyx_v_m[8]) * (__pyx_v_m[5]))));

        /* "kivy\graphics\transformation.pyx":339
 *             r[ 4] = - det * (m[4] * m[10] - m[8] * m[6])
 *             r[ 8] =   det * (m[4] * m[ 9] - m[8] * m[5])
 *             r[ 1] = - det * (m[1] * m[10] - m[9] * m[2])             # <<<<<<<<<<<<<<
 *             r[ 5] =   det * (m[0] * m[10] - m[8] * m[2])
 *             r[ 9] = - det * (m[0] * m[ 9] - m[8] * m[1])
 */
        (__pyx_v_r[1]) = ((-__pyx_v_det) * (((__pyx_v_m[1]) * (__pyx_v_m[10])) - ((__pyx_v_m[9]) * (__pyx_v_m[2]))));

        /* "kivy\graphics\transformation.pyx":340
 *             r[ 8] =   det * (m[4] * m[ 9] - m[8] * m[5])
 *             r[ 1] = - det * (m[1] * m[10] - m[9] * m[2])
 *             r[ 5] =   det * (m[0] * m[10] - m[8] * m[2])             # <<<<<<<<<<<<<<
 *             r[ 9] = - det * (m[0] * m[ 9] - m[8] * m[1])
 *             r[ 2] =   det * (m[1] * m[ 6] - m[5] * m[2])
 */
        (__pyx_v_r[5]) = (__pyx_v_det * (((__pyx_v_m[0]) * (__pyx_v_m[10])) - ((__pyx_v_m[8]) * (__pyx_v_m[2]))));

        /* "kivy\graphics\transformation.pyx":341
 *             r[ 1] = - det * (m[1] * m[10] - m[9] * m[2])
 *             r[ 5] =   det * (m[0] * m[10] - m[8] * m[2])
 *             r[ 9] = - det * (m[0] * m[ 9] - m[8] * m[1])             # <<<<<<<<<<<<<<
 *             r[ 2] =   det * (m[1] * m[ 6] - m[5] * m[2])
 *             r[ 6] = - det * (m[0] * m[ 6] - m[4] * m[2])
 */
        (__pyx_v_r[9]) = ((-__pyx_v_det) * (((__pyx_v_m[0]) * (__pyx_v_m[9])) - ((__pyx_v_m[8]) * (__pyx_v_m[1]))));

        /* "kivy\graphics\transformation.pyx":342
 *             r[ 5] =   det * (m[0] * m[10] - m[8] * m[2])
 *             r[ 9] = - det * (m[0] * m[ 9] - m[8] * m[1])
 *             r[ 2] =   det * (m[1] * m[ 6] - m[5] * m[2])             # <<<<<<<<<<<<<<
 *             r[ 6] = - det * (m[0] * m[ 6] - m[4] * m[2])
 *             r[10] =   det * (m[0] * m[ 5] - m[4] * m[1])
 */
        (__pyx_v_r[2]) = (__pyx_v_det * (((__pyx_v_m[1]) * (__pyx_v_m[6])) - ((__pyx_v_m[5]) * (__pyx_v_m[2]))));

        /* "kivy\graphics\transformation.pyx":343
 *             r[ 9] = - det * (m[0] * m[ 9] - m[8] * m[1])
 *             r[ 2] =   det * (m[1] * m[ 6] - m[5] * m[2])
 *             r[ 6] = - det * (m[0] * m[ 6] - m[4] * m[2])             # <<<<<<<<<<<<<<
 *             r[10] =   det * (m[0] * m[ 5] - m[4] * m[1])
 *             r[ 3] = 0
 */
        (__pyx_v_r[6]) = ((-__pyx_v_det) * (((__pyx_v_m[0]) * (__pyx_v_m[6])) - ((__pyx_v_m[4]) * (__pyx_v_m[2]))));

        /* "kivy\graphics\transformation.pyx":344
 *             r[ 2] =   det * (m[1] * m[ 6] - m[5] * m[2])
 *             r[ 6] = - det * (m[0] * m[ 6] - m[4] * m[2])
 *             r[10] =   det * (m[0] * m[ 5] - m[4] * m[1])             # <<<<<<<<<<<<<<
 *             r[ 3] = 0
 *             r[ 7] = 0
 */
        (__pyx_v_r[10]) = (__pyx_v_det * (((__pyx_v_m[0]) * (__pyx_v_m[5])) - ((__pyx_v_m[4]) * (__pyx_v_m[1]))));

        /* "kivy\graphics\transformation.pyx":345
 *             r[ 6] = - det * (m[0] * m[ 6] - m[4] * m[2])
 *             r[10] =   det * (m[0] * m[ 5] - m[4] * m[1])
 *             r[ 3] = 0             # <<<<<<<<<<<<<<
 *             r[ 7] = 0
 *             r[11] = 0
 */
        (__pyx_v_r[3]) = 0.0;

        /* "kivy\graphics\transformation.pyx":346
 *             r[10] =   det * (m[0] * m[ 5] - m[4] * m[1])
 *             r[ 3] = 0
 *             r[ 7] = 0             # <<<<<<<<<<<<<<
 *             r[11] = 0
 *             r[15] = 1
 */
        (__pyx_v_r[7]) = 0.0;

        /* "kivy\graphics\transformation.pyx":347
 *             r[ 3] = 0
 *             r[ 7] = 0
 *             r[11] = 0             # <<<<<<<<<<<<<<
 *             r[15] = 1
 *             r[12] = -(m[12] * r[0] + m[13] * r[4] + m[14] * r[ 8])
 */
        (__pyx_v_r[11]) = 0.0;

        /* "kivy\graphics\transformation.pyx":348
 *             r[ 7] = 0
 *             r[11] = 0
 *             r[15] = 1             # <<<<<<<<<<<<<<
 *             r[12] = -(m[12] * r[0] + m[13] * r[4] + m[14] * r[ 8])
 *             r[13] = -(m[12] * r[1] + m[13] * r[5] + m[14] * r[ 9])
 */
        (__pyx_v_r[15]) = 1.0;

        /* "kivy\graphics\transformation.pyx":349
 *             r[11] = 0
 *             r[15] = 1
 *             r[12] = -(m[12] * r[0] + m[13] * r[4] + m[14] * r[ 8])             # <<<<<<<<<<<<<<
 *             r[13] = -(m[12] * r[1] + m[13] * r[5] + m[14] * r[ 9])
 *             r[14] = -(m[12] * r[2] + m[13] * r[6] + m[14] * r[10])
 */
        (__pyx_v_r[12]) = (-((((__pyx_v_m[12]) * (__pyx_v_r[0])) + ((__pyx_v_m[13]) * (__pyx_v_r[4]))) + ((__pyx_v_m[14]) * (__pyx_v_r[8]))));

        /* "kivy\graphics\transformation.pyx":350
 *             r[15] = 1
 *             r[12] = -(m[12] * r[0] + m[13] * r[4] + m[14] * r[ 8])
 *             r[13] = -(m[12] * r[1] + m[13] * r[5] + m[14] * r[ 9])             # <<<<<<<<<<<<<<
 *             r[14] = -(m[12] * r[2] + m[13] * r[6] + m[14] * r[10])
 *         return mr
 */
        (__pyx_v_r[13]) = (-((((__pyx_v_m[12]) * (__pyx_v_r[1])) + ((__pyx_v_m[13]) * (__pyx_v_r[5]))) + ((__pyx_v_m[14]) * (__pyx_v_r[9]))));

        /* "kivy\graphics\transformation.pyx":351
 *             r[12] = -(m[12] * r[0] + m[13] * r[4] + m[14] * r[ 8])
 *             r[13] = -(m[12] * r[1] + m[13] * r[5] + m[14] * r[ 9])
 *             r[14] = -(m[12] * r[2] + m[13] * r[6] + m[14] * r[10])             # <<<<<<<<<<<<<<
 *         return mr
 * 
 */
        (__pyx_v_r[14]) = (-((((__pyx_v_m[12]) * (__pyx_v_r[2])) + ((__pyx_v_m[13]) * (__pyx_v_r[6]))) + ((__pyx_v_m[14]) * (__pyx_v_r[10]))));
      }

      /* "kivy\graphics\transformation.pyx":334
 *         if det == 0:
 *             return
 *         with nogil:             # <<<<<<<<<<<<<<
 *             det = 1.0 / det
 *             r[ 0] =   det * (m[5] * m[10] - m[9] * m[6])
 */
      /*finally:*/ {
        #ifdef WITH_THREAD
        Py_BLOCK_THREADS
        #endif
      }
  }

  /* "kivy\graphics\transformation.pyx":352
 *             r[13] = -(m[12] * r[1] + m[13] * r[5] + m[14] * r[ 9])
 *             r[14] = -(m[12] * r[2] + m[13] * r[6] + m[14] * r[10])
 *         return mr             # <<<<<<<<<<<<<<
 * 
 *     cpdef Matrix normal_matrix(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_mr));
  __pyx_r = __pyx_v_mr;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.inverse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mr);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_23inverse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_22inverse[] = "Return the inverse of the matrix as a new Matrix.\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_23inverse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("inverse (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_22inverse(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":322
 *         return mm
 * 
 *     cpdef Matrix inverse(self):             # <<<<<<<<<<<<<<
 *         '''Return the inverse of the matrix as a new Matrix.
 *         '''
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_22inverse(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("inverse", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->inverse(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.inverse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":354
 *         return mr
 * 
 *     cpdef Matrix normal_matrix(self):             # <<<<<<<<<<<<<<
 *         '''Computes the normal matrix, which is the inverse transpose
 *         of the top left 3x3 modelview matrix used to transform normals
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_25normal_matrix(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_f_4kivy_8graphics_14transformation_6Matrix_normal_matrix(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_nm = 0;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("normal_matrix", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__normal_matrix); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_25normal_matrix)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4kivy_8graphics_14transformation_Matrix))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":361
 *         .. versionadded:: 1.6.0
 *         '''
 *         cdef Matrix nm = Matrix().multiply(self)             # <<<<<<<<<<<<<<
 *         nm = nm.inverse().transpose()
 *         nm.mat[3] = 0
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_14transformation_Matrix)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_1)->__pyx_vtab)->multiply(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_1), __pyx_v_self, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_nm = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "kivy\graphics\transformation.pyx":362
 *         '''
 *         cdef Matrix nm = Matrix().multiply(self)
 *         nm = nm.inverse().transpose()             # <<<<<<<<<<<<<<
 *         nm.mat[3] = 0
 *         nm.mat[7] = 0
 */
  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_nm->__pyx_vtab)->inverse(__pyx_v_nm, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_2)->__pyx_vtab)->transpose(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_2), 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_v_nm));
  __pyx_v_nm = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "kivy\graphics\transformation.pyx":363
 *         cdef Matrix nm = Matrix().multiply(self)
 *         nm = nm.inverse().transpose()
 *         nm.mat[3] = 0             # <<<<<<<<<<<<<<
 *         nm.mat[7] = 0
 *         nm.mat[11] = 0
 */
  (__pyx_v_nm->mat[3]) = 0.0;

  /* "kivy\graphics\transformation.pyx":364
 *         nm = nm.inverse().transpose()
 *         nm.mat[3] = 0
 *         nm.mat[7] = 0             # <<<<<<<<<<<<<<
 *         nm.mat[11] = 0
 *         nm.mat[12] = 0
 */
  (__pyx_v_nm->mat[7]) = 0.0;

  /* "kivy\graphics\transformation.pyx":365
 *         nm.mat[3] = 0
 *         nm.mat[7] = 0
 *         nm.mat[11] = 0             # <<<<<<<<<<<<<<
 *         nm.mat[12] = 0
 *         nm.mat[13] = 0
 */
  (__pyx_v_nm->mat[11]) = 0.0;

  /* "kivy\graphics\transformation.pyx":366
 *         nm.mat[7] = 0
 *         nm.mat[11] = 0
 *         nm.mat[12] = 0             # <<<<<<<<<<<<<<
 *         nm.mat[13] = 0
 *         nm.mat[14] = 0
 */
  (__pyx_v_nm->mat[12]) = 0.0;

  /* "kivy\graphics\transformation.pyx":367
 *         nm.mat[11] = 0
 *         nm.mat[12] = 0
 *         nm.mat[13] = 0             # <<<<<<<<<<<<<<
 *         nm.mat[14] = 0
 *         nm.mat[15] = 1
 */
  (__pyx_v_nm->mat[13]) = 0.0;

  /* "kivy\graphics\transformation.pyx":368
 *         nm.mat[12] = 0
 *         nm.mat[13] = 0
 *         nm.mat[14] = 0             # <<<<<<<<<<<<<<
 *         nm.mat[15] = 1
 *         return nm
 */
  (__pyx_v_nm->mat[14]) = 0.0;

  /* "kivy\graphics\transformation.pyx":369
 *         nm.mat[13] = 0
 *         nm.mat[14] = 0
 *         nm.mat[15] = 1             # <<<<<<<<<<<<<<
 *         return nm
 * 
 */
  (__pyx_v_nm->mat[15]) = 1.0;

  /* "kivy\graphics\transformation.pyx":370
 *         nm.mat[14] = 0
 *         nm.mat[15] = 1
 *         return nm             # <<<<<<<<<<<<<<
 * 
 *     cpdef Matrix multiply(Matrix mb, Matrix ma):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_nm));
  __pyx_r = __pyx_v_nm;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.normal_matrix", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_nm);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_25normal_matrix(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_24normal_matrix[] = "Computes the normal matrix, which is the inverse transpose\n        of the top left 3x3 modelview matrix used to transform normals \n        into eye/camera space.\n\n        .. versionadded:: 1.6.0\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_25normal_matrix(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("normal_matrix (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_24normal_matrix(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":354
 *         return mr
 * 
 *     cpdef Matrix normal_matrix(self):             # <<<<<<<<<<<<<<
 *         '''Computes the normal matrix, which is the inverse transpose
 *         of the top left 3x3 modelview matrix used to transform normals
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_24normal_matrix(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("normal_matrix", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->normal_matrix(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.normal_matrix", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":372
 *         return nm
 * 
 *     cpdef Matrix multiply(Matrix mb, Matrix ma):             # <<<<<<<<<<<<<<
 *         '''Multiply the given matrix with self (from the left).
 *         I.e., we premultiply the given matrix to the current matrix and return
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_27multiply(PyObject *__pyx_v_mb, PyObject *__pyx_v_ma); /*proto*/
static struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_f_4kivy_8graphics_14transformation_6Matrix_multiply(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_mb, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_ma, int __pyx_skip_dispatch) {
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_mr = 0;
  double *__pyx_v_a;
  double *__pyx_v_b;
  double *__pyx_v_r;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("multiply", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_mb))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mb), __pyx_n_s__multiply); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_27multiply)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_ma));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_ma));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_ma));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4kivy_8graphics_14transformation_Matrix))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":379
 *             m.multiply(n) -> n * m
 *         '''
 *         cdef Matrix mr = Matrix()             # <<<<<<<<<<<<<<
 *         cdef double *a = <double *>ma.mat, *b = <double *>mb.mat, *r = <double *>mr.mat
 *         with nogil:
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_14transformation_Matrix)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_mr = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "kivy\graphics\transformation.pyx":380
 *         '''
 *         cdef Matrix mr = Matrix()
 *         cdef double *a = <double *>ma.mat, *b = <double *>mb.mat, *r = <double *>mr.mat             # <<<<<<<<<<<<<<
 *         with nogil:
 *             r[ 0] = a[ 0] * b[0] + a[ 1] * b[4] + a[ 2] * b[ 8]
 */
  __pyx_v_a = ((double *)__pyx_v_ma->mat);
  __pyx_v_b = ((double *)__pyx_v_mb->mat);
  __pyx_v_r = ((double *)__pyx_v_mr->mat);

  /* "kivy\graphics\transformation.pyx":381
 *         cdef Matrix mr = Matrix()
 *         cdef double *a = <double *>ma.mat, *b = <double *>mb.mat, *r = <double *>mr.mat
 *         with nogil:             # <<<<<<<<<<<<<<
 *             r[ 0] = a[ 0] * b[0] + a[ 1] * b[4] + a[ 2] * b[ 8]
 *             r[ 4] = a[ 4] * b[0] + a[ 5] * b[4] + a[ 6] * b[ 8]
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "kivy\graphics\transformation.pyx":382
 *         cdef double *a = <double *>ma.mat, *b = <double *>mb.mat, *r = <double *>mr.mat
 *         with nogil:
 *             r[ 0] = a[ 0] * b[0] + a[ 1] * b[4] + a[ 2] * b[ 8]             # <<<<<<<<<<<<<<
 *             r[ 4] = a[ 4] * b[0] + a[ 5] * b[4] + a[ 6] * b[ 8]
 *             r[ 8] = a[ 8] * b[0] + a[ 9] * b[4] + a[10] * b[ 8]
 */
        (__pyx_v_r[0]) = ((((__pyx_v_a[0]) * (__pyx_v_b[0])) + ((__pyx_v_a[1]) * (__pyx_v_b[4]))) + ((__pyx_v_a[2]) * (__pyx_v_b[8])));

        /* "kivy\graphics\transformation.pyx":383
 *         with nogil:
 *             r[ 0] = a[ 0] * b[0] + a[ 1] * b[4] + a[ 2] * b[ 8]
 *             r[ 4] = a[ 4] * b[0] + a[ 5] * b[4] + a[ 6] * b[ 8]             # <<<<<<<<<<<<<<
 *             r[ 8] = a[ 8] * b[0] + a[ 9] * b[4] + a[10] * b[ 8]
 *             r[12] = a[12] * b[0] + a[13] * b[4] + a[14] * b[ 8] + b[12]
 */
        (__pyx_v_r[4]) = ((((__pyx_v_a[4]) * (__pyx_v_b[0])) + ((__pyx_v_a[5]) * (__pyx_v_b[4]))) + ((__pyx_v_a[6]) * (__pyx_v_b[8])));

        /* "kivy\graphics\transformation.pyx":384
 *             r[ 0] = a[ 0] * b[0] + a[ 1] * b[4] + a[ 2] * b[ 8]
 *             r[ 4] = a[ 4] * b[0] + a[ 5] * b[4] + a[ 6] * b[ 8]
 *             r[ 8] = a[ 8] * b[0] + a[ 9] * b[4] + a[10] * b[ 8]             # <<<<<<<<<<<<<<
 *             r[12] = a[12] * b[0] + a[13] * b[4] + a[14] * b[ 8] + b[12]
 *             r[ 1] = a[ 0] * b[1] + a[ 1] * b[5] + a[ 2] * b[ 9]
 */
        (__pyx_v_r[8]) = ((((__pyx_v_a[8]) * (__pyx_v_b[0])) + ((__pyx_v_a[9]) * (__pyx_v_b[4]))) + ((__pyx_v_a[10]) * (__pyx_v_b[8])));

        /* "kivy\graphics\transformation.pyx":385
 *             r[ 4] = a[ 4] * b[0] + a[ 5] * b[4] + a[ 6] * b[ 8]
 *             r[ 8] = a[ 8] * b[0] + a[ 9] * b[4] + a[10] * b[ 8]
 *             r[12] = a[12] * b[0] + a[13] * b[4] + a[14] * b[ 8] + b[12]             # <<<<<<<<<<<<<<
 *             r[ 1] = a[ 0] * b[1] + a[ 1] * b[5] + a[ 2] * b[ 9]
 *             r[ 5] = a[ 4] * b[1] + a[ 5] * b[5] + a[ 6] * b[ 9]
 */
        (__pyx_v_r[12]) = (((((__pyx_v_a[12]) * (__pyx_v_b[0])) + ((__pyx_v_a[13]) * (__pyx_v_b[4]))) + ((__pyx_v_a[14]) * (__pyx_v_b[8]))) + (__pyx_v_b[12]));

        /* "kivy\graphics\transformation.pyx":386
 *             r[ 8] = a[ 8] * b[0] + a[ 9] * b[4] + a[10] * b[ 8]
 *             r[12] = a[12] * b[0] + a[13] * b[4] + a[14] * b[ 8] + b[12]
 *             r[ 1] = a[ 0] * b[1] + a[ 1] * b[5] + a[ 2] * b[ 9]             # <<<<<<<<<<<<<<
 *             r[ 5] = a[ 4] * b[1] + a[ 5] * b[5] + a[ 6] * b[ 9]
 *             r[ 9] = a[ 8] * b[1] + a[ 9] * b[5] + a[10] * b[ 9]
 */
        (__pyx_v_r[1]) = ((((__pyx_v_a[0]) * (__pyx_v_b[1])) + ((__pyx_v_a[1]) * (__pyx_v_b[5]))) + ((__pyx_v_a[2]) * (__pyx_v_b[9])));

        /* "kivy\graphics\transformation.pyx":387
 *             r[12] = a[12] * b[0] + a[13] * b[4] + a[14] * b[ 8] + b[12]
 *             r[ 1] = a[ 0] * b[1] + a[ 1] * b[5] + a[ 2] * b[ 9]
 *             r[ 5] = a[ 4] * b[1] + a[ 5] * b[5] + a[ 6] * b[ 9]             # <<<<<<<<<<<<<<
 *             r[ 9] = a[ 8] * b[1] + a[ 9] * b[5] + a[10] * b[ 9]
 *             r[13] = a[12] * b[1] + a[13] * b[5] + a[14] * b[ 9] + b[13]
 */
        (__pyx_v_r[5]) = ((((__pyx_v_a[4]) * (__pyx_v_b[1])) + ((__pyx_v_a[5]) * (__pyx_v_b[5]))) + ((__pyx_v_a[6]) * (__pyx_v_b[9])));

        /* "kivy\graphics\transformation.pyx":388
 *             r[ 1] = a[ 0] * b[1] + a[ 1] * b[5] + a[ 2] * b[ 9]
 *             r[ 5] = a[ 4] * b[1] + a[ 5] * b[5] + a[ 6] * b[ 9]
 *             r[ 9] = a[ 8] * b[1] + a[ 9] * b[5] + a[10] * b[ 9]             # <<<<<<<<<<<<<<
 *             r[13] = a[12] * b[1] + a[13] * b[5] + a[14] * b[ 9] + b[13]
 *             r[ 2] = a[ 0] * b[2] + a[ 1] * b[6] + a[ 2] * b[10]
 */
        (__pyx_v_r[9]) = ((((__pyx_v_a[8]) * (__pyx_v_b[1])) + ((__pyx_v_a[9]) * (__pyx_v_b[5]))) + ((__pyx_v_a[10]) * (__pyx_v_b[9])));

        /* "kivy\graphics\transformation.pyx":389
 *             r[ 5] = a[ 4] * b[1] + a[ 5] * b[5] + a[ 6] * b[ 9]
 *             r[ 9] = a[ 8] * b[1] + a[ 9] * b[5] + a[10] * b[ 9]
 *             r[13] = a[12] * b[1] + a[13] * b[5] + a[14] * b[ 9] + b[13]             # <<<<<<<<<<<<<<
 *             r[ 2] = a[ 0] * b[2] + a[ 1] * b[6] + a[ 2] * b[10]
 *             r[ 6] = a[ 4] * b[2] + a[ 5] * b[6] + a[ 6] * b[10]
 */
        (__pyx_v_r[13]) = (((((__pyx_v_a[12]) * (__pyx_v_b[1])) + ((__pyx_v_a[13]) * (__pyx_v_b[5]))) + ((__pyx_v_a[14]) * (__pyx_v_b[9]))) + (__pyx_v_b[13]));

        /* "kivy\graphics\transformation.pyx":390
 *             r[ 9] = a[ 8] * b[1] + a[ 9] * b[5] + a[10] * b[ 9]
 *             r[13] = a[12] * b[1] + a[13] * b[5] + a[14] * b[ 9] + b[13]
 *             r[ 2] = a[ 0] * b[2] + a[ 1] * b[6] + a[ 2] * b[10]             # <<<<<<<<<<<<<<
 *             r[ 6] = a[ 4] * b[2] + a[ 5] * b[6] + a[ 6] * b[10]
 *             r[10] = a[ 8] * b[2] + a[ 9] * b[6] + a[10] * b[10]
 */
        (__pyx_v_r[2]) = ((((__pyx_v_a[0]) * (__pyx_v_b[2])) + ((__pyx_v_a[1]) * (__pyx_v_b[6]))) + ((__pyx_v_a[2]) * (__pyx_v_b[10])));

        /* "kivy\graphics\transformation.pyx":391
 *             r[13] = a[12] * b[1] + a[13] * b[5] + a[14] * b[ 9] + b[13]
 *             r[ 2] = a[ 0] * b[2] + a[ 1] * b[6] + a[ 2] * b[10]
 *             r[ 6] = a[ 4] * b[2] + a[ 5] * b[6] + a[ 6] * b[10]             # <<<<<<<<<<<<<<
 *             r[10] = a[ 8] * b[2] + a[ 9] * b[6] + a[10] * b[10]
 *             r[14] = a[12] * b[2] + a[13] * b[6] + a[14] * b[10] + b[14]
 */
        (__pyx_v_r[6]) = ((((__pyx_v_a[4]) * (__pyx_v_b[2])) + ((__pyx_v_a[5]) * (__pyx_v_b[6]))) + ((__pyx_v_a[6]) * (__pyx_v_b[10])));

        /* "kivy\graphics\transformation.pyx":392
 *             r[ 2] = a[ 0] * b[2] + a[ 1] * b[6] + a[ 2] * b[10]
 *             r[ 6] = a[ 4] * b[2] + a[ 5] * b[6] + a[ 6] * b[10]
 *             r[10] = a[ 8] * b[2] + a[ 9] * b[6] + a[10] * b[10]             # <<<<<<<<<<<<<<
 *             r[14] = a[12] * b[2] + a[13] * b[6] + a[14] * b[10] + b[14]
 *             r[ 3] = 0
 */
        (__pyx_v_r[10]) = ((((__pyx_v_a[8]) * (__pyx_v_b[2])) + ((__pyx_v_a[9]) * (__pyx_v_b[6]))) + ((__pyx_v_a[10]) * (__pyx_v_b[10])));

        /* "kivy\graphics\transformation.pyx":393
 *             r[ 6] = a[ 4] * b[2] + a[ 5] * b[6] + a[ 6] * b[10]
 *             r[10] = a[ 8] * b[2] + a[ 9] * b[6] + a[10] * b[10]
 *             r[14] = a[12] * b[2] + a[13] * b[6] + a[14] * b[10] + b[14]             # <<<<<<<<<<<<<<
 *             r[ 3] = 0
 *             r[ 7] = 0
 */
        (__pyx_v_r[14]) = (((((__pyx_v_a[12]) * (__pyx_v_b[2])) + ((__pyx_v_a[13]) * (__pyx_v_b[6]))) + ((__pyx_v_a[14]) * (__pyx_v_b[10]))) + (__pyx_v_b[14]));

        /* "kivy\graphics\transformation.pyx":394
 *             r[10] = a[ 8] * b[2] + a[ 9] * b[6] + a[10] * b[10]
 *             r[14] = a[12] * b[2] + a[13] * b[6] + a[14] * b[10] + b[14]
 *             r[ 3] = 0             # <<<<<<<<<<<<<<
 *             r[ 7] = 0
 *             r[11] = 0
 */
        (__pyx_v_r[3]) = 0.0;

        /* "kivy\graphics\transformation.pyx":395
 *             r[14] = a[12] * b[2] + a[13] * b[6] + a[14] * b[10] + b[14]
 *             r[ 3] = 0
 *             r[ 7] = 0             # <<<<<<<<<<<<<<
 *             r[11] = 0
 *             r[15] = 1
 */
        (__pyx_v_r[7]) = 0.0;

        /* "kivy\graphics\transformation.pyx":396
 *             r[ 3] = 0
 *             r[ 7] = 0
 *             r[11] = 0             # <<<<<<<<<<<<<<
 *             r[15] = 1
 *         return mr
 */
        (__pyx_v_r[11]) = 0.0;

        /* "kivy\graphics\transformation.pyx":397
 *             r[ 7] = 0
 *             r[11] = 0
 *             r[15] = 1             # <<<<<<<<<<<<<<
 *         return mr
 * 
 */
        (__pyx_v_r[15]) = 1.0;
      }

      /* "kivy\graphics\transformation.pyx":381
 *         cdef Matrix mr = Matrix()
 *         cdef double *a = <double *>ma.mat, *b = <double *>mb.mat, *r = <double *>mr.mat
 *         with nogil:             # <<<<<<<<<<<<<<
 *             r[ 0] = a[ 0] * b[0] + a[ 1] * b[4] + a[ 2] * b[ 8]
 *             r[ 4] = a[ 4] * b[0] + a[ 5] * b[4] + a[ 6] * b[ 8]
 */
      /*finally:*/ {
        #ifdef WITH_THREAD
        Py_BLOCK_THREADS
        #endif
      }
  }

  /* "kivy\graphics\transformation.pyx":398
 *             r[11] = 0
 *             r[15] = 1
 *         return mr             # <<<<<<<<<<<<<<
 * 
 *     cpdef project(Matrix self, double objx, double objy, double objz, Matrix model, Matrix proj,
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_mr));
  __pyx_r = __pyx_v_mr;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.multiply", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mr);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_27multiply(PyObject *__pyx_v_mb, PyObject *__pyx_v_ma); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_26multiply[] = "Multiply the given matrix with self (from the left).\n        I.e., we premultiply the given matrix to the current matrix and return\n        the result (not inplace)::\n\n            m.multiply(n) -> n * m\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_27multiply(PyObject *__pyx_v_mb, PyObject *__pyx_v_ma) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("multiply (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ma), __pyx_ptype_4kivy_8graphics_14transformation_Matrix, 1, "ma", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_26multiply(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_mb), ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_ma));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":372
 *         return nm
 * 
 *     cpdef Matrix multiply(Matrix mb, Matrix ma):             # <<<<<<<<<<<<<<
 *         '''Multiply the given matrix with self (from the left).
 *         I.e., we premultiply the given matrix to the current matrix and return
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_26multiply(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_mb, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_ma) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("multiply", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_mb->__pyx_vtab)->multiply(__pyx_v_mb, __pyx_v_ma, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.multiply", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":400
 *         return mr
 * 
 *     cpdef project(Matrix self, double objx, double objy, double objz, Matrix model, Matrix proj,             # <<<<<<<<<<<<<<
 *             double vx, double vy, double vw, double vh):
 *         '''Project a point from 3d space to 2d viewport.
 */

static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_29project(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4kivy_8graphics_14transformation_6Matrix_project(CYTHON_UNUSED struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_objx, double __pyx_v_objy, double __pyx_v_objz, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_model, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_proj, double __pyx_v_vx, double __pyx_v_vy, double __pyx_v_vw, double __pyx_v_vh, int __pyx_skip_dispatch) {
  double __pyx_v_winx;
  double __pyx_v_winy;
  double __pyx_v_winz;
  PyObject *__pyx_v_point = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  struct __pyx_opt_args_4kivy_8graphics_14transformation_6Matrix_transform_point __pyx_t_10;
  int __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  double __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("project", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__project); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_29project)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_objx); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_objy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_objz); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_vx); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyFloat_FromDouble(__pyx_v_vy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyFloat_FromDouble(__pyx_v_vw); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyFloat_FromDouble(__pyx_v_vh); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyTuple_New(9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_v_model));
      PyTuple_SET_ITEM(__pyx_t_9, 3, ((PyObject *)__pyx_v_model));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_model));
      __Pyx_INCREF(((PyObject *)__pyx_v_proj));
      PyTuple_SET_ITEM(__pyx_t_9, 4, ((PyObject *)__pyx_v_proj));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_proj));
      PyTuple_SET_ITEM(__pyx_t_9, 5, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_9, 6, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 7, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_9, 8, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __pyx_r = __pyx_t_8;
      __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\transformation.pyx":407
 *         '''
 *         cdef double winx, winy, winz
 *         cdef list point = list(model.transform_point(objx, objy, objz, 1.0))             # <<<<<<<<<<<<<<
 *         point = list(proj.transform_point(*point))
 * 
 */
  __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_10.__pyx_n = 1;
  __pyx_t_10.t = __pyx_t_1;
  __pyx_t_8 = ((PyObject *)((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_model->__pyx_vtab)->transform_point(__pyx_v_model, __pyx_v_objx, __pyx_v_objy, __pyx_v_objz, 0, &__pyx_t_10)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_8 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_point = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "kivy\graphics\transformation.pyx":408
 *         cdef double winx, winy, winz
 *         cdef list point = list(model.transform_point(objx, objy, objz, 1.0))
 *         point = list(proj.transform_point(*point))             # <<<<<<<<<<<<<<
 * 
 *         if point[3] == 0:
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_proj), __pyx_n_s__transform_point); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = PySequence_Tuple(((PyObject *)__pyx_v_point)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_9 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_v_point));
  __pyx_v_point = ((PyObject*)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "kivy\graphics\transformation.pyx":410
 *         point = list(proj.transform_point(*point))
 * 
 *         if point[3] == 0:             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  __pyx_t_9 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_point), 3, sizeof(long), PyInt_FromLong, 1, 0, 1); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_9, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_11) {

    /* "kivy\graphics\transformation.pyx":411
 * 
 *         if point[3] == 0:
 *             return None             # <<<<<<<<<<<<<<
 * 
 *         point[0] /= point[3]
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\transformation.pyx":413
 *             return None
 * 
 *         point[0] /= point[3]             # <<<<<<<<<<<<<<
 *         point[1] /= point[3]
 *         point[2] /= point[3]
 */
  __pyx_t_12 = 0;
  __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_point), __pyx_t_12, sizeof(Py_ssize_t), PyInt_FromSsize_t, 1, 1, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_point), 3, sizeof(long), PyInt_FromLong, 1, 0, 1); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_8 = __Pyx_PyNumber_InPlaceDivide(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__Pyx_SetItemInt(((PyObject *)__pyx_v_point), __pyx_t_12, __pyx_t_8, sizeof(Py_ssize_t), PyInt_FromSsize_t, 1, 1, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "kivy\graphics\transformation.pyx":414
 * 
 *         point[0] /= point[3]
 *         point[1] /= point[3]             # <<<<<<<<<<<<<<
 *         point[2] /= point[3]
 * 
 */
  __pyx_t_12 = 1;
  __pyx_t_8 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_point), __pyx_t_12, sizeof(Py_ssize_t), PyInt_FromSsize_t, 1, 1, 1); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_point), 3, sizeof(long), PyInt_FromLong, 1, 0, 1); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = __Pyx_PyNumber_InPlaceDivide(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__Pyx_SetItemInt(((PyObject *)__pyx_v_point), __pyx_t_12, __pyx_t_1, sizeof(Py_ssize_t), PyInt_FromSsize_t, 1, 1, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy\graphics\transformation.pyx":415
 *         point[0] /= point[3]
 *         point[1] /= point[3]
 *         point[2] /= point[3]             # <<<<<<<<<<<<<<
 * 
 *         winx = vx + (1 + point[0]) * vw / 2.
 */
  __pyx_t_12 = 2;
  __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_point), __pyx_t_12, sizeof(Py_ssize_t), PyInt_FromSsize_t, 1, 1, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_point), 3, sizeof(long), PyInt_FromLong, 1, 0, 1); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_8 = __Pyx_PyNumber_InPlaceDivide(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__Pyx_SetItemInt(((PyObject *)__pyx_v_point), __pyx_t_12, __pyx_t_8, sizeof(Py_ssize_t), PyInt_FromSsize_t, 1, 1, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "kivy\graphics\transformation.pyx":417
 *         point[2] /= point[3]
 * 
 *         winx = vx + (1 + point[0]) * vw / 2.             # <<<<<<<<<<<<<<
 *         winy = vy + (1 + point[1]) * vh / 2.
 *         winz = (1 + point[2]) / 2.
 */
  __pyx_t_8 = PyFloat_FromDouble(__pyx_v_vx); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_point), 0, sizeof(long), PyInt_FromLong, 1, 0, 1); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = PyNumber_Add(__pyx_int_1, __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyFloat_FromDouble(__pyx_v_vw); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyFloat_FromDouble(2.); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyNumber_Add(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_winx = __pyx_t_13;

  /* "kivy\graphics\transformation.pyx":418
 * 
 *         winx = vx + (1 + point[0]) * vw / 2.
 *         winy = vy + (1 + point[1]) * vh / 2.             # <<<<<<<<<<<<<<
 *         winz = (1 + point[2]) / 2.
 * 
 */
  __pyx_t_9 = PyFloat_FromDouble(__pyx_v_vy); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_point), 1, sizeof(long), PyInt_FromLong, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyNumber_Add(__pyx_int_1, __pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_vh); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyNumber_Multiply(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble(2.); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(__pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_winy = __pyx_t_13;

  /* "kivy\graphics\transformation.pyx":419
 *         winx = vx + (1 + point[0]) * vw / 2.
 *         winy = vy + (1 + point[1]) * vh / 2.
 *         winz = (1 + point[2]) / 2.             # <<<<<<<<<<<<<<
 * 
 *         return (winx, winy, winz)
 */
  __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_point), 2, sizeof(long), PyInt_FromLong, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyNumber_Add(__pyx_int_1, __pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble(2.); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_winz = __pyx_t_13;

  /* "kivy\graphics\transformation.pyx":421
 *         winz = (1 + point[2]) / 2.
 * 
 *         return (winx, winy, winz)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_9 = PyFloat_FromDouble(__pyx_v_winx); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_winy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyFloat_FromDouble(__pyx_v_winz); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_9 = 0;
  __pyx_t_1 = 0;
  __pyx_t_8 = 0;
  __pyx_r = ((PyObject *)__pyx_t_7);
  __pyx_t_7 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.project", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_point);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_29project(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_14transformation_6Matrix_28project[] = "Project a point from 3d space to 2d viewport.\n\n        .. versionadded:: 1.7.0\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_29project(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_objx;
  double __pyx_v_objy;
  double __pyx_v_objz;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_model = 0;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_proj = 0;
  double __pyx_v_vx;
  double __pyx_v_vy;
  double __pyx_v_vw;
  double __pyx_v_vh;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("project (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__objx,&__pyx_n_s__objy,&__pyx_n_s__objz,&__pyx_n_s__model,&__pyx_n_s__proj,&__pyx_n_s__vx,&__pyx_n_s__vy,&__pyx_n_s__vw,&__pyx_n_s__vh,0};
    PyObject* values[9] = {0,0,0,0,0,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  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__objx)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__objy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("project", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__objz)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("project", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__model)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("project", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__proj)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("project", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("project", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("project", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vw)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("project", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  8:
        if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vh)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("project", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "project") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 9) {
      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);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
    }
    __pyx_v_objx = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_objx == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_objy = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_objy == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_objz = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_objz == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_model = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)values[3]);
    __pyx_v_proj = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)values[4]);
    __pyx_v_vx = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_vx == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_vy = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_vy == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_vw = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_vw == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_vh = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_vh == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("project", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.project", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_model), __pyx_ptype_4kivy_8graphics_14transformation_Matrix, 1, "model", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_proj), __pyx_ptype_4kivy_8graphics_14transformation_Matrix, 1, "proj", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_28project(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self), __pyx_v_objx, __pyx_v_objy, __pyx_v_objz, __pyx_v_model, __pyx_v_proj, __pyx_v_vx, __pyx_v_vy, __pyx_v_vw, __pyx_v_vh);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":400
 *         return mr
 * 
 *     cpdef project(Matrix self, double objx, double objy, double objz, Matrix model, Matrix proj,             # <<<<<<<<<<<<<<
 *             double vx, double vy, double vw, double vh):
 *         '''Project a point from 3d space to 2d viewport.
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_28project(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self, double __pyx_v_objx, double __pyx_v_objy, double __pyx_v_objz, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_model, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_proj, double __pyx_v_vx, double __pyx_v_vy, double __pyx_v_vw, double __pyx_v_vh) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("project", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self->__pyx_vtab)->project(__pyx_v_self, __pyx_v_objx, __pyx_v_objy, __pyx_v_objz, __pyx_v_model, __pyx_v_proj, __pyx_v_vx, __pyx_v_vy, __pyx_v_vw, __pyx_v_vh, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.transformation.Matrix.project", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_31__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_14transformation_6Matrix_31__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_14transformation_6Matrix_30__str__(((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\transformation.pyx":423
 *         return (winx, winy, winz)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         cdef double *m = <double *>self.mat
 *         return '[[ %f %f %f %f ]\n[ %f %f %f %f ]\n' \
 */

static PyObject *__pyx_pf_4kivy_8graphics_14transformation_6Matrix_30__str__(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *__pyx_v_self) {
  double *__pyx_v_m;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "kivy\graphics\transformation.pyx":424
 * 
 *     def __str__(self):
 *         cdef double *m = <double *>self.mat             # <<<<<<<<<<<<<<
 *         return '[[ %f %f %f %f ]\n[ %f %f %f %f ]\n' \
 *                '[ %f %f %f %f ]\n[ %f %f %f %f ]]' % (
 */
  __pyx_v_m = ((double *)__pyx_v_self->mat);

  /* "kivy\graphics\transformation.pyx":425
 *     def __str__(self):
 *         cdef double *m = <double *>self.mat
 *         return '[[ %f %f %f %f ]\n[ %f %f %f %f ]\n' \             # <<<<<<<<<<<<<<
 *                '[ %f %f %f %f ]\n[ %f %f %f %f ]]' % (
 *                    m[0], m[1], m[2], m[3],
 */
  __Pyx_XDECREF(__pyx_r);

  /* "kivy\graphics\transformation.pyx":427
 *         return '[[ %f %f %f %f ]\n[ %f %f %f %f ]\n' \
 *                '[ %f %f %f %f ]\n[ %f %f %f %f ]]' % (
 *                    m[0], m[1], m[2], m[3],             # <<<<<<<<<<<<<<
 *                    m[4], m[5], m[6], m[7],
 *                    m[8], m[9], m[10], m[11],
 */
  __pyx_t_1 = PyFloat_FromDouble((__pyx_v_m[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble((__pyx_v_m[1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble((__pyx_v_m[2])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble((__pyx_v_m[3])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "kivy\graphics\transformation.pyx":428
 *                '[ %f %f %f %f ]\n[ %f %f %f %f ]]' % (
 *                    m[0], m[1], m[2], m[3],
 *                    m[4], m[5], m[6], m[7],             # <<<<<<<<<<<<<<
 *                    m[8], m[9], m[10], m[11],
 *                    m[12], m[13], m[14], m[15])
 */
  __pyx_t_5 = PyFloat_FromDouble((__pyx_v_m[4])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyFloat_FromDouble((__pyx_v_m[5])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyFloat_FromDouble((__pyx_v_m[6])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyFloat_FromDouble((__pyx_v_m[7])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);

  /* "kivy\graphics\transformation.pyx":429
 *                    m[0], m[1], m[2], m[3],
 *                    m[4], m[5], m[6], m[7],
 *                    m[8], m[9], m[10], m[11],             # <<<<<<<<<<<<<<
 *                    m[12], m[13], m[14], m[15])
 * 
 */
  __pyx_t_9 = PyFloat_FromDouble((__pyx_v_m[8])); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = PyFloat_FromDouble((__pyx_v_m[9])); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = PyFloat_FromDouble((__pyx_v_m[10])); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = PyFloat_FromDouble((__pyx_v_m[11])); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);

  /* "kivy\graphics\transformation.pyx":430
 *                    m[4], m[5], m[6], m[7],
 *                    m[8], m[9], m[10], m[11],
 *                    m[12], m[13], m[14], m[15])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_13 = PyFloat_FromDouble((__pyx_v_m[12])); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = PyFloat_FromDouble((__pyx_v_m[13])); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = PyFloat_FromDouble((__pyx_v_m[14])); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_16 = PyFloat_FromDouble((__pyx_v_m[15])); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_17 = PyTuple_New(16); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_17, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_17, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_17, 4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_17, 5, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_17, 6, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_17, 7, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_17, 8, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_17, 9, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_17, 10, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_17, 11, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_17, 12, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_17, 13, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_17, 14, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_17, 15, __pyx_t_16);
  __Pyx_GIVEREF(__pyx_t_16);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_9 = 0;
  __pyx_t_10 = 0;
  __pyx_t_11 = 0;
  __pyx_t_12 = 0;
  __pyx_t_13 = 0;
  __pyx_t_14 = 0;
  __pyx_t_15 = 0;
  __pyx_t_16 = 0;
  __pyx_t_16 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_17)); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_16));
  __Pyx_DECREF(((PyObject *)__pyx_t_17)); __pyx_t_17 = 0;
  __pyx_r = ((PyObject *)__pyx_t_16);
  __pyx_t_16 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __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("kivy.graphics.transformation.Matrix.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix __pyx_vtable_4kivy_8graphics_14transformation_Matrix;

static PyObject *__pyx_tp_new_4kivy_8graphics_14transformation_Matrix(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *p;
  PyObject *o;
  o = (*t->tp_alloc)(t, 0);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *)o);
  p->__pyx_vtab = __pyx_vtabptr_4kivy_8graphics_14transformation_Matrix;
  if (unlikely(__pyx_pw_4kivy_8graphics_14transformation_6Matrix_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4kivy_8graphics_14transformation_Matrix(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_4kivy_8graphics_14transformation_Matrix[] = {
  {__Pyx_NAMESTR("rotate"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_5rotate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_4rotate)},
  {__Pyx_NAMESTR("scale"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_7scale, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_6scale)},
  {__Pyx_NAMESTR("translate"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_9translate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_8translate)},
  {__Pyx_NAMESTR("perspective"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_11perspective, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_10perspective)},
  {__Pyx_NAMESTR("view_clip"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_13view_clip, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_12view_clip)},
  {__Pyx_NAMESTR("look_at"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_15look_at, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_14look_at)},
  {__Pyx_NAMESTR("transform_point"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_17transform_point, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("identity"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_19identity, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_18identity)},
  {__Pyx_NAMESTR("transpose"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_21transpose, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_20transpose)},
  {__Pyx_NAMESTR("inverse"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_23inverse, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_22inverse)},
  {__Pyx_NAMESTR("normal_matrix"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_25normal_matrix, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_24normal_matrix)},
  {__Pyx_NAMESTR("multiply"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_27multiply, METH_O, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_26multiply)},
  {__Pyx_NAMESTR("project"), (PyCFunction)__pyx_pw_4kivy_8graphics_14transformation_6Matrix_29project, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_14transformation_6Matrix_28project)},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4kivy_8graphics_14transformation_Matrix = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("kivy.graphics.transformation.Matrix"), /*tp_name*/
  sizeof(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4kivy_8graphics_14transformation_Matrix, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_4kivy_8graphics_14transformation_6Matrix_31__str__, /*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*/
  __Pyx_DOCSTR("\n    Optimized matrix class for OpenGL::\n\n        >>> from kivy.graphics.transformation import Matrix\n        >>> m = Matrix()\n        >>> print m\n        [[ 1.000000 0.000000 0.000000 0.000000 ]\n        [ 0.000000 1.000000 0.000000 0.000000 ]\n        [ 0.000000 0.000000 1.000000 0.000000 ]\n        [ 0.000000 0.000000 0.000000 1.000000 ]]\n\n        [ 0   1   2   3]\n        [ 4   5   6   7]\n        [ 8   9  10  11]\n        [ 12  13  14  15]\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4kivy_8graphics_14transformation_Matrix, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4kivy_8graphics_14transformation_6Matrix_3__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4kivy_8graphics_14transformation_Matrix, /*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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #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
    __Pyx_NAMESTR("transformation"),
    __Pyx_DOCSTR(__pyx_k_6), /* 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_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_n_s__Matrix, __pyx_k__Matrix, sizeof(__pyx_k__Matrix), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 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____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s__angle, __pyx_k__angle, sizeof(__pyx_k__angle), 0, 0, 1, 1},
  {&__pyx_n_s__aspect, __pyx_k__aspect, sizeof(__pyx_k__aspect), 0, 0, 1, 1},
  {&__pyx_n_s__bottom, __pyx_k__bottom, sizeof(__pyx_k__bottom), 0, 0, 1, 1},
  {&__pyx_n_s__centerx, __pyx_k__centerx, sizeof(__pyx_k__centerx), 0, 0, 1, 1},
  {&__pyx_n_s__centery, __pyx_k__centery, sizeof(__pyx_k__centery), 0, 0, 1, 1},
  {&__pyx_n_s__centerz, __pyx_k__centerz, sizeof(__pyx_k__centerz), 0, 0, 1, 1},
  {&__pyx_n_s__eyex, __pyx_k__eyex, sizeof(__pyx_k__eyex), 0, 0, 1, 1},
  {&__pyx_n_s__eyey, __pyx_k__eyey, sizeof(__pyx_k__eyey), 0, 0, 1, 1},
  {&__pyx_n_s__eyez, __pyx_k__eyez, sizeof(__pyx_k__eyez), 0, 0, 1, 1},
  {&__pyx_n_s__far, __pyx_k__far, sizeof(__pyx_k__far), 0, 0, 1, 1},
  {&__pyx_n_s__fovy, __pyx_k__fovy, sizeof(__pyx_k__fovy), 0, 0, 1, 1},
  {&__pyx_n_s__identity, __pyx_k__identity, sizeof(__pyx_k__identity), 0, 0, 1, 1},
  {&__pyx_n_s__inverse, __pyx_k__inverse, sizeof(__pyx_k__inverse), 0, 0, 1, 1},
  {&__pyx_n_s__left, __pyx_k__left, sizeof(__pyx_k__left), 0, 0, 1, 1},
  {&__pyx_n_s__look_at, __pyx_k__look_at, sizeof(__pyx_k__look_at), 0, 0, 1, 1},
  {&__pyx_n_s__model, __pyx_k__model, sizeof(__pyx_k__model), 0, 0, 1, 1},
  {&__pyx_n_s__multiply, __pyx_k__multiply, sizeof(__pyx_k__multiply), 0, 0, 1, 1},
  {&__pyx_n_s__near, __pyx_k__near, sizeof(__pyx_k__near), 0, 0, 1, 1},
  {&__pyx_n_s__normal_matrix, __pyx_k__normal_matrix, sizeof(__pyx_k__normal_matrix), 0, 0, 1, 1},
  {&__pyx_n_s__objx, __pyx_k__objx, sizeof(__pyx_k__objx), 0, 0, 1, 1},
  {&__pyx_n_s__objy, __pyx_k__objy, sizeof(__pyx_k__objy), 0, 0, 1, 1},
  {&__pyx_n_s__objz, __pyx_k__objz, sizeof(__pyx_k__objz), 0, 0, 1, 1},
  {&__pyx_n_s__perspective, __pyx_k__perspective, sizeof(__pyx_k__perspective), 0, 0, 1, 1},
  {&__pyx_n_s__proj, __pyx_k__proj, sizeof(__pyx_k__proj), 0, 0, 1, 1},
  {&__pyx_n_s__project, __pyx_k__project, sizeof(__pyx_k__project), 0, 0, 1, 1},
  {&__pyx_n_s__right, __pyx_k__right, sizeof(__pyx_k__right), 0, 0, 1, 1},
  {&__pyx_n_s__rotate, __pyx_k__rotate, sizeof(__pyx_k__rotate), 0, 0, 1, 1},
  {&__pyx_n_s__scale, __pyx_k__scale, sizeof(__pyx_k__scale), 0, 0, 1, 1},
  {&__pyx_n_s__t, __pyx_k__t, sizeof(__pyx_k__t), 0, 0, 1, 1},
  {&__pyx_n_s__top, __pyx_k__top, sizeof(__pyx_k__top), 0, 0, 1, 1},
  {&__pyx_n_s__transform_point, __pyx_k__transform_point, sizeof(__pyx_k__transform_point), 0, 0, 1, 1},
  {&__pyx_n_s__translate, __pyx_k__translate, sizeof(__pyx_k__translate), 0, 0, 1, 1},
  {&__pyx_n_s__transpose, __pyx_k__transpose, sizeof(__pyx_k__transpose), 0, 0, 1, 1},
  {&__pyx_n_s__upx, __pyx_k__upx, sizeof(__pyx_k__upx), 0, 0, 1, 1},
  {&__pyx_n_s__upy, __pyx_k__upy, sizeof(__pyx_k__upy), 0, 0, 1, 1},
  {&__pyx_n_s__upz, __pyx_k__upz, sizeof(__pyx_k__upz), 0, 0, 1, 1},
  {&__pyx_n_s__vh, __pyx_k__vh, sizeof(__pyx_k__vh), 0, 0, 1, 1},
  {&__pyx_n_s__view_clip, __pyx_k__view_clip, sizeof(__pyx_k__view_clip), 0, 0, 1, 1},
  {&__pyx_n_s__vw, __pyx_k__vw, sizeof(__pyx_k__vw), 0, 0, 1, 1},
  {&__pyx_n_s__vx, __pyx_k__vx, sizeof(__pyx_k__vx), 0, 0, 1, 1},
  {&__pyx_n_s__vy, __pyx_k__vy, sizeof(__pyx_k__vy), 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__z, __pyx_k__z, sizeof(__pyx_k__z), 0, 0, 1, 1},
  {&__pyx_n_s__zFar, __pyx_k__zFar, sizeof(__pyx_k__zFar), 0, 0, 1, 1},
  {&__pyx_n_s__zNear, __pyx_k__zNear, sizeof(__pyx_k__zNear), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "kivy\graphics\transformation.pyx":159
 *         cdef double t
 *         if left >= right or bottom >= top or near >= far:
 *             raise ValueError('invalid frustrum')             # <<<<<<<<<<<<<<
 *         if perspective and near <= _EPS:
 *             raise ValueError('invalid frustrum: near <= 0')
 */
  __pyx_k_tuple_2 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_1)); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_2);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));

  /* "kivy\graphics\transformation.pyx":161
 *             raise ValueError('invalid frustrum')
 *         if perspective and near <= _EPS:
 *             raise ValueError('invalid frustrum: near <= 0')             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_k_tuple_4 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_3)); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_4);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));

  /* "kivy\graphics\transformation.pyx":20
 * '''
 * 
 * __all__ = ('Matrix', )             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "math.h":
 */
  __pyx_k_tuple_7 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__Matrix)); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_7);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7));
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC inittransformation(void); /*proto*/
PyMODINIT_FUNC inittransformation(void)
#else
PyMODINIT_FUNC PyInit_transformation(void); /*proto*/
PyMODINIT_FUNC PyInit_transformation(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_transformation(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("transformation"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_6), 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_d);
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!PyDict_GetItemString(modules, "kivy.graphics.transformation")) {
      if (unlikely(PyDict_SetItemString(modules, "kivy.graphics.transformation", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__pyx_module_is_main_kivy__graphics__transformation) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_4kivy_8graphics_14transformation_Matrix = &__pyx_vtable_4kivy_8graphics_14transformation_Matrix;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.identity = (struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_identity;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.inverse = (struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_inverse;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.transpose = (struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_transpose;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.multiply = (struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_multiply;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.scale = (struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_scale;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.translate = (struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_translate;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.rotate = (struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_rotate;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.view_clip = (struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, double, double, int, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_view_clip;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.perspective = (struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_perspective;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.look_at = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, double, double, double, double, double, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_look_at;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.normal_matrix = (struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_normal_matrix;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.transform_point = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch, struct __pyx_opt_args_4kivy_8graphics_14transformation_6Matrix_transform_point *__pyx_optional_args))__pyx_f_4kivy_8graphics_14transformation_6Matrix_transform_point;
  __pyx_vtable_4kivy_8graphics_14transformation_Matrix.project = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_14transformation_6Matrix_project;
  if (PyType_Ready(&__pyx_type_4kivy_8graphics_14transformation_Matrix) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4kivy_8graphics_14transformation_Matrix.tp_dict, __pyx_vtabptr_4kivy_8graphics_14transformation_Matrix) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Matrix", (PyObject *)&__pyx_type_4kivy_8graphics_14transformation_Matrix) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_14transformation_Matrix = &__pyx_type_4kivy_8graphics_14transformation_Matrix;
  /*--- Type import code ---*/
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "kivy\graphics\transformation.pyx":20
 * '''
 * 
 * __all__ = ('Matrix', )             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "math.h":
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s____all__, ((PyObject *)__pyx_k_tuple_7)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "kivy\graphics\transformation.pyx":33
 *     void *memset(void *s, int c, int n)
 * 
 * cdef double _EPS = 8.8817841970012523e-16             # <<<<<<<<<<<<<<
 * 
 * cdef class Matrix:
 */
  __pyx_v_4kivy_8graphics_14transformation__EPS = 8.8817841970012523e-16;

  /* "kivy\graphics\transformation.pyx":1
 * #cython: cdivision=True             # <<<<<<<<<<<<<<
 * 
 * '''
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  if (__pyx_m) {
    __Pyx_AddTraceback("init kivy.graphics.transformation", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init kivy.graphics.transformation");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif /* CYTHON_REFNANNY */

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 '%s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

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,
                 "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CPYTHON_COMPILING_IN_PYPY
    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
        goto invalid_keyword;
    return 1;
#else
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
#endif
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    #if PY_VERSION_HEX < 0x02050000
    if (PyClass_Check(type)) {
    #else
    if (PyType_Check(type)) {
    #endif
#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;
        #if PY_VERSION_HEX < 0x02050000
        if (PyInstance_Check(type)) {
            type = (PyObject*) ((PyInstanceObject*)type)->in_class;
            Py_INCREF(type);
        } else {
            type = 0;
            PyErr_SetString(PyExc_TypeError,
                "raise: exception must be an old-style class or instance");
            goto raise_error;
        }
        #else
        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;
        }
        #endif
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else /* Python 3+ */
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 *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 = PyEval_CallObject(type, args);
        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) {
        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);
        }
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return NULL;
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return -1;
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
#else
    if (is_list || PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s____pyx_vtable__, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return (unsigned long)PyLong_AsUnsignedLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (unsigned long)PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return (long)PyLong_AsUnsignedLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(long) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (long)PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (signed long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return (signed long)PyLong_AsUnsignedLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(signed long) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (signed long)PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

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);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = (start + end) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,            /*int argcount,*/
        0,            /*int kwonlyargcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __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,      /*int firstlineno,*/
        __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;
    PyObject *py_globals = 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_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static 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  /* Python 3+ has unicode identifiers */
        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(char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else /* PY_VERSION_HEX < 0x03030000 */
        if (PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_DATA_SIZE(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
        return PyUnicode_AsUTF8AndSize(o, length);
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
#endif /* PY_VERSION_HEX < 0x03030000 */
    } else
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII  || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (r < 0) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (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 = 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) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred())
           PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
