/* Generated by Cython 0.16 on Fri Sep 14 12:12:05 2012 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 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 CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyCFunction_Call PyObject_Call
#else
  #define __Pyx_PyCFunction_Call PyCFunction_Call
#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 PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #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"
#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 > 0x03030000 && defined(PyUnicode_GET_LENGTH)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#else
  #define CYTHON_PEP393_ENABLED 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]))
#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_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

#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__cogent__align___pairwise_seqs
#define __PYX_HAVE_API__cogent__align___pairwise_seqs
#include "array_interface.h"
#include "math.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* inline attribute */
#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

/* unused attribute */
#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 long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

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

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))

#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_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[] = {
  "numerical_pyrex.pyx",
  "_pairwise_seqs.pyx",
};

/*--- Type declarations ---*/

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":30
 *     int CONTIGUOUS
 * 
 * ctypedef object ArrayType             # <<<<<<<<<<<<<<
 * 
 * cdef double *uncheckedArrayDouble(ArrayType A):
 */
typedef PyObject *__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType;
#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)

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *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 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 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_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

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

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;
}
#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
    if (PyList_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if (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 = (likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (likely(i >= 0)) {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            return m->sq_item(o, i);
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

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 void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename); /*proto*/

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 'cogent.align._pairwise_seqs' */
static double __pyx_v_6cogent_5align_14_pairwise_seqs_SCALE_STEP;
static double __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_FLOAT_VALUE;
static int __pyx_v_6cogent_5align_14_pairwise_seqs_MAX_XCOUNT;
static long __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_SCALE;
static long __pyx_v_6cogent_5align_14_pairwise_seqs_MAX_SCALE;
static void *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArray(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType, char, int, int, int **); /*proto*/
static void *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArray1D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType, char, int, int *); /*proto*/
static void *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArray2D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType, char, int, int *, int *); /*proto*/
static void *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArray3D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType, char, int, int *, int *, int *); /*proto*/
static void *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArray4D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType, char, int, int *, int *, int *, int *); /*proto*/
static double *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble2D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType, int *, int *); /*proto*/
static double *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble3D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType, int *, int *, int *); /*proto*/
static long *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong1D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType, int *); /*proto*/
static long *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong2D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType, int *, int *); /*proto*/
static unsigned char *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayUChar3D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType, int *, int *, int *); /*proto*/
#define __Pyx_MODULE_NAME "cogent.align._pairwise_seqs"
int __pyx_module_is_main_cogent__align___pairwise_seqs = 0;

/* Implementation of 'cogent.align._pairwise_seqs' */
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_chr;
static PyObject *__pyx_builtin_ArithmeticError;
static PyObject *__pyx_pf_6cogent_5align_14_pairwise_seqs_fmpt(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mantissa, PyObject *__pyx_v_exponent, PyObject *__pyx_v_msg); /* proto */
static PyObject *__pyx_pf_6cogent_5align_14_pairwise_seqs_2calc_rows(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_plan, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_seq1_index, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_seq2_index, int __pyx_v_i_low, int __pyx_v_i_high, int __pyx_v_j_low, int __pyx_v_j_high, CYTHON_UNUSED PyObject *__pyx_v_preds, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_state_directions, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_T, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_xgap_scores, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_ygap_scores, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_match_scores, PyObject *__pyx_v_rows, PyObject *__pyx_v_track, PyObject *__pyx_v_track_enc, int __pyx_v_viterbi, int __pyx_v_use_logs, int __pyx_v_local, int __pyx_v_use_scaling); /* proto */
static char __pyx_k_1[] = "Array required, got None";
static char __pyx_k_3[] = "Unexpected array interface version %s";
static char __pyx_k_4[] = "'%s' type array required, got '%s'";
static char __pyx_k_5[] = "'%s%s' type array required, got '%s%s'";
static char __pyx_k_6[] = "%s dimensional array required, got %s";
static char __pyx_k_7[] = "Noncontiguous array";
static char __pyx_k_9[] = "Dimension %s is %s, expected %s";
static char __pyx_k_10[] = "";
static char __pyx_k_11[] = "%s * SCALE_STEP ** %s %s";
static char __pyx_k_12[] = "transition is a negative probability";
static char __pyx_k_13[] = "product is a negative probability";
static char __pyx_k_14[] = "is unexpectedly large";
static char __pyx_k_15[] = "('1', '5', '3')";
static char __pyx_k_19[] = "/Users/jrideout/.virtualenvs/pycogent/trunk/cogent/align/_pairwise_seqs.pyx";
static char __pyx_k_20[] = "cogent.align._pairwise_seqs";
static char __pyx_k_21[] = "overall_max_exponent";
static char __pyx_k_22[] = "overall_max_mantissa";
static char __pyx_k__N[] = "N";
static char __pyx_k__T[] = "T";
static char __pyx_k__a[] = "a";
static char __pyx_k__b[] = "b";
static char __pyx_k__i[] = "i";
static char __pyx_k__j[] = "j";
static char __pyx_k__x[] = "x";
static char __pyx_k__y[] = "y";
static char __pyx_k__d4[] = "d4";
static char __pyx_k__dx[] = "dx";
static char __pyx_k__dy[] = "dy";
static char __pyx_k__bin[] = "bin";
static char __pyx_k__chr[] = "chr";
static char __pyx_k__msg[] = "msg";
static char __pyx_k__fmpt[] = "fmpt";
static char __pyx_k__plan[] = "plan";
static char __pyx_k__rows[] = "rows";
static char __pyx_k__a_low[] = "a_low";
static char __pyx_k__b_low[] = "b_low";
static char __pyx_k__i_low[] = "i_low";
static char __pyx_k__index[] = "index";
static char __pyx_k__j_low[] = "j_low";
static char __pyx_k__local[] = "local";
static char __pyx_k__max_x[] = "max_x";
static char __pyx_k__max_y[] = "max_y";
static char __pyx_k__preds[] = "preds";
static char __pyx_k__score[] = "score";
static char __pyx_k__state[] = "state";
static char __pyx_k__track[] = "track";
static char __pyx_k__T_data[] = "T_data";
static char __pyx_k__a_high[] = "a_high";
static char __pyx_k__b_high[] = "b_high";
static char __pyx_k__i_high[] = "i_high";
static char __pyx_k__j_high[] = "j_high";
static char __pyx_k__last_i[] = "last_i";
static char __pyx_k__last_j[] = "last_j";
static char __pyx_k__prev_i[] = "prev_i";
static char __pyx_k__prev_j[] = "prev_j";
static char __pyx_k__a_count[] = "a_count";
static char __pyx_k__b_count[] = "b_count";
static char __pyx_k__d_score[] = "d_score";
static char __pyx_k__tcode_s[] = "tcode_s";
static char __pyx_k__tcode_x[] = "tcode_x";
static char __pyx_k__tcode_y[] = "tcode_y";
static char __pyx_k__viterbi[] = "viterbi";
static char __pyx_k__x_index[] = "x_index";
static char __pyx_k__y_index[] = "y_index";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__exponent[] = "exponent";
static char __pyx_k__mantissa[] = "mantissa";
static char __pyx_k__source_i[] = "source_i";
static char __pyx_k__use_logs[] = "use_logs";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k__bin_count[] = "bin_count";
static char __pyx_k__calc_rows[] = "calc_rows";
static char __pyx_k__exponents[] = "exponents";
static char __pyx_k__i_sources[] = "i_sources";
static char __pyx_k__j_sources[] = "j_sources";
static char __pyx_k__mantissas[] = "mantissas";
static char __pyx_k__plan_data[] = "plan_data";
static char __pyx_k__pointer_a[] = "pointer_a";
static char __pyx_k__pointer_b[] = "pointer_b";
static char __pyx_k__row_count[] = "row_count";
static char __pyx_k__track_enc[] = "track_enc";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__dest_state[] = "dest_state";
static char __pyx_k__impossible[] = "impossible";
static char __pyx_k__last_state[] = "last_state";
static char __pyx_k__plan_index[] = "plan_index";
static char __pyx_k__prev_state[] = "prev_state";
static char __pyx_k__row_length[] = "row_length";
static char __pyx_k__seq1_index[] = "seq1_index";
static char __pyx_k__seq2_index[] = "seq2_index";
static char __pyx_k__track_data[] = "track_data";
static char __pyx_k__underflows[] = "underflows";
static char __pyx_k____version__[] = "__version__";
static char __pyx_k__dest_states[] = "dest_states";
static char __pyx_k__partial_sum[] = "partial_sum";
static char __pyx_k__plan_index1[] = "plan_index1";
static char __pyx_k__plan_index2[] = "plan_index2";
static char __pyx_k__row_length1[] = "row_length1";
static char __pyx_k__use_scaling[] = "use_scaling";
static char __pyx_k__xgap_scores[] = "xgap_scores";
static char __pyx_k__ygap_scores[] = "ygap_scores";
static char __pyx_k__match_scores[] = "match_scores";
static char __pyx_k__max_exponent[] = "max_exponent";
static char __pyx_k__max_mantissa[] = "max_mantissa";
static char __pyx_k__version_info[] = "version_info";
static char __pyx_k__pointer_state[] = "pointer_state";
static char __pyx_k__prev_row_data[] = "prev_row_data";
static char __pyx_k__ArithmeticError[] = "ArithmeticError";
static char __pyx_k__source_row_data[] = "source_row_data";
static char __pyx_k__sub_partial_sum[] = "sub_partial_sum";
static char __pyx_k__xgap_score_data[] = "xgap_score_data";
static char __pyx_k__ygap_score_data[] = "ygap_score_data";
static char __pyx_k____array_struct__[] = "__array_struct__";
static char __pyx_k__current_row_data[] = "current_row_data";
static char __pyx_k__dest_states_data[] = "dest_states_data";
static char __pyx_k__match_score_data[] = "match_score_data";
static char __pyx_k__prev_row_ex_data[] = "prev_row_ex_data";
static char __pyx_k__state_directions[] = "state_directions";
static char __pyx_k__source_row_ex_data[] = "source_row_ex_data";
static char __pyx_k__current_row_ex_data[] = "current_row_ex_data";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_10;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_kp_s_13;
static PyObject *__pyx_kp_s_14;
static PyObject *__pyx_kp_s_15;
static PyObject *__pyx_kp_s_19;
static PyObject *__pyx_n_s_20;
static PyObject *__pyx_n_s_21;
static PyObject *__pyx_n_s_22;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__ArithmeticError;
static PyObject *__pyx_n_s__N;
static PyObject *__pyx_n_s__T;
static PyObject *__pyx_n_s__T_data;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____array_struct__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s____version__;
static PyObject *__pyx_n_s__a;
static PyObject *__pyx_n_s__a_count;
static PyObject *__pyx_n_s__a_high;
static PyObject *__pyx_n_s__a_low;
static PyObject *__pyx_n_s__b;
static PyObject *__pyx_n_s__b_count;
static PyObject *__pyx_n_s__b_high;
static PyObject *__pyx_n_s__b_low;
static PyObject *__pyx_n_s__bin;
static PyObject *__pyx_n_s__bin_count;
static PyObject *__pyx_n_s__calc_rows;
static PyObject *__pyx_n_s__chr;
static PyObject *__pyx_n_s__current_row_data;
static PyObject *__pyx_n_s__current_row_ex_data;
static PyObject *__pyx_n_s__d4;
static PyObject *__pyx_n_s__d_score;
static PyObject *__pyx_n_s__dest_state;
static PyObject *__pyx_n_s__dest_states;
static PyObject *__pyx_n_s__dest_states_data;
static PyObject *__pyx_n_s__dx;
static PyObject *__pyx_n_s__dy;
static PyObject *__pyx_n_s__exponent;
static PyObject *__pyx_n_s__exponents;
static PyObject *__pyx_n_s__fmpt;
static PyObject *__pyx_n_s__i;
static PyObject *__pyx_n_s__i_high;
static PyObject *__pyx_n_s__i_low;
static PyObject *__pyx_n_s__i_sources;
static PyObject *__pyx_n_s__impossible;
static PyObject *__pyx_n_s__index;
static PyObject *__pyx_n_s__j;
static PyObject *__pyx_n_s__j_high;
static PyObject *__pyx_n_s__j_low;
static PyObject *__pyx_n_s__j_sources;
static PyObject *__pyx_n_s__last_i;
static PyObject *__pyx_n_s__last_j;
static PyObject *__pyx_n_s__last_state;
static PyObject *__pyx_n_s__local;
static PyObject *__pyx_n_s__mantissa;
static PyObject *__pyx_n_s__mantissas;
static PyObject *__pyx_n_s__match_score_data;
static PyObject *__pyx_n_s__match_scores;
static PyObject *__pyx_n_s__max_exponent;
static PyObject *__pyx_n_s__max_mantissa;
static PyObject *__pyx_n_s__max_x;
static PyObject *__pyx_n_s__max_y;
static PyObject *__pyx_n_s__msg;
static PyObject *__pyx_n_s__partial_sum;
static PyObject *__pyx_n_s__plan;
static PyObject *__pyx_n_s__plan_data;
static PyObject *__pyx_n_s__plan_index;
static PyObject *__pyx_n_s__plan_index1;
static PyObject *__pyx_n_s__plan_index2;
static PyObject *__pyx_n_s__pointer_a;
static PyObject *__pyx_n_s__pointer_b;
static PyObject *__pyx_n_s__pointer_state;
static PyObject *__pyx_n_s__preds;
static PyObject *__pyx_n_s__prev_i;
static PyObject *__pyx_n_s__prev_j;
static PyObject *__pyx_n_s__prev_row_data;
static PyObject *__pyx_n_s__prev_row_ex_data;
static PyObject *__pyx_n_s__prev_state;
static PyObject *__pyx_n_s__row_count;
static PyObject *__pyx_n_s__row_length;
static PyObject *__pyx_n_s__row_length1;
static PyObject *__pyx_n_s__rows;
static PyObject *__pyx_n_s__score;
static PyObject *__pyx_n_s__seq1_index;
static PyObject *__pyx_n_s__seq2_index;
static PyObject *__pyx_n_s__source_i;
static PyObject *__pyx_n_s__source_row_data;
static PyObject *__pyx_n_s__source_row_ex_data;
static PyObject *__pyx_n_s__state;
static PyObject *__pyx_n_s__state_directions;
static PyObject *__pyx_n_s__sub_partial_sum;
static PyObject *__pyx_n_s__tcode_s;
static PyObject *__pyx_n_s__tcode_x;
static PyObject *__pyx_n_s__tcode_y;
static PyObject *__pyx_n_s__track;
static PyObject *__pyx_n_s__track_data;
static PyObject *__pyx_n_s__track_enc;
static PyObject *__pyx_n_s__underflows;
static PyObject *__pyx_n_s__use_logs;
static PyObject *__pyx_n_s__use_scaling;
static PyObject *__pyx_n_s__version_info;
static PyObject *__pyx_n_s__viterbi;
static PyObject *__pyx_n_s__x;
static PyObject *__pyx_n_s__x_index;
static PyObject *__pyx_n_s__xgap_score_data;
static PyObject *__pyx_n_s__xgap_scores;
static PyObject *__pyx_n_s__y;
static PyObject *__pyx_n_s__y_index;
static PyObject *__pyx_n_s__ygap_score_data;
static PyObject *__pyx_n_s__ygap_scores;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_3;
static PyObject *__pyx_k_tuple_2;
static PyObject *__pyx_k_tuple_8;
static PyObject *__pyx_k_tuple_16;
static PyObject *__pyx_k_tuple_17;
static PyObject *__pyx_k_tuple_23;
static PyObject *__pyx_k_codeobj_18;
static PyObject *__pyx_k_codeobj_24;

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":32
 * ctypedef object ArrayType
 * 
 * cdef double *uncheckedArrayDouble(ArrayType A):             # <<<<<<<<<<<<<<
 *     cdef PyArrayInterface *a
 *     cobj = A.__array_struct__
 */

static double *__pyx_f_6cogent_5align_14_pairwise_seqs_uncheckedArrayDouble(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_A) {
  struct PyArrayInterface *__pyx_v_a;
  PyObject *__pyx_v_cobj = NULL;
  double *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("uncheckedArrayDouble", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":34
 * cdef double *uncheckedArrayDouble(ArrayType A):
 *     cdef PyArrayInterface *a
 *     cobj = A.__array_struct__             # <<<<<<<<<<<<<<
 *     a = <PyArrayInterface *> PyCObject_AsVoidPtr(cobj)
 *     return <double *> a.data
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_A), __pyx_n_s____array_struct__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_cobj = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":35
 *     cdef PyArrayInterface *a
 *     cobj = A.__array_struct__
 *     a = <PyArrayInterface *> PyCObject_AsVoidPtr(cobj)             # <<<<<<<<<<<<<<
 *     return <double *> a.data
 * 
 */
  __pyx_v_a = ((struct PyArrayInterface *)PyCObject_AsVoidPtr(__pyx_v_cobj));

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":36
 *     cobj = A.__array_struct__
 *     a = <PyArrayInterface *> PyCObject_AsVoidPtr(cobj)
 *     return <double *> a.data             # <<<<<<<<<<<<<<
 * 
 * cdef void *checkArray(ArrayType A, char typecode, int itemsize,
 */
  __pyx_r = ((double *)__pyx_v_a->data);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_WriteUnraisable("cogent.align._pairwise_seqs.uncheckedArrayDouble", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_cobj);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":38
 *     return <double *> a.data
 * 
 * cdef void *checkArray(ArrayType A, char typecode, int itemsize,             # <<<<<<<<<<<<<<
 *         int nd, int **dims) except NULL:
 *     cdef PyArrayInterface *a
 */

static void *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArray(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_A, char __pyx_v_typecode, int __pyx_v_itemsize, int __pyx_v_nd, int **__pyx_v_dims) {
  struct PyArrayInterface *__pyx_v_a;
  PyObject *__pyx_v_cobj = NULL;
  char __pyx_v_typecode2;
  int __pyx_v_dimension;
  int __pyx_v_val;
  int *__pyx_v_var;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArray", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":43
 *     cdef int length, size
 *     cdef char kind
 *     if A is None:             # <<<<<<<<<<<<<<
 *         raise TypeError("Array required, got None")
 *     cobj = A.__array_struct__
 */
  __pyx_t_1 = (__pyx_v_A == ((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)Py_None));
  if (__pyx_t_1) {

    /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":44
 *     cdef char kind
 *     if A is None:
 *         raise TypeError("Array required, got None")             # <<<<<<<<<<<<<<
 *     cobj = A.__array_struct__
 *     a = <PyArrayInterface *> PyCObject_AsVoidPtr(cobj)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":45
 *     if A is None:
 *         raise TypeError("Array required, got None")
 *     cobj = A.__array_struct__             # <<<<<<<<<<<<<<
 *     a = <PyArrayInterface *> PyCObject_AsVoidPtr(cobj)
 *     if a.version != 2:
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_A), __pyx_n_s____array_struct__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_cobj = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":46
 *         raise TypeError("Array required, got None")
 *     cobj = A.__array_struct__
 *     a = <PyArrayInterface *> PyCObject_AsVoidPtr(cobj)             # <<<<<<<<<<<<<<
 *     if a.version != 2:
 *         raise ValueError(
 */
  __pyx_v_a = ((struct PyArrayInterface *)PyCObject_AsVoidPtr(__pyx_v_cobj));

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":47
 *     cobj = A.__array_struct__
 *     a = <PyArrayInterface *> PyCObject_AsVoidPtr(cobj)
 *     if a.version != 2:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             "Unexpected array interface version %s" % str(a.version))
 */
  __pyx_t_1 = (__pyx_v_a->version != 2);
  if (__pyx_t_1) {

    /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":49
 *     if a.version != 2:
 *         raise ValueError(
 *             "Unexpected array interface version %s" % str(a.version))             # <<<<<<<<<<<<<<
 *     cdef char typecode2
 *     typecode2 = a.typekind
 */
    __pyx_t_2 = PyInt_FromLong(__pyx_v_a->version); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":51
 *             "Unexpected array interface version %s" % str(a.version))
 *     cdef char typecode2
 *     typecode2 = a.typekind             # <<<<<<<<<<<<<<
 *     if typecode2 != typecode:
 *         raise TypeError("'%s' type array required, got '%s'" %
 */
  __pyx_v_typecode2 = __pyx_v_a->typekind;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":52
 *     cdef char typecode2
 *     typecode2 = a.typekind
 *     if typecode2 != typecode:             # <<<<<<<<<<<<<<
 *         raise TypeError("'%s' type array required, got '%s'" %
 *                 (chr(typecode), chr(typecode2)))
 */
  __pyx_t_1 = (__pyx_v_typecode2 != __pyx_v_typecode);
  if (__pyx_t_1) {

    /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":54
 *     if typecode2 != typecode:
 *         raise TypeError("'%s' type array required, got '%s'" %
 *                 (chr(typecode), chr(typecode2)))             # <<<<<<<<<<<<<<
 *     if a.itemsize != itemsize:
 *         raise TypeError("'%s%s' type array required, got '%s%s'" %
 */
    __pyx_t_3 = PyInt_FromLong(__pyx_v_typecode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_chr, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyInt_FromLong(__pyx_v_typecode2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_chr, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":55
 *         raise TypeError("'%s' type array required, got '%s'" %
 *                 (chr(typecode), chr(typecode2)))
 *     if a.itemsize != itemsize:             # <<<<<<<<<<<<<<
 *         raise TypeError("'%s%s' type array required, got '%s%s'" %
 *                 (chr(typecode), itemsize, chr(typecode2), a.itemsize))
 */
  __pyx_t_1 = (__pyx_v_a->itemsize != __pyx_v_itemsize);
  if (__pyx_t_1) {

    /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":57
 *     if a.itemsize != itemsize:
 *         raise TypeError("'%s%s' type array required, got '%s%s'" %
 *                 (chr(typecode), itemsize, chr(typecode2), a.itemsize))             # <<<<<<<<<<<<<<
 *     if a.nd != nd:
 *         raise ValueError("%s dimensional array required, got %s" %
 */
    __pyx_t_2 = PyInt_FromLong(__pyx_v_typecode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_chr, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyInt_FromLong(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyInt_FromLong(__pyx_v_typecode2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_chr, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_5 = PyInt_FromLong(__pyx_v_a->itemsize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __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 = 57; __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_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_3 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":58
 *         raise TypeError("'%s%s' type array required, got '%s%s'" %
 *                 (chr(typecode), itemsize, chr(typecode2), a.itemsize))
 *     if a.nd != nd:             # <<<<<<<<<<<<<<
 *         raise ValueError("%s dimensional array required, got %s" %
 *                 (nd, a.nd))
 */
  __pyx_t_1 = (__pyx_v_a->nd != __pyx_v_nd);
  if (__pyx_t_1) {

    /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":60
 *     if a.nd != nd:
 *         raise ValueError("%s dimensional array required, got %s" %
 *                 (nd, a.nd))             # <<<<<<<<<<<<<<
 *     if not a.flags & CONTIGUOUS:
 *         raise ValueError ('Noncontiguous array')
 */
    __pyx_t_5 = PyInt_FromLong(__pyx_v_nd); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyInt_FromLong(__pyx_v_a->nd); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); 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);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_6));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); 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);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":61
 *         raise ValueError("%s dimensional array required, got %s" %
 *                 (nd, a.nd))
 *     if not a.flags & CONTIGUOUS:             # <<<<<<<<<<<<<<
 *         raise ValueError ('Noncontiguous array')
 * 
 */
  __pyx_t_1 = (!(__pyx_v_a->flags & CONTIGUOUS));
  if (__pyx_t_1) {

    /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":62
 *                 (nd, a.nd))
 *     if not a.flags & CONTIGUOUS:
 *         raise ValueError ('Noncontiguous array')             # <<<<<<<<<<<<<<
 * 
 *     cdef int dimension, val
 */
    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":66
 *     cdef int dimension, val
 *     cdef int *var
 *     for dimension from 0 <= dimension < nd:             # <<<<<<<<<<<<<<
 *         val = a.shape[dimension]
 *         var = dims[dimension]
 */
  __pyx_t_7 = __pyx_v_nd;
  for (__pyx_v_dimension = 0; __pyx_v_dimension < __pyx_t_7; __pyx_v_dimension++) {

    /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":67
 *     cdef int *var
 *     for dimension from 0 <= dimension < nd:
 *         val = a.shape[dimension]             # <<<<<<<<<<<<<<
 *         var = dims[dimension]
 *         if var[0] == 0:
 */
    __pyx_v_val = (__pyx_v_a->shape[__pyx_v_dimension]);

    /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":68
 *     for dimension from 0 <= dimension < nd:
 *         val = a.shape[dimension]
 *         var = dims[dimension]             # <<<<<<<<<<<<<<
 *         if var[0] == 0:
 *             # Length unspecified, take it from the provided array
 */
    __pyx_v_var = (__pyx_v_dims[__pyx_v_dimension]);

    /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":69
 *         val = a.shape[dimension]
 *         var = dims[dimension]
 *         if var[0] == 0:             # <<<<<<<<<<<<<<
 *             # Length unspecified, take it from the provided array
 *             var[0] = val
 */
    __pyx_t_1 = ((__pyx_v_var[0]) == 0);
    if (__pyx_t_1) {

      /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":71
 *         if var[0] == 0:
 *             # Length unspecified, take it from the provided array
 *             var[0] = val             # <<<<<<<<<<<<<<
 *         elif var[0] != val:
 *             # Length already specified, but not the same
 */
      (__pyx_v_var[0]) = __pyx_v_val;
      goto __pyx_L11;
    }

    /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":72
 *             # Length unspecified, take it from the provided array
 *             var[0] = val
 *         elif var[0] != val:             # <<<<<<<<<<<<<<
 *             # Length already specified, but not the same
 *             raise ValueError("Dimension %s is %s, expected %s" %
 */
    __pyx_t_1 = ((__pyx_v_var[0]) != __pyx_v_val);
    if (__pyx_t_1) {

      /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":75
 *             # Length already specified, but not the same
 *             raise ValueError("Dimension %s is %s, expected %s" %
 *                     (dimension, val, var[0]))             # <<<<<<<<<<<<<<
 *         else:
 *             # Length matches what was expected
 */
      __pyx_t_6 = PyInt_FromLong(__pyx_v_dimension); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = PyInt_FromLong(__pyx_v_val); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyInt_FromLong((__pyx_v_var[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __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 = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      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_6 = 0;
      __pyx_t_3 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L11;
    }
    /*else*/ {
    }
    __pyx_L11:;
  }

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":79
 *             # Length matches what was expected
 *             pass
 *     return a.data             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_a->data;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_cobj);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":82
 * 
 * 
 * cdef void *checkArray1D(ArrayType a, char typecode, int size,             # <<<<<<<<<<<<<<
 *         int *x) except NULL:
 *     cdef int *dims[1]
 */

static void *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArray1D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, char __pyx_v_typecode, int __pyx_v_size, int *__pyx_v_x) {
  int *__pyx_v_dims[1];
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArray1D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":85
 *         int *x) except NULL:
 *     cdef int *dims[1]
 *     dims[0] = x             # <<<<<<<<<<<<<<
 *     return checkArray(a, typecode, size, 1, dims)
 * 
 */
  (__pyx_v_dims[0]) = __pyx_v_x;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":86
 *     cdef int *dims[1]
 *     dims[0] = x
 *     return checkArray(a, typecode, size, 1, dims)             # <<<<<<<<<<<<<<
 * 
 * cdef void *checkArray2D(ArrayType a, char typecode, int size,
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray(__pyx_v_a, __pyx_v_typecode, __pyx_v_size, 1, __pyx_v_dims); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArray1D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":88
 *     return checkArray(a, typecode, size, 1, dims)
 * 
 * cdef void *checkArray2D(ArrayType a, char typecode, int size,             # <<<<<<<<<<<<<<
 *         int *x, int *y) except NULL:
 *     cdef int *dims[2]
 */

static void *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArray2D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, char __pyx_v_typecode, int __pyx_v_size, int *__pyx_v_x, int *__pyx_v_y) {
  int *__pyx_v_dims[2];
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArray2D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":91
 *         int *x, int *y) except NULL:
 *     cdef int *dims[2]
 *     dims[0] = x             # <<<<<<<<<<<<<<
 *     dims[1] = y
 *     return checkArray(a, typecode, size, 2, dims)
 */
  (__pyx_v_dims[0]) = __pyx_v_x;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":92
 *     cdef int *dims[2]
 *     dims[0] = x
 *     dims[1] = y             # <<<<<<<<<<<<<<
 *     return checkArray(a, typecode, size, 2, dims)
 * 
 */
  (__pyx_v_dims[1]) = __pyx_v_y;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":93
 *     dims[0] = x
 *     dims[1] = y
 *     return checkArray(a, typecode, size, 2, dims)             # <<<<<<<<<<<<<<
 * 
 * cdef void *checkArray3D(ArrayType a, char typecode, int size,
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray(__pyx_v_a, __pyx_v_typecode, __pyx_v_size, 2, __pyx_v_dims); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArray2D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":95
 *     return checkArray(a, typecode, size, 2, dims)
 * 
 * cdef void *checkArray3D(ArrayType a, char typecode, int size,             # <<<<<<<<<<<<<<
 *         int *x, int *y, int *z) except NULL:
 *     cdef int *dims[3]
 */

static void *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArray3D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, char __pyx_v_typecode, int __pyx_v_size, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  int *__pyx_v_dims[3];
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArray3D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":98
 *         int *x, int *y, int *z) except NULL:
 *     cdef int *dims[3]
 *     dims[0] = x             # <<<<<<<<<<<<<<
 *     dims[1] = y
 *     dims[2] = z
 */
  (__pyx_v_dims[0]) = __pyx_v_x;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":99
 *     cdef int *dims[3]
 *     dims[0] = x
 *     dims[1] = y             # <<<<<<<<<<<<<<
 *     dims[2] = z
 *     return checkArray(a, typecode, size, 3, dims)
 */
  (__pyx_v_dims[1]) = __pyx_v_y;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":100
 *     dims[0] = x
 *     dims[1] = y
 *     dims[2] = z             # <<<<<<<<<<<<<<
 *     return checkArray(a, typecode, size, 3, dims)
 * 
 */
  (__pyx_v_dims[2]) = __pyx_v_z;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":101
 *     dims[1] = y
 *     dims[2] = z
 *     return checkArray(a, typecode, size, 3, dims)             # <<<<<<<<<<<<<<
 * 
 * cdef void *checkArray4D(ArrayType a, char typecode, int size,
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray(__pyx_v_a, __pyx_v_typecode, __pyx_v_size, 3, __pyx_v_dims); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArray3D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":103
 *     return checkArray(a, typecode, size, 3, dims)
 * 
 * cdef void *checkArray4D(ArrayType a, char typecode, int size,             # <<<<<<<<<<<<<<
 *         int *w, int *x, int *y, int *z) except NULL:
 *     cdef int *dims[4]
 */

static void *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArray4D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, char __pyx_v_typecode, int __pyx_v_size, int *__pyx_v_w, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  int *__pyx_v_dims[4];
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArray4D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":106
 *         int *w, int *x, int *y, int *z) except NULL:
 *     cdef int *dims[4]
 *     dims[0] = w             # <<<<<<<<<<<<<<
 *     dims[1] = x
 *     dims[2] = y
 */
  (__pyx_v_dims[0]) = __pyx_v_w;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":107
 *     cdef int *dims[4]
 *     dims[0] = w
 *     dims[1] = x             # <<<<<<<<<<<<<<
 *     dims[2] = y
 *     dims[3] = z
 */
  (__pyx_v_dims[1]) = __pyx_v_x;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":108
 *     dims[0] = w
 *     dims[1] = x
 *     dims[2] = y             # <<<<<<<<<<<<<<
 *     dims[3] = z
 *     return checkArray(a, typecode, size, 4, dims)
 */
  (__pyx_v_dims[2]) = __pyx_v_y;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":109
 *     dims[1] = x
 *     dims[2] = y
 *     dims[3] = z             # <<<<<<<<<<<<<<
 *     return checkArray(a, typecode, size, 4, dims)
 * 
 */
  (__pyx_v_dims[3]) = __pyx_v_z;

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":110
 *     dims[2] = y
 *     dims[3] = z
 *     return checkArray(a, typecode, size, 4, dims)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray(__pyx_v_a, __pyx_v_typecode, __pyx_v_size, 4, __pyx_v_dims); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArray4D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":113
 * 
 * 
 * cdef double * checkArrayDouble1D(ArrayType a, int *x) except NULL:             # <<<<<<<<<<<<<<
 *     return <double *> checkArray1D(a, c'f', sizeof(double), x)
 * 
 */

static double *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble1D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, int *__pyx_v_x) {
  double *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArrayDouble1D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":114
 * 
 * cdef double * checkArrayDouble1D(ArrayType a, int *x) except NULL:
 *     return <double *> checkArray1D(a, c'f', sizeof(double), x)             # <<<<<<<<<<<<<<
 * 
 * cdef double * checkArrayDouble2D(ArrayType a, int *x, int *y) except NULL:
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray1D(__pyx_v_a, 'f', (sizeof(double)), __pyx_v_x); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((double *)__pyx_t_1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArrayDouble1D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":116
 *     return <double *> checkArray1D(a, c'f', sizeof(double), x)
 * 
 * cdef double * checkArrayDouble2D(ArrayType a, int *x, int *y) except NULL:             # <<<<<<<<<<<<<<
 *     return <double *> checkArray2D(a, c'f', sizeof(double), x, y)
 * 
 */

static double *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble2D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, int *__pyx_v_x, int *__pyx_v_y) {
  double *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArrayDouble2D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":117
 * 
 * cdef double * checkArrayDouble2D(ArrayType a, int *x, int *y) except NULL:
 *     return <double *> checkArray2D(a, c'f', sizeof(double), x, y)             # <<<<<<<<<<<<<<
 * 
 * cdef double * checkArrayDouble3D(ArrayType a, int *x, int *y, int *z) except NULL:
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray2D(__pyx_v_a, 'f', (sizeof(double)), __pyx_v_x, __pyx_v_y); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((double *)__pyx_t_1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArrayDouble2D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":119
 *     return <double *> checkArray2D(a, c'f', sizeof(double), x, y)
 * 
 * cdef double * checkArrayDouble3D(ArrayType a, int *x, int *y, int *z) except NULL:             # <<<<<<<<<<<<<<
 *     return <double *> checkArray3D(a, c'f', sizeof(double), x, y, z)
 * 
 */

static double *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble3D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  double *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArrayDouble3D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":120
 * 
 * cdef double * checkArrayDouble3D(ArrayType a, int *x, int *y, int *z) except NULL:
 *     return <double *> checkArray3D(a, c'f', sizeof(double), x, y, z)             # <<<<<<<<<<<<<<
 * 
 * cdef double * checkArrayDouble4D(ArrayType a, int *w, int *x, int *y, int *z) except NULL:
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray3D(__pyx_v_a, 'f', (sizeof(double)), __pyx_v_x, __pyx_v_y, __pyx_v_z); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((double *)__pyx_t_1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArrayDouble3D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":122
 *     return <double *> checkArray3D(a, c'f', sizeof(double), x, y, z)
 * 
 * cdef double * checkArrayDouble4D(ArrayType a, int *w, int *x, int *y, int *z) except NULL:             # <<<<<<<<<<<<<<
 *     return <double *> checkArray4D(a, c'f', sizeof(double), w, x, y, z)
 * 
 */

static double *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble4D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, int *__pyx_v_w, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  double *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArrayDouble4D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":123
 * 
 * cdef double * checkArrayDouble4D(ArrayType a, int *w, int *x, int *y, int *z) except NULL:
 *     return <double *> checkArray4D(a, c'f', sizeof(double), w, x, y, z)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray4D(__pyx_v_a, 'f', (sizeof(double)), __pyx_v_w, __pyx_v_x, __pyx_v_y, __pyx_v_z); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((double *)__pyx_t_1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArrayDouble4D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":126
 * 
 * 
 * cdef long * checkArrayLong1D(ArrayType a, int *x) except NULL:             # <<<<<<<<<<<<<<
 *     return <long *> checkArray1D(a, c'i', sizeof(long), x)
 * 
 */

static long *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong1D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, int *__pyx_v_x) {
  long *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArrayLong1D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":127
 * 
 * cdef long * checkArrayLong1D(ArrayType a, int *x) except NULL:
 *     return <long *> checkArray1D(a, c'i', sizeof(long), x)             # <<<<<<<<<<<<<<
 * 
 * cdef long * checkArrayLong2D(ArrayType a, int *x, int *y) except NULL:
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray1D(__pyx_v_a, 'i', (sizeof(long)), __pyx_v_x); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((long *)__pyx_t_1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArrayLong1D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":129
 *     return <long *> checkArray1D(a, c'i', sizeof(long), x)
 * 
 * cdef long * checkArrayLong2D(ArrayType a, int *x, int *y) except NULL:             # <<<<<<<<<<<<<<
 *     return <long *> checkArray2D(a, c'i', sizeof(long), x, y)
 * 
 */

static long *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong2D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, int *__pyx_v_x, int *__pyx_v_y) {
  long *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArrayLong2D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":130
 * 
 * cdef long * checkArrayLong2D(ArrayType a, int *x, int *y) except NULL:
 *     return <long *> checkArray2D(a, c'i', sizeof(long), x, y)             # <<<<<<<<<<<<<<
 * 
 * cdef long * checkArrayLong3D(ArrayType a, int *x, int *y, int *z) except NULL:
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray2D(__pyx_v_a, 'i', (sizeof(long)), __pyx_v_x, __pyx_v_y); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((long *)__pyx_t_1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArrayLong2D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":132
 *     return <long *> checkArray2D(a, c'i', sizeof(long), x, y)
 * 
 * cdef long * checkArrayLong3D(ArrayType a, int *x, int *y, int *z) except NULL:             # <<<<<<<<<<<<<<
 *     return <long *> checkArray3D(a, c'i', sizeof(long), x, y, z)
 * 
 */

static long *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong3D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  long *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArrayLong3D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":133
 * 
 * cdef long * checkArrayLong3D(ArrayType a, int *x, int *y, int *z) except NULL:
 *     return <long *> checkArray3D(a, c'i', sizeof(long), x, y, z)             # <<<<<<<<<<<<<<
 * 
 * cdef long * checkArrayLong4D(ArrayType a, int *w, int *x, int *y, int *z) except NULL:
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray3D(__pyx_v_a, 'i', (sizeof(long)), __pyx_v_x, __pyx_v_y, __pyx_v_z); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((long *)__pyx_t_1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArrayLong3D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":135
 *     return <long *> checkArray3D(a, c'i', sizeof(long), x, y, z)
 * 
 * cdef long * checkArrayLong4D(ArrayType a, int *w, int *x, int *y, int *z) except NULL:             # <<<<<<<<<<<<<<
 *     return <long *> checkArray4D(a, c'i', sizeof(long), w, x, y, z)
 */

static long *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong4D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, int *__pyx_v_w, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  long *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArrayLong4D", 0);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":136
 * 
 * cdef long * checkArrayLong4D(ArrayType a, int *w, int *x, int *y, int *z) except NULL:
 *     return <long *> checkArray4D(a, c'i', sizeof(long), w, x, y, z)             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray4D(__pyx_v_a, 'i', (sizeof(long)), __pyx_v_w, __pyx_v_x, __pyx_v_y, __pyx_v_z); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((long *)__pyx_t_1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArrayLong4D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cogent/align/_pairwise_seqs.pyx":33
 * #    return <unsigned int *> checkArray3D(a, c'i', sizeof(int), x, y, z)
 * 
 * cdef unsigned char * checkArrayUChar3D(ArrayType a, int *x, int *y, int *z) except NULL:             # <<<<<<<<<<<<<<
 *     return <unsigned char *> checkArray3D(a, c'i', sizeof(char), x, y, z)
 * 
 */

static unsigned char *__pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayUChar3D(__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_a, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  unsigned char *__pyx_r;
  __Pyx_RefNannyDeclarations
  void *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checkArrayUChar3D", 0);

  /* "cogent/align/_pairwise_seqs.pyx":34
 * 
 * cdef unsigned char * checkArrayUChar3D(ArrayType a, int *x, int *y, int *z) except NULL:
 *     return <unsigned char *> checkArray3D(a, c'i', sizeof(char), x, y, z)             # <<<<<<<<<<<<<<
 * 
 * def fmpt(mantissa, exponent, msg=''):
 */
  __pyx_t_1 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArray3D(__pyx_v_a, 'i', (sizeof(char)), __pyx_v_x, __pyx_v_y, __pyx_v_z); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((unsigned char *)__pyx_t_1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.checkArrayUChar3D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6cogent_5align_14_pairwise_seqs_1fmpt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6cogent_5align_14_pairwise_seqs_1fmpt = {__Pyx_NAMESTR("fmpt"), (PyCFunction)__pyx_pw_6cogent_5align_14_pairwise_seqs_1fmpt, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_6cogent_5align_14_pairwise_seqs_1fmpt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mantissa = 0;
  PyObject *__pyx_v_exponent = 0;
  PyObject *__pyx_v_msg = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__mantissa,&__pyx_n_s__exponent,&__pyx_n_s__msg,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fmpt (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_kp_s_10);
    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:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mantissa);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exponent);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fmpt", 0, 2, 3, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__msg);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fmpt") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_mantissa = values[0];
    __pyx_v_exponent = values[1];
    __pyx_v_msg = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fmpt", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.fmpt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cogent_5align_14_pairwise_seqs_fmpt(__pyx_self, __pyx_v_mantissa, __pyx_v_exponent, __pyx_v_msg);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cogent/align/_pairwise_seqs.pyx":36
 *     return <unsigned char *> checkArray3D(a, c'i', sizeof(char), x, y, z)
 * 
 * def fmpt(mantissa, exponent, msg=''):             # <<<<<<<<<<<<<<
 *     return "%s * SCALE_STEP ** %s %s" % (mantissa, exponent, msg)
 * 
 */

static PyObject *__pyx_pf_6cogent_5align_14_pairwise_seqs_fmpt(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mantissa, PyObject *__pyx_v_exponent, PyObject *__pyx_v_msg) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fmpt", 0);

  /* "cogent/align/_pairwise_seqs.pyx":37
 * 
 * def fmpt(mantissa, exponent, msg=''):
 *     return "%s * SCALE_STEP ** %s %s" % (mantissa, exponent, msg)             # <<<<<<<<<<<<<<
 * 
 * def calc_rows(ArrayType plan, ArrayType seq1_index, ArrayType seq2_index,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_mantissa);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_mantissa);
  __Pyx_GIVEREF(__pyx_v_mantissa);
  __Pyx_INCREF(__pyx_v_exponent);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_exponent);
  __Pyx_GIVEREF(__pyx_v_exponent);
  __Pyx_INCREF(__pyx_v_msg);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_msg);
  __Pyx_GIVEREF(__pyx_v_msg);
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 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_AddTraceback("cogent.align._pairwise_seqs.fmpt", __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_6cogent_5align_14_pairwise_seqs_3calc_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cogent_5align_14_pairwise_seqs_2calc_rows[] = "The faster, sequence only (no POG) version.  Forward or Viterbi \n    algorithm, with doubles or with slower but practically unoverflowable \n    (double, long) GMP-like numbers.  Viterbi is also available in the ever \n    popular addition-of-logs version.  All this with any possible pair HMM \n    transition matrix.\n        \n    Limitations\n       - HMM states must be in a sensible order: M and X, then Y, then END.\n    ";
static PyMethodDef __pyx_mdef_6cogent_5align_14_pairwise_seqs_3calc_rows = {__Pyx_NAMESTR("calc_rows"), (PyCFunction)__pyx_pw_6cogent_5align_14_pairwise_seqs_3calc_rows, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6cogent_5align_14_pairwise_seqs_2calc_rows)};
static PyObject *__pyx_pw_6cogent_5align_14_pairwise_seqs_3calc_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_plan = 0;
  __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_seq1_index = 0;
  __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_seq2_index = 0;
  int __pyx_v_i_low;
  int __pyx_v_i_high;
  int __pyx_v_j_low;
  int __pyx_v_j_high;
  CYTHON_UNUSED PyObject *__pyx_v_preds = 0;
  __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_state_directions = 0;
  __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_T = 0;
  __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_xgap_scores = 0;
  __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_ygap_scores = 0;
  __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_match_scores = 0;
  PyObject *__pyx_v_rows = 0;
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_track_enc = 0;
  int __pyx_v_viterbi;
  int __pyx_v_use_logs;
  int __pyx_v_local;
  int __pyx_v_use_scaling;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__plan,&__pyx_n_s__seq1_index,&__pyx_n_s__seq2_index,&__pyx_n_s__i_low,&__pyx_n_s__i_high,&__pyx_n_s__j_low,&__pyx_n_s__j_high,&__pyx_n_s__preds,&__pyx_n_s__state_directions,&__pyx_n_s__T,&__pyx_n_s__xgap_scores,&__pyx_n_s__ygap_scores,&__pyx_n_s__match_scores,&__pyx_n_s__rows,&__pyx_n_s__track,&__pyx_n_s__track_enc,&__pyx_n_s__viterbi,&__pyx_n_s__use_logs,&__pyx_n_s__local,&__pyx_n_s__use_scaling,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("calc_rows (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[20] = {0,0,0,0,0,0,0,0,0,0,0,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 20: values[19] = PyTuple_GET_ITEM(__pyx_args, 19);
        case 19: values[18] = PyTuple_GET_ITEM(__pyx_args, 18);
        case 18: values[17] = PyTuple_GET_ITEM(__pyx_args, 17);
        case 17: values[16] = PyTuple_GET_ITEM(__pyx_args, 16);
        case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15);
        case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14);
        case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13);
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__plan);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seq1_index);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seq2_index);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_low);
        if (likely(values[3])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 3); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_high);
        if (likely(values[4])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 4); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  5:
        values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__j_low);
        if (likely(values[5])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 5); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  6:
        values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__j_high);
        if (likely(values[6])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 6); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  7:
        values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__preds);
        if (likely(values[7])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 7); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  8:
        values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__state_directions);
        if (likely(values[8])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 8); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  9:
        values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__T);
        if (likely(values[9])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 9); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case 10:
        values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__xgap_scores);
        if (likely(values[10])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 10); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case 11:
        values[11] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ygap_scores);
        if (likely(values[11])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 11); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case 12:
        values[12] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__match_scores);
        if (likely(values[12])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 12); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case 13:
        values[13] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__rows);
        if (likely(values[13])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 13); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case 14:
        values[14] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track);
        if (likely(values[14])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 14); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case 15:
        values[15] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track_enc);
        if (likely(values[15])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 15); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case 16:
        values[16] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__viterbi);
        if (likely(values[16])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, 16); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case 17:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_logs);
          if (value) { values[17] = value; kw_args--; }
        }
        case 18:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__local);
          if (value) { values[18] = value; kw_args--; }
        }
        case 19:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_scaling);
          if (value) { values[19] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "calc_rows") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[17]) {
      } else {
        __pyx_v_use_logs = ((int)0);
      }
      if (values[18]) {
      } else {

        /* "cogent/align/_pairwise_seqs.pyx":43
 *         ArrayType state_directions, ArrayType T,
 *         ArrayType xgap_scores, ArrayType ygap_scores, ArrayType match_scores,
 *         rows, track, track_enc, int viterbi, int use_logs=0, int local=False,             # <<<<<<<<<<<<<<
 *         int use_scaling=True):
 * 
 */
        __pyx_v_local = ((int)0);
      }
      if (values[19]) {
      } else {

        /* "cogent/align/_pairwise_seqs.pyx":44
 *         ArrayType xgap_scores, ArrayType ygap_scores, ArrayType match_scores,
 *         rows, track, track_enc, int viterbi, int use_logs=0, int local=False,
 *         int use_scaling=True):             # <<<<<<<<<<<<<<
 * 
 *     """The faster, sequence only (no POG) version.  Forward or Viterbi
 */
        __pyx_v_use_scaling = ((int)1);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 20: values[19] = PyTuple_GET_ITEM(__pyx_args, 19);
        case 19: values[18] = PyTuple_GET_ITEM(__pyx_args, 18);
        case 18: values[17] = PyTuple_GET_ITEM(__pyx_args, 17);
        case 17: values[16] = PyTuple_GET_ITEM(__pyx_args, 16);
        values[15] = PyTuple_GET_ITEM(__pyx_args, 15);
        values[14] = PyTuple_GET_ITEM(__pyx_args, 14);
        values[13] = PyTuple_GET_ITEM(__pyx_args, 13);
        values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_plan = ((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)values[0]);
    __pyx_v_seq1_index = ((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)values[1]);
    __pyx_v_seq2_index = ((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)values[2]);
    __pyx_v_i_low = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_i_low == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_i_high = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_i_high == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_j_low = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_j_low == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_j_high = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_j_high == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_preds = values[7];
    __pyx_v_state_directions = ((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)values[8]);
    __pyx_v_T = ((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)values[9]);
    __pyx_v_xgap_scores = ((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)values[10]);
    __pyx_v_ygap_scores = ((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)values[11]);
    __pyx_v_match_scores = ((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)values[12]);
    __pyx_v_rows = values[13];
    __pyx_v_track = values[14];
    __pyx_v_track_enc = values[15];
    __pyx_v_viterbi = __Pyx_PyInt_AsInt(values[16]); if (unlikely((__pyx_v_viterbi == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[17]) {
      __pyx_v_use_logs = __Pyx_PyInt_AsInt(values[17]); if (unlikely((__pyx_v_use_logs == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_use_logs = ((int)0);
    }
    if (values[18]) {
      __pyx_v_local = __Pyx_PyInt_AsInt(values[18]); if (unlikely((__pyx_v_local == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "cogent/align/_pairwise_seqs.pyx":43
 *         ArrayType state_directions, ArrayType T,
 *         ArrayType xgap_scores, ArrayType ygap_scores, ArrayType match_scores,
 *         rows, track, track_enc, int viterbi, int use_logs=0, int local=False,             # <<<<<<<<<<<<<<
 *         int use_scaling=True):
 * 
 */
      __pyx_v_local = ((int)0);
    }
    if (values[19]) {
      __pyx_v_use_scaling = __Pyx_PyInt_AsInt(values[19]); if (unlikely((__pyx_v_use_scaling == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "cogent/align/_pairwise_seqs.pyx":44
 *         ArrayType xgap_scores, ArrayType ygap_scores, ArrayType match_scores,
 *         rows, track, track_enc, int viterbi, int use_logs=0, int local=False,
 *         int use_scaling=True):             # <<<<<<<<<<<<<<
 * 
 *     """The faster, sequence only (no POG) version.  Forward or Viterbi
 */
      __pyx_v_use_scaling = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("calc_rows", 0, 17, 20, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.calc_rows", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cogent_5align_14_pairwise_seqs_2calc_rows(__pyx_self, __pyx_v_plan, __pyx_v_seq1_index, __pyx_v_seq2_index, __pyx_v_i_low, __pyx_v_i_high, __pyx_v_j_low, __pyx_v_j_high, __pyx_v_preds, __pyx_v_state_directions, __pyx_v_T, __pyx_v_xgap_scores, __pyx_v_ygap_scores, __pyx_v_match_scores, __pyx_v_rows, __pyx_v_track, __pyx_v_track_enc, __pyx_v_viterbi, __pyx_v_use_logs, __pyx_v_local, __pyx_v_use_scaling);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cogent/align/_pairwise_seqs.pyx":39
 *     return "%s * SCALE_STEP ** %s %s" % (mantissa, exponent, msg)
 * 
 * def calc_rows(ArrayType plan, ArrayType seq1_index, ArrayType seq2_index,             # <<<<<<<<<<<<<<
 *         int i_low, int i_high, int j_low, int j_high, preds,
 *         ArrayType state_directions, ArrayType T,
 */

static PyObject *__pyx_pf_6cogent_5align_14_pairwise_seqs_2calc_rows(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_plan, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_seq1_index, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_seq2_index, int __pyx_v_i_low, int __pyx_v_i_high, int __pyx_v_j_low, int __pyx_v_j_high, CYTHON_UNUSED PyObject *__pyx_v_preds, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_state_directions, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_T, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_xgap_scores, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_ygap_scores, __pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType __pyx_v_match_scores, PyObject *__pyx_v_rows, PyObject *__pyx_v_track, PyObject *__pyx_v_track_enc, int __pyx_v_viterbi, int __pyx_v_use_logs, int __pyx_v_local, int __pyx_v_use_scaling) {
  int __pyx_v_dx;
  int __pyx_v_dy;
  int __pyx_v_prev_j;
  int __pyx_v_state;
  int __pyx_v_prev_state;
  int __pyx_v_N;
  int __pyx_v_row_length;
  int __pyx_v_a;
  int __pyx_v_b;
  int __pyx_v_dest_states;
  int __pyx_v_dest_state;
  int __pyx_v_d4;
  int __pyx_v_j;
  int __pyx_v_i;
  int __pyx_v_source_i;
  int __pyx_v_last_i;
  int __pyx_v_last_j;
  int __pyx_v_last_state;
  int __pyx_v_overall_max_exponent;
  int __pyx_v_tcode_x;
  int __pyx_v_tcode_y;
  int __pyx_v_tcode_s;
  unsigned char *__pyx_v_track_data;
  double __pyx_v_overall_max_mantissa;
  double __pyx_v_d_score;
  double __pyx_v_mantissa;
  double __pyx_v_partial_sum;
  double __pyx_v_sub_partial_sum;
  double __pyx_v_max_mantissa;
  long __pyx_v_exponent;
  long __pyx_v_index;
  long __pyx_v_max_exponent;
  long *__pyx_v_source_row_ex_data;
  double *__pyx_v_T_data;
  double *__pyx_v_source_row_data;
  double *__pyx_v_match_score_data;
  long *__pyx_v_dest_states_data;
  long *__pyx_v_plan_data;
  double *__pyx_v_current_row_data;
  double *__pyx_v_prev_row_data;
  long *__pyx_v_current_row_ex_data;
  long *__pyx_v_prev_row_ex_data;
  long __pyx_v_pointer_a;
  long __pyx_v_pointer_b;
  long __pyx_v_pointer_state;
  long *__pyx_v_x_index;
  long *__pyx_v_y_index;
  int __pyx_v_x;
  int __pyx_v_y;
  int __pyx_v_max_x;
  int __pyx_v_max_y;
  int __pyx_v_row_count;
  int __pyx_v_plan_index2;
  PyObject *__pyx_v_mantissas = NULL;
  PyObject *__pyx_v_exponents = NULL;
  int __pyx_v_bin_count;
  int __pyx_v_bin;
  double *__pyx_v_xgap_score_data;
  double *__pyx_v_ygap_score_data;
  double __pyx_v_impossible;
  long __pyx_v_plan_index1;
  double __pyx_v_score;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  int __pyx_t_5;
  int __pyx_t_6;
  double *__pyx_t_7;
  long *__pyx_t_8;
  long *__pyx_t_9;
  double *__pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  unsigned char *__pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  double __pyx_t_18;
  int __pyx_t_19;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("calc_rows", 0);

  /* "cogent/align/_pairwise_seqs.pyx":77
 *     cdef int row_count, row_length1, plan_index, plan_index2
 * 
 *     (mantissas, exponents) = rows             # <<<<<<<<<<<<<<
 * 
 *     assert not (use_logs and not viterbi)
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_rows))) || (PyList_CheckExact(__pyx_v_rows))) {
    PyObject* sequence = __pyx_v_rows;
    if (likely(PyTuple_CheckExact(sequence))) {
      if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
        if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
        else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
        if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
        else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_rows); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
    if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_mantissas = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_exponents = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cogent/align/_pairwise_seqs.pyx":79
 *     (mantissas, exponents) = rows
 * 
 *     assert not (use_logs and not viterbi)             # <<<<<<<<<<<<<<
 *     assert not (use_logs and use_scaling)
 *     assert not (local and not viterbi)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (__pyx_v_use_logs) {
    __pyx_t_5 = (!__pyx_v_viterbi);
    __pyx_t_6 = __pyx_t_5;
  } else {
    __pyx_t_6 = __pyx_v_use_logs;
  }
  if (unlikely(!(!__pyx_t_6))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "cogent/align/_pairwise_seqs.pyx":80
 * 
 *     assert not (use_logs and not viterbi)
 *     assert not (use_logs and use_scaling)             # <<<<<<<<<<<<<<
 *     assert not (local and not viterbi)
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (__pyx_v_use_logs) {
    __pyx_t_6 = __pyx_v_use_scaling;
  } else {
    __pyx_t_6 = __pyx_v_use_logs;
  }
  if (unlikely(!(!__pyx_t_6))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "cogent/align/_pairwise_seqs.pyx":81
 *     assert not (use_logs and not viterbi)
 *     assert not (use_logs and use_scaling)
 *     assert not (local and not viterbi)             # <<<<<<<<<<<<<<
 * 
 *     N = 0
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (__pyx_v_local) {
    __pyx_t_6 = (!__pyx_v_viterbi);
    __pyx_t_5 = __pyx_t_6;
  } else {
    __pyx_t_5 = __pyx_v_local;
  }
  if (unlikely(!(!__pyx_t_5))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "cogent/align/_pairwise_seqs.pyx":83
 *     assert not (local and not viterbi)
 * 
 *     N = 0             # <<<<<<<<<<<<<<
 *     T_data = checkArrayDouble2D(T, &N, &N)
 *     row_length = 0
 */
  __pyx_v_N = 0;

  /* "cogent/align/_pairwise_seqs.pyx":84
 * 
 *     N = 0
 *     T_data = checkArrayDouble2D(T, &N, &N)             # <<<<<<<<<<<<<<
 *     row_length = 0
 *     row_count = 0
 */
  __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble2D(__pyx_v_T, (&__pyx_v_N), (&__pyx_v_N)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_T_data = __pyx_t_7;

  /* "cogent/align/_pairwise_seqs.pyx":85
 *     N = 0
 *     T_data = checkArrayDouble2D(T, &N, &N)
 *     row_length = 0             # <<<<<<<<<<<<<<
 *     row_count = 0
 *     plan_data = checkArrayLong1D(plan, &row_count)
 */
  __pyx_v_row_length = 0;

  /* "cogent/align/_pairwise_seqs.pyx":86
 *     T_data = checkArrayDouble2D(T, &N, &N)
 *     row_length = 0
 *     row_count = 0             # <<<<<<<<<<<<<<
 *     plan_data = checkArrayLong1D(plan, &row_count)
 * 
 */
  __pyx_v_row_count = 0;

  /* "cogent/align/_pairwise_seqs.pyx":87
 *     row_length = 0
 *     row_count = 0
 *     plan_data = checkArrayLong1D(plan, &row_count)             # <<<<<<<<<<<<<<
 * 
 *     dest_states = 0
 */
  __pyx_t_8 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong1D(__pyx_v_plan, (&__pyx_v_row_count)); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_plan_data = __pyx_t_8;

  /* "cogent/align/_pairwise_seqs.pyx":89
 *     plan_data = checkArrayLong1D(plan, &row_count)
 * 
 *     dest_states = 0             # <<<<<<<<<<<<<<
 *     d4 = 4
 *     # Array of (state, bin, dx, dy) tuples describing the HMM states.
 */
  __pyx_v_dest_states = 0;

  /* "cogent/align/_pairwise_seqs.pyx":90
 * 
 *     dest_states = 0
 *     d4 = 4             # <<<<<<<<<<<<<<
 *     # Array of (state, bin, dx, dy) tuples describing the HMM states.
 *     dest_states_data = checkArrayLong2D(state_directions, &dest_states, &d4)
 */
  __pyx_v_d4 = 4;

  /* "cogent/align/_pairwise_seqs.pyx":92
 *     d4 = 4
 *     # Array of (state, bin, dx, dy) tuples describing the HMM states.
 *     dest_states_data = checkArrayLong2D(state_directions, &dest_states, &d4)             # <<<<<<<<<<<<<<
 * 
 *     cdef int bin_count, bin
 */
  __pyx_t_9 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong2D(__pyx_v_state_directions, (&__pyx_v_dest_states), (&__pyx_v_d4)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_dest_states_data = __pyx_t_9;

  /* "cogent/align/_pairwise_seqs.pyx":97
 *     cdef double *xgap_score_data, *ygap_score_data
 * 
 *     x_index = checkArrayLong1D(seq1_index, &row_count)             # <<<<<<<<<<<<<<
 *     y_index = checkArrayLong1D(seq2_index, &row_length)
 * 
 */
  __pyx_t_8 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong1D(__pyx_v_seq1_index, (&__pyx_v_row_count)); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_x_index = __pyx_t_8;

  /* "cogent/align/_pairwise_seqs.pyx":98
 * 
 *     x_index = checkArrayLong1D(seq1_index, &row_count)
 *     y_index = checkArrayLong1D(seq2_index, &row_length)             # <<<<<<<<<<<<<<
 * 
 *     max_x = max_y = bin_count = 0
 */
  __pyx_t_8 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong1D(__pyx_v_seq2_index, (&__pyx_v_row_length)); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_y_index = __pyx_t_8;

  /* "cogent/align/_pairwise_seqs.pyx":100
 *     y_index = checkArrayLong1D(seq2_index, &row_length)
 * 
 *     max_x = max_y = bin_count = 0             # <<<<<<<<<<<<<<
 *     match_score_data = checkArrayDouble3D(
 *             match_scores, &bin_count, &max_x, &max_y)
 */
  __pyx_v_max_x = 0;
  __pyx_v_max_y = 0;
  __pyx_v_bin_count = 0;

  /* "cogent/align/_pairwise_seqs.pyx":102
 *     max_x = max_y = bin_count = 0
 *     match_score_data = checkArrayDouble3D(
 *             match_scores, &bin_count, &max_x, &max_y)             # <<<<<<<<<<<<<<
 *     xgap_score_data = checkArrayDouble2D(xgap_scores, &bin_count, &max_x)
 *     ygap_score_data = checkArrayDouble2D(ygap_scores, &bin_count, &max_y)
 */
  __pyx_t_10 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble3D(__pyx_v_match_scores, (&__pyx_v_bin_count), (&__pyx_v_max_x), (&__pyx_v_max_y)); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_match_score_data = __pyx_t_10;

  /* "cogent/align/_pairwise_seqs.pyx":103
 *     match_score_data = checkArrayDouble3D(
 *             match_scores, &bin_count, &max_x, &max_y)
 *     xgap_score_data = checkArrayDouble2D(xgap_scores, &bin_count, &max_x)             # <<<<<<<<<<<<<<
 *     ygap_score_data = checkArrayDouble2D(ygap_scores, &bin_count, &max_y)
 * 
 */
  __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble2D(__pyx_v_xgap_scores, (&__pyx_v_bin_count), (&__pyx_v_max_x)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_xgap_score_data = __pyx_t_7;

  /* "cogent/align/_pairwise_seqs.pyx":104
 *             match_scores, &bin_count, &max_x, &max_y)
 *     xgap_score_data = checkArrayDouble2D(xgap_scores, &bin_count, &max_x)
 *     ygap_score_data = checkArrayDouble2D(ygap_scores, &bin_count, &max_y)             # <<<<<<<<<<<<<<
 * 
 *     for i from 0 <= i < row_count:
 */
  __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble2D(__pyx_v_ygap_scores, (&__pyx_v_bin_count), (&__pyx_v_max_y)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_ygap_score_data = __pyx_t_7;

  /* "cogent/align/_pairwise_seqs.pyx":106
 *     ygap_score_data = checkArrayDouble2D(ygap_scores, &bin_count, &max_y)
 * 
 *     for i from 0 <= i < row_count:             # <<<<<<<<<<<<<<
 *         assert 0 <= x_index[i] < max_x
 *     for j from 0 <= j < row_length:
 */
  __pyx_t_11 = __pyx_v_row_count;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_11; __pyx_v_i++) {

    /* "cogent/align/_pairwise_seqs.pyx":107
 * 
 *     for i from 0 <= i < row_count:
 *         assert 0 <= x_index[i] < max_x             # <<<<<<<<<<<<<<
 *     for j from 0 <= j < row_length:
 *         assert 0 <= y_index[j] < max_y
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    __pyx_t_5 = (0 <= (__pyx_v_x_index[__pyx_v_i]));
    if (__pyx_t_5) {
      __pyx_t_5 = ((__pyx_v_x_index[__pyx_v_i]) < __pyx_v_max_x);
    }
    if (unlikely(!__pyx_t_5)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif
  }

  /* "cogent/align/_pairwise_seqs.pyx":108
 *     for i from 0 <= i < row_count:
 *         assert 0 <= x_index[i] < max_x
 *     for j from 0 <= j < row_length:             # <<<<<<<<<<<<<<
 *         assert 0 <= y_index[j] < max_y
 * 
 */
  __pyx_t_11 = __pyx_v_row_length;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_11; __pyx_v_j++) {

    /* "cogent/align/_pairwise_seqs.pyx":109
 *         assert 0 <= x_index[i] < max_x
 *     for j from 0 <= j < row_length:
 *         assert 0 <= y_index[j] < max_y             # <<<<<<<<<<<<<<
 * 
 *     assert j_low >= 0 and j_high > j_low and j_high <= row_length
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    __pyx_t_5 = (0 <= (__pyx_v_y_index[__pyx_v_j]));
    if (__pyx_t_5) {
      __pyx_t_5 = ((__pyx_v_y_index[__pyx_v_j]) < __pyx_v_max_y);
    }
    if (unlikely(!__pyx_t_5)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif
  }

  /* "cogent/align/_pairwise_seqs.pyx":111
 *         assert 0 <= y_index[j] < max_y
 * 
 *     assert j_low >= 0 and j_high > j_low and j_high <= row_length             # <<<<<<<<<<<<<<
 * 
 *     cdef double impossible
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_5 = (__pyx_v_j_low >= 0);
  if (__pyx_t_5) {
    __pyx_t_6 = (__pyx_v_j_high > __pyx_v_j_low);
    if (__pyx_t_6) {
      __pyx_t_12 = (__pyx_v_j_high <= __pyx_v_row_length);
      __pyx_t_13 = __pyx_t_12;
    } else {
      __pyx_t_13 = __pyx_t_6;
    }
    __pyx_t_6 = __pyx_t_13;
  } else {
    __pyx_t_6 = __pyx_t_5;
  }
  if (unlikely(!__pyx_t_6)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "cogent/align/_pairwise_seqs.pyx":114
 * 
 *     cdef double impossible
 *     if use_logs:             # <<<<<<<<<<<<<<
 *         impossible = log(0.0) # -inf
 *     else:
 */
  if (__pyx_v_use_logs) {

    /* "cogent/align/_pairwise_seqs.pyx":115
 *     cdef double impossible
 *     if use_logs:
 *         impossible = log(0.0) # -inf             # <<<<<<<<<<<<<<
 *     else:
 *         impossible = 0.0
 */
    __pyx_v_impossible = log(0.0);
    goto __pyx_L9;
  }
  /*else*/ {

    /* "cogent/align/_pairwise_seqs.pyx":117
 *         impossible = log(0.0) # -inf
 *     else:
 *         impossible = 0.0             # <<<<<<<<<<<<<<
 * 
 *     if viterbi and track is not None and track_enc is not None:
 */
    __pyx_v_impossible = 0.0;
  }
  __pyx_L9:;

  /* "cogent/align/_pairwise_seqs.pyx":119
 *         impossible = 0.0
 * 
 *     if viterbi and track is not None and track_enc is not None:             # <<<<<<<<<<<<<<
 *         track_data = checkArrayUChar3D(track, &row_count, &row_length, &N)
 *         (tcode_x, tcode_y, tcode_s) = track_enc
 */
  if (__pyx_v_viterbi) {
    __pyx_t_6 = (__pyx_v_track != Py_None);
    if (__pyx_t_6) {
      __pyx_t_5 = (__pyx_v_track_enc != Py_None);
      __pyx_t_13 = __pyx_t_5;
    } else {
      __pyx_t_13 = __pyx_t_6;
    }
    __pyx_t_6 = __pyx_t_13;
  } else {
    __pyx_t_6 = __pyx_v_viterbi;
  }
  if (__pyx_t_6) {

    /* "cogent/align/_pairwise_seqs.pyx":120
 * 
 *     if viterbi and track is not None and track_enc is not None:
 *         track_data = checkArrayUChar3D(track, &row_count, &row_length, &N)             # <<<<<<<<<<<<<<
 *         (tcode_x, tcode_y, tcode_s) = track_enc
 *     else:
 */
    __pyx_t_14 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayUChar3D(((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)__pyx_v_track), (&__pyx_v_row_count), (&__pyx_v_row_length), (&__pyx_v_N)); if (unlikely(__pyx_t_14 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_track_data = __pyx_t_14;

    /* "cogent/align/_pairwise_seqs.pyx":121
 *     if viterbi and track is not None and track_enc is not None:
 *         track_data = checkArrayUChar3D(track, &row_count, &row_length, &N)
 *         (tcode_x, tcode_y, tcode_s) = track_enc             # <<<<<<<<<<<<<<
 *     else:
 *         track_data = NULL
 */
    if ((likely(PyTuple_CheckExact(__pyx_v_track_enc))) || (PyList_CheckExact(__pyx_v_track_enc))) {
      PyObject* sequence = __pyx_v_track_enc;
      if (likely(PyTuple_CheckExact(sequence))) {
        if (unlikely(PyTuple_GET_SIZE(sequence) != 3)) {
          if (PyTuple_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
          else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        if (unlikely(PyList_GET_SIZE(sequence) != 3)) {
          if (PyList_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
          else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
    } else {
      Py_ssize_t index = -1;
      __pyx_t_15 = PyObject_GetIter(__pyx_v_track_enc); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_4 = Py_TYPE(__pyx_t_15)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_4(__pyx_t_15); if (unlikely(!__pyx_t_2)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_1 = __pyx_t_4(__pyx_t_15); if (unlikely(!__pyx_t_1)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 2; __pyx_t_3 = __pyx_t_4(__pyx_t_15); if (unlikely(!__pyx_t_3)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_15), 3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      goto __pyx_L12_unpacking_done;
      __pyx_L11_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
      if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L12_unpacking_done:;
    }
    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_16 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_17 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_tcode_x = __pyx_t_11;
    __pyx_v_tcode_y = __pyx_t_16;
    __pyx_v_tcode_s = __pyx_t_17;
    goto __pyx_L10;
  }
  /*else*/ {

    /* "cogent/align/_pairwise_seqs.pyx":123
 *         (tcode_x, tcode_y, tcode_s) = track_enc
 *     else:
 *         track_data = NULL             # <<<<<<<<<<<<<<
 *         tcode_x = tcode_y = tcode_s = 0
 * 
 */
    __pyx_v_track_data = NULL;

    /* "cogent/align/_pairwise_seqs.pyx":124
 *     else:
 *         track_data = NULL
 *         tcode_x = tcode_y = tcode_s = 0             # <<<<<<<<<<<<<<
 * 
 *     # For local
 */
    __pyx_v_tcode_x = 0;
    __pyx_v_tcode_y = 0;
    __pyx_v_tcode_s = 0;
  }
  __pyx_L10:;

  /* "cogent/align/_pairwise_seqs.pyx":127
 * 
 *     # For local
 *     overall_max_exponent = MIN_SCALE             # <<<<<<<<<<<<<<
 *     overall_max_mantissa = impossible
 *     last_i = last_j = last_state = -1
 */
  __pyx_v_overall_max_exponent = __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_SCALE;

  /* "cogent/align/_pairwise_seqs.pyx":128
 *     # For local
 *     overall_max_exponent = MIN_SCALE
 *     overall_max_mantissa = impossible             # <<<<<<<<<<<<<<
 *     last_i = last_j = last_state = -1
 * 
 */
  __pyx_v_overall_max_mantissa = __pyx_v_impossible;

  /* "cogent/align/_pairwise_seqs.pyx":129
 *     overall_max_exponent = MIN_SCALE
 *     overall_max_mantissa = impossible
 *     last_i = last_j = last_state = -1             # <<<<<<<<<<<<<<
 * 
 *     for i from i_low <= i < i_high:
 */
  __pyx_v_last_i = -1;
  __pyx_v_last_j = -1;
  __pyx_v_last_state = -1;

  /* "cogent/align/_pairwise_seqs.pyx":131
 *     last_i = last_j = last_state = -1
 * 
 *     for i from i_low <= i < i_high:             # <<<<<<<<<<<<<<
 *         x = x_index[i]
 * 
 */
  __pyx_t_17 = __pyx_v_i_high;
  for (__pyx_v_i = __pyx_v_i_low; __pyx_v_i < __pyx_t_17; __pyx_v_i++) {

    /* "cogent/align/_pairwise_seqs.pyx":132
 * 
 *     for i from i_low <= i < i_high:
 *         x = x_index[i]             # <<<<<<<<<<<<<<
 * 
 *         if PyErr_CheckSignals():
 */
    __pyx_v_x = (__pyx_v_x_index[__pyx_v_i]);

    /* "cogent/align/_pairwise_seqs.pyx":134
 *         x = x_index[i]
 * 
 *         if PyErr_CheckSignals():             # <<<<<<<<<<<<<<
 *             raise PyErr_Occurred()
 * 
 */
    __pyx_t_16 = PyErr_CheckSignals();
    if (__pyx_t_16) {

      /* "cogent/align/_pairwise_seqs.pyx":135
 * 
 *         if PyErr_CheckSignals():
 *             raise PyErr_Occurred()             # <<<<<<<<<<<<<<
 * 
 *         plan_index1 = plan_data[i]
 */
      __pyx_t_3 = PyErr_Occurred(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "cogent/align/_pairwise_seqs.pyx":137
 *             raise PyErr_Occurred()
 * 
 *         plan_index1 = plan_data[i]             # <<<<<<<<<<<<<<
 *         if i > 0:
 *             plan_index2 = plan_data[i-1]
 */
    __pyx_v_plan_index1 = (__pyx_v_plan_data[__pyx_v_i]);

    /* "cogent/align/_pairwise_seqs.pyx":138
 * 
 *         plan_index1 = plan_data[i]
 *         if i > 0:             # <<<<<<<<<<<<<<
 *             plan_index2 = plan_data[i-1]
 *         else:
 */
    __pyx_t_6 = (__pyx_v_i > 0);
    if (__pyx_t_6) {

      /* "cogent/align/_pairwise_seqs.pyx":139
 *         plan_index1 = plan_data[i]
 *         if i > 0:
 *             plan_index2 = plan_data[i-1]             # <<<<<<<<<<<<<<
 *         else:
 *             prev_row_data = NULL
 */
      __pyx_v_plan_index2 = (__pyx_v_plan_data[(__pyx_v_i - 1)]);
      goto __pyx_L16;
    }
    /*else*/ {

      /* "cogent/align/_pairwise_seqs.pyx":141
 *             plan_index2 = plan_data[i-1]
 *         else:
 *             prev_row_data = NULL             # <<<<<<<<<<<<<<
 *         current_row_data = checkArrayDouble2D(mantissas[plan_index1], &row_length, &N)
 *         if use_scaling:
 */
      __pyx_v_prev_row_data = NULL;
    }
    __pyx_L16:;

    /* "cogent/align/_pairwise_seqs.pyx":142
 *         else:
 *             prev_row_data = NULL
 *         current_row_data = checkArrayDouble2D(mantissas[plan_index1], &row_length, &N)             # <<<<<<<<<<<<<<
 *         if use_scaling:
 *             current_row_ex_data = checkArrayLong2D(exponents[plan_index1], &row_length, &N)
 */
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_mantissas, __pyx_v_plan_index1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble2D(((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)__pyx_t_3), (&__pyx_v_row_length), (&__pyx_v_N)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_current_row_data = __pyx_t_7;

    /* "cogent/align/_pairwise_seqs.pyx":143
 *             prev_row_data = NULL
 *         current_row_data = checkArrayDouble2D(mantissas[plan_index1], &row_length, &N)
 *         if use_scaling:             # <<<<<<<<<<<<<<
 *             current_row_ex_data = checkArrayLong2D(exponents[plan_index1], &row_length, &N)
 *         if i > 0:
 */
    if (__pyx_v_use_scaling) {

      /* "cogent/align/_pairwise_seqs.pyx":144
 *         current_row_data = checkArrayDouble2D(mantissas[plan_index1], &row_length, &N)
 *         if use_scaling:
 *             current_row_ex_data = checkArrayLong2D(exponents[plan_index1], &row_length, &N)             # <<<<<<<<<<<<<<
 *         if i > 0:
 *             prev_row_data = checkArrayDouble2D(mantissas[plan_index2], &row_length, &N)
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_exponents, __pyx_v_plan_index1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong2D(((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)__pyx_t_3), (&__pyx_v_row_length), (&__pyx_v_N)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_current_row_ex_data = __pyx_t_9;
      goto __pyx_L17;
    }
    __pyx_L17:;

    /* "cogent/align/_pairwise_seqs.pyx":145
 *         if use_scaling:
 *             current_row_ex_data = checkArrayLong2D(exponents[plan_index1], &row_length, &N)
 *         if i > 0:             # <<<<<<<<<<<<<<
 *             prev_row_data = checkArrayDouble2D(mantissas[plan_index2], &row_length, &N)
 *             if use_scaling:
 */
    __pyx_t_6 = (__pyx_v_i > 0);
    if (__pyx_t_6) {

      /* "cogent/align/_pairwise_seqs.pyx":146
 *             current_row_ex_data = checkArrayLong2D(exponents[plan_index1], &row_length, &N)
 *         if i > 0:
 *             prev_row_data = checkArrayDouble2D(mantissas[plan_index2], &row_length, &N)             # <<<<<<<<<<<<<<
 *             if use_scaling:
 *                 prev_row_ex_data = checkArrayLong2D(exponents[plan_index2], &row_length, &N)
 */
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_mantissas, __pyx_v_plan_index2, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayDouble2D(((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)__pyx_t_3), (&__pyx_v_row_length), (&__pyx_v_N)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_prev_row_data = __pyx_t_7;

      /* "cogent/align/_pairwise_seqs.pyx":147
 *         if i > 0:
 *             prev_row_data = checkArrayDouble2D(mantissas[plan_index2], &row_length, &N)
 *             if use_scaling:             # <<<<<<<<<<<<<<
 *                 prev_row_ex_data = checkArrayLong2D(exponents[plan_index2], &row_length, &N)
 * 
 */
      if (__pyx_v_use_scaling) {

        /* "cogent/align/_pairwise_seqs.pyx":148
 *             prev_row_data = checkArrayDouble2D(mantissas[plan_index2], &row_length, &N)
 *             if use_scaling:
 *                 prev_row_ex_data = checkArrayLong2D(exponents[plan_index2], &row_length, &N)             # <<<<<<<<<<<<<<
 * 
 *         #for prev_state from 1 <= prev_state < N:
 */
        __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_exponents, __pyx_v_plan_index2, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_9 = __pyx_f_6cogent_5align_14_pairwise_seqs_checkArrayLong2D(((__pyx_t_6cogent_5align_14_pairwise_seqs_ArrayType)__pyx_t_3), (&__pyx_v_row_length), (&__pyx_v_N)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_v_prev_row_ex_data = __pyx_t_9;
        goto __pyx_L19;
      }
      __pyx_L19:;
      goto __pyx_L18;
    }
    __pyx_L18:;

    /* "cogent/align/_pairwise_seqs.pyx":153
 *         #    current_row_data[0*N+prev_state] = impossible
 * 
 *         for j from j_low <= j < j_high:             # <<<<<<<<<<<<<<
 * 
 *             for dest_state from 0 <= dest_state < dest_states:
 */
    __pyx_t_16 = __pyx_v_j_high;
    for (__pyx_v_j = __pyx_v_j_low; __pyx_v_j < __pyx_t_16; __pyx_v_j++) {

      /* "cogent/align/_pairwise_seqs.pyx":155
 *         for j from j_low <= j < j_high:
 * 
 *             for dest_state from 0 <= dest_state < dest_states:             # <<<<<<<<<<<<<<
 *                 state = dest_states_data[dest_state*4+0]
 *                 bin = dest_states_data[dest_state*4+1]
 */
      __pyx_t_11 = __pyx_v_dest_states;
      for (__pyx_v_dest_state = 0; __pyx_v_dest_state < __pyx_t_11; __pyx_v_dest_state++) {

        /* "cogent/align/_pairwise_seqs.pyx":156
 * 
 *             for dest_state from 0 <= dest_state < dest_states:
 *                 state = dest_states_data[dest_state*4+0]             # <<<<<<<<<<<<<<
 *                 bin = dest_states_data[dest_state*4+1]
 *                 dx = dest_states_data[dest_state*4+2]
 */
        __pyx_v_state = (__pyx_v_dest_states_data[((__pyx_v_dest_state * 4) + 0)]);

        /* "cogent/align/_pairwise_seqs.pyx":157
 *             for dest_state from 0 <= dest_state < dest_states:
 *                 state = dest_states_data[dest_state*4+0]
 *                 bin = dest_states_data[dest_state*4+1]             # <<<<<<<<<<<<<<
 *                 dx = dest_states_data[dest_state*4+2]
 *                 dy = dest_states_data[dest_state*4+3]
 */
        __pyx_v_bin = (__pyx_v_dest_states_data[((__pyx_v_dest_state * 4) + 1)]);

        /* "cogent/align/_pairwise_seqs.pyx":158
 *                 state = dest_states_data[dest_state*4+0]
 *                 bin = dest_states_data[dest_state*4+1]
 *                 dx = dest_states_data[dest_state*4+2]             # <<<<<<<<<<<<<<
 *                 dy = dest_states_data[dest_state*4+3]
 * 
 */
        __pyx_v_dx = (__pyx_v_dest_states_data[((__pyx_v_dest_state * 4) + 2)]);

        /* "cogent/align/_pairwise_seqs.pyx":159
 *                 bin = dest_states_data[dest_state*4+1]
 *                 dx = dest_states_data[dest_state*4+2]
 *                 dy = dest_states_data[dest_state*4+3]             # <<<<<<<<<<<<<<
 * 
 *                 max_mantissa = impossible
 */
        __pyx_v_dy = (__pyx_v_dest_states_data[((__pyx_v_dest_state * 4) + 3)]);

        /* "cogent/align/_pairwise_seqs.pyx":161
 *                 dy = dest_states_data[dest_state*4+3]
 * 
 *                 max_mantissa = impossible             # <<<<<<<<<<<<<<
 *                 max_exponent = MIN_SCALE
 *                 partial_sum = 0.0
 */
        __pyx_v_max_mantissa = __pyx_v_impossible;

        /* "cogent/align/_pairwise_seqs.pyx":162
 * 
 *                 max_mantissa = impossible
 *                 max_exponent = MIN_SCALE             # <<<<<<<<<<<<<<
 *                 partial_sum = 0.0
 *                 pointer_state = N  # ie ERROR
 */
        __pyx_v_max_exponent = __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_SCALE;

        /* "cogent/align/_pairwise_seqs.pyx":163
 *                 max_mantissa = impossible
 *                 max_exponent = MIN_SCALE
 *                 partial_sum = 0.0             # <<<<<<<<<<<<<<
 *                 pointer_state = N  # ie ERROR
 * 
 */
        __pyx_v_partial_sum = 0.0;

        /* "cogent/align/_pairwise_seqs.pyx":164
 *                 max_exponent = MIN_SCALE
 *                 partial_sum = 0.0
 *                 pointer_state = N  # ie ERROR             # <<<<<<<<<<<<<<
 * 
 *                 a = dx
 */
        __pyx_v_pointer_state = __pyx_v_N;

        /* "cogent/align/_pairwise_seqs.pyx":166
 *                 pointer_state = N  # ie ERROR
 * 
 *                 a = dx             # <<<<<<<<<<<<<<
 *                 b = dy
 * 
 */
        __pyx_v_a = __pyx_v_dx;

        /* "cogent/align/_pairwise_seqs.pyx":167
 * 
 *                 a = dx
 *                 b = dy             # <<<<<<<<<<<<<<
 * 
 *                 if dx:
 */
        __pyx_v_b = __pyx_v_dy;

        /* "cogent/align/_pairwise_seqs.pyx":169
 *                 b = dy
 * 
 *                 if dx:             # <<<<<<<<<<<<<<
 *                     source_i = i - 1
 *                     source_row_data = prev_row_data
 */
        if (__pyx_v_dx) {

          /* "cogent/align/_pairwise_seqs.pyx":170
 * 
 *                 if dx:
 *                     source_i = i - 1             # <<<<<<<<<<<<<<
 *                     source_row_data = prev_row_data
 *                     source_row_ex_data = prev_row_ex_data
 */
          __pyx_v_source_i = (__pyx_v_i - 1);

          /* "cogent/align/_pairwise_seqs.pyx":171
 *                 if dx:
 *                     source_i = i - 1
 *                     source_row_data = prev_row_data             # <<<<<<<<<<<<<<
 *                     source_row_ex_data = prev_row_ex_data
 *                 else:
 */
          __pyx_v_source_row_data = __pyx_v_prev_row_data;

          /* "cogent/align/_pairwise_seqs.pyx":172
 *                     source_i = i - 1
 *                     source_row_data = prev_row_data
 *                     source_row_ex_data = prev_row_ex_data             # <<<<<<<<<<<<<<
 *                 else:
 *                     source_i = i
 */
          __pyx_v_source_row_ex_data = __pyx_v_prev_row_ex_data;
          goto __pyx_L24;
        }
        /*else*/ {

          /* "cogent/align/_pairwise_seqs.pyx":174
 *                     source_row_ex_data = prev_row_ex_data
 *                 else:
 *                     source_i = i             # <<<<<<<<<<<<<<
 *                     source_row_data = current_row_data
 *                     source_row_ex_data = current_row_ex_data
 */
          __pyx_v_source_i = __pyx_v_i;

          /* "cogent/align/_pairwise_seqs.pyx":175
 *                 else:
 *                     source_i = i
 *                     source_row_data = current_row_data             # <<<<<<<<<<<<<<
 *                     source_row_ex_data = current_row_ex_data
 * 
 */
          __pyx_v_source_row_data = __pyx_v_current_row_data;

          /* "cogent/align/_pairwise_seqs.pyx":176
 *                     source_i = i
 *                     source_row_data = current_row_data
 *                     source_row_ex_data = current_row_ex_data             # <<<<<<<<<<<<<<
 * 
 *                 prev_j = j - dy
 */
          __pyx_v_source_row_ex_data = __pyx_v_current_row_ex_data;
        }
        __pyx_L24:;

        /* "cogent/align/_pairwise_seqs.pyx":178
 *                     source_row_ex_data = current_row_ex_data
 * 
 *                 prev_j = j - dy             # <<<<<<<<<<<<<<
 *                 if prev_j < 0:
 *                     continue
 */
        __pyx_v_prev_j = (__pyx_v_j - __pyx_v_dy);

        /* "cogent/align/_pairwise_seqs.pyx":179
 * 
 *                 prev_j = j - dy
 *                 if prev_j < 0:             # <<<<<<<<<<<<<<
 *                     continue
 * 
 */
        __pyx_t_6 = (__pyx_v_prev_j < 0);
        if (__pyx_t_6) {

          /* "cogent/align/_pairwise_seqs.pyx":180
 *                 prev_j = j - dy
 *                 if prev_j < 0:
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 if source_i < 0:
 */
          goto __pyx_L22_continue;
          goto __pyx_L25;
        }
        __pyx_L25:;

        /* "cogent/align/_pairwise_seqs.pyx":182
 *                     continue
 * 
 *                 if source_i < 0:             # <<<<<<<<<<<<<<
 *                     continue
 * 
 */
        __pyx_t_6 = (__pyx_v_source_i < 0);
        if (__pyx_t_6) {

          /* "cogent/align/_pairwise_seqs.pyx":183
 * 
 *                 if source_i < 0:
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 if (local and dx and dy) or (prev_j == 0 and source_i == 0):
 */
          goto __pyx_L22_continue;
          goto __pyx_L26;
        }
        __pyx_L26:;

        /* "cogent/align/_pairwise_seqs.pyx":185
 *                     continue
 * 
 *                 if (local and dx and dy) or (prev_j == 0 and source_i == 0):             # <<<<<<<<<<<<<<
 *                     partial_sum = max_mantissa = T_data[0*N+state]
 *                     max_exponent = 0
 */
        if (__pyx_v_local) {
          if (__pyx_v_dx) {
            __pyx_t_6 = __pyx_v_dy;
          } else {
            __pyx_t_6 = __pyx_v_dx;
          }
          __pyx_t_13 = __pyx_t_6;
        } else {
          __pyx_t_13 = __pyx_v_local;
        }
        if (!__pyx_t_13) {
          __pyx_t_6 = (__pyx_v_prev_j == 0);
          if (__pyx_t_6) {
            __pyx_t_5 = (__pyx_v_source_i == 0);
            __pyx_t_12 = __pyx_t_5;
          } else {
            __pyx_t_12 = __pyx_t_6;
          }
          __pyx_t_6 = __pyx_t_12;
        } else {
          __pyx_t_6 = __pyx_t_13;
        }
        if (__pyx_t_6) {

          /* "cogent/align/_pairwise_seqs.pyx":186
 * 
 *                 if (local and dx and dy) or (prev_j == 0 and source_i == 0):
 *                     partial_sum = max_mantissa = T_data[0*N+state]             # <<<<<<<<<<<<<<
 *                     max_exponent = 0
 *                     pointer_state = 0
 */
          __pyx_t_18 = (__pyx_v_T_data[((0 * __pyx_v_N) + __pyx_v_state)]);
          __pyx_v_partial_sum = __pyx_t_18;
          __pyx_v_max_mantissa = __pyx_t_18;

          /* "cogent/align/_pairwise_seqs.pyx":187
 *                 if (local and dx and dy) or (prev_j == 0 and source_i == 0):
 *                     partial_sum = max_mantissa = T_data[0*N+state]
 *                     max_exponent = 0             # <<<<<<<<<<<<<<
 *                     pointer_state = 0
 *                     pointer_a = a
 */
          __pyx_v_max_exponent = 0;

          /* "cogent/align/_pairwise_seqs.pyx":188
 *                     partial_sum = max_mantissa = T_data[0*N+state]
 *                     max_exponent = 0
 *                     pointer_state = 0             # <<<<<<<<<<<<<<
 *                     pointer_a = a
 *                     pointer_b = b
 */
          __pyx_v_pointer_state = 0;

          /* "cogent/align/_pairwise_seqs.pyx":189
 *                     max_exponent = 0
 *                     pointer_state = 0
 *                     pointer_a = a             # <<<<<<<<<<<<<<
 *                     pointer_b = b
 * 
 */
          __pyx_v_pointer_a = __pyx_v_a;

          /* "cogent/align/_pairwise_seqs.pyx":190
 *                     pointer_state = 0
 *                     pointer_a = a
 *                     pointer_b = b             # <<<<<<<<<<<<<<
 * 
 *                 if use_scaling:
 */
          __pyx_v_pointer_b = __pyx_v_b;
          goto __pyx_L27;
        }
        __pyx_L27:;

        /* "cogent/align/_pairwise_seqs.pyx":192
 *                     pointer_b = b
 * 
 *                 if use_scaling:             # <<<<<<<<<<<<<<
 *                             sub_partial_sum = 0.0
 *                             for prev_state from 1 <= prev_state < N:
 */
        if (__pyx_v_use_scaling) {

          /* "cogent/align/_pairwise_seqs.pyx":193
 * 
 *                 if use_scaling:
 *                             sub_partial_sum = 0.0             # <<<<<<<<<<<<<<
 *                             for prev_state from 1 <= prev_state < N:
 *                                 index = prev_j*N + prev_state
 */
          __pyx_v_sub_partial_sum = 0.0;

          /* "cogent/align/_pairwise_seqs.pyx":194
 *                 if use_scaling:
 *                             sub_partial_sum = 0.0
 *                             for prev_state from 1 <= prev_state < N:             # <<<<<<<<<<<<<<
 *                                 index = prev_j*N + prev_state
 * 
 */
          __pyx_t_19 = __pyx_v_N;
          for (__pyx_v_prev_state = 1; __pyx_v_prev_state < __pyx_t_19; __pyx_v_prev_state++) {

            /* "cogent/align/_pairwise_seqs.pyx":195
 *                             sub_partial_sum = 0.0
 *                             for prev_state from 1 <= prev_state < N:
 *                                 index = prev_j*N + prev_state             # <<<<<<<<<<<<<<
 * 
 *                                 exponent = source_row_ex_data[index]
 */
            __pyx_v_index = ((__pyx_v_prev_j * __pyx_v_N) + __pyx_v_prev_state);

            /* "cogent/align/_pairwise_seqs.pyx":197
 *                                 index = prev_j*N + prev_state
 * 
 *                                 exponent = source_row_ex_data[index]             # <<<<<<<<<<<<<<
 *                                 if exponent == MIN_SCALE:
 *                                     continue
 */
            __pyx_v_exponent = (__pyx_v_source_row_ex_data[__pyx_v_index]);

            /* "cogent/align/_pairwise_seqs.pyx":198
 * 
 *                                 exponent = source_row_ex_data[index]
 *                                 if exponent == MIN_SCALE:             # <<<<<<<<<<<<<<
 *                                     continue
 * 
 */
            __pyx_t_6 = (__pyx_v_exponent == __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_SCALE);
            if (__pyx_t_6) {

              /* "cogent/align/_pairwise_seqs.pyx":199
 *                                 exponent = source_row_ex_data[index]
 *                                 if exponent == MIN_SCALE:
 *                                     continue             # <<<<<<<<<<<<<<
 * 
 *                                 mantissa = (source_row_data[index]
 */
              goto __pyx_L29_continue;
              goto __pyx_L31;
            }
            __pyx_L31:;

            /* "cogent/align/_pairwise_seqs.pyx":202
 * 
 *                                 mantissa = (source_row_data[index]
 *                                      * T_data[prev_state*N+state])             # <<<<<<<<<<<<<<
 * 
 *                                 if mantissa < MIN_FLOAT_VALUE:
 */
            __pyx_v_mantissa = ((__pyx_v_source_row_data[__pyx_v_index]) * (__pyx_v_T_data[((__pyx_v_prev_state * __pyx_v_N) + __pyx_v_state)]));

            /* "cogent/align/_pairwise_seqs.pyx":204
 *                                      * T_data[prev_state*N+state])
 * 
 *                                 if mantissa < MIN_FLOAT_VALUE:             # <<<<<<<<<<<<<<
 *                                     if mantissa == 0.0:
 *                                         continue
 */
            __pyx_t_6 = (__pyx_v_mantissa < __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_FLOAT_VALUE);
            if (__pyx_t_6) {

              /* "cogent/align/_pairwise_seqs.pyx":205
 * 
 *                                 if mantissa < MIN_FLOAT_VALUE:
 *                                     if mantissa == 0.0:             # <<<<<<<<<<<<<<
 *                                         continue
 *                                     if mantissa < 0.0:
 */
              __pyx_t_6 = (__pyx_v_mantissa == 0.0);
              if (__pyx_t_6) {

                /* "cogent/align/_pairwise_seqs.pyx":206
 *                                 if mantissa < MIN_FLOAT_VALUE:
 *                                     if mantissa == 0.0:
 *                                         continue             # <<<<<<<<<<<<<<
 *                                     if mantissa < 0.0:
 *                                         if T_data[prev_state*N+state] < 0.0:
 */
                goto __pyx_L29_continue;
                goto __pyx_L33;
              }
              __pyx_L33:;

              /* "cogent/align/_pairwise_seqs.pyx":207
 *                                     if mantissa == 0.0:
 *                                         continue
 *                                     if mantissa < 0.0:             # <<<<<<<<<<<<<<
 *                                         if T_data[prev_state*N+state] < 0.0:
 *                                             raise ArithmeticError(fmpt(mantissa, exponent,
 */
              __pyx_t_6 = (__pyx_v_mantissa < 0.0);
              if (__pyx_t_6) {

                /* "cogent/align/_pairwise_seqs.pyx":208
 *                                         continue
 *                                     if mantissa < 0.0:
 *                                         if T_data[prev_state*N+state] < 0.0:             # <<<<<<<<<<<<<<
 *                                             raise ArithmeticError(fmpt(mantissa, exponent,
 *                                                     "transition is a negative probability"))
 */
                __pyx_t_6 = ((__pyx_v_T_data[((__pyx_v_prev_state * __pyx_v_N) + __pyx_v_state)]) < 0.0);
                if (__pyx_t_6) {

                  /* "cogent/align/_pairwise_seqs.pyx":209
 *                                     if mantissa < 0.0:
 *                                         if T_data[prev_state*N+state] < 0.0:
 *                                             raise ArithmeticError(fmpt(mantissa, exponent,             # <<<<<<<<<<<<<<
 *                                                     "transition is a negative probability"))
 *                                         raise ArithmeticError(fmpt(mantissa, exponent,
 */
                  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__fmpt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_mantissa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_1);
                  __pyx_t_2 = PyInt_FromLong(__pyx_v_exponent); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_2);
                  __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_15);
                  PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_1);
                  __Pyx_GIVEREF(__pyx_t_1);
                  PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_2);
                  __Pyx_GIVEREF(__pyx_t_2);
                  __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
                  PyTuple_SET_ITEM(__pyx_t_15, 2, ((PyObject *)__pyx_kp_s_12));
                  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
                  __pyx_t_1 = 0;
                  __pyx_t_2 = 0;
                  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_2);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;
                  __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_15);
                  PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_2);
                  __Pyx_GIVEREF(__pyx_t_2);
                  __pyx_t_2 = 0;
                  __pyx_t_2 = PyObject_Call(__pyx_builtin_ArithmeticError, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_2);
                  __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;
                  __Pyx_Raise(__pyx_t_2, 0, 0, 0);
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                  {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  goto __pyx_L35;
                }
                __pyx_L35:;

                /* "cogent/align/_pairwise_seqs.pyx":211
 *                                             raise ArithmeticError(fmpt(mantissa, exponent,
 *                                                     "transition is a negative probability"))
 *                                         raise ArithmeticError(fmpt(mantissa, exponent,             # <<<<<<<<<<<<<<
 *                                                 "product is a negative probability"))
 *                                     while mantissa < MIN_FLOAT_VALUE:
 */
                __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__fmpt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_15 = PyFloat_FromDouble(__pyx_v_mantissa); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_3 = PyInt_FromLong(__pyx_v_exponent); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_1);
                PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_15);
                __Pyx_GIVEREF(__pyx_t_15);
                PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_3);
                __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
                PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_kp_s_13));
                __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13));
                __pyx_t_15 = 0;
                __pyx_t_3 = 0;
                __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_1);
                PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_3);
                __pyx_t_3 = 0;
                __pyx_t_3 = PyObject_Call(__pyx_builtin_ArithmeticError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
                __Pyx_Raise(__pyx_t_3, 0, 0, 0);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                goto __pyx_L34;
              }
              __pyx_L34:;

              /* "cogent/align/_pairwise_seqs.pyx":213
 *                                         raise ArithmeticError(fmpt(mantissa, exponent,
 *                                                 "product is a negative probability"))
 *                                     while mantissa < MIN_FLOAT_VALUE:             # <<<<<<<<<<<<<<
 *                                         mantissa *= SCALE_STEP
 *                                         exponent += -1
 */
              while (1) {
                __pyx_t_6 = (__pyx_v_mantissa < __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_FLOAT_VALUE);
                if (!__pyx_t_6) break;

                /* "cogent/align/_pairwise_seqs.pyx":214
 *                                                 "product is a negative probability"))
 *                                     while mantissa < MIN_FLOAT_VALUE:
 *                                         mantissa *= SCALE_STEP             # <<<<<<<<<<<<<<
 *                                         exponent += -1
 *                                         if exponent <= MIN_SCALE:
 */
                __pyx_v_mantissa = (__pyx_v_mantissa * __pyx_v_6cogent_5align_14_pairwise_seqs_SCALE_STEP);

                /* "cogent/align/_pairwise_seqs.pyx":215
 *                                     while mantissa < MIN_FLOAT_VALUE:
 *                                         mantissa *= SCALE_STEP
 *                                         exponent += -1             # <<<<<<<<<<<<<<
 *                                         if exponent <= MIN_SCALE:
 *                                           raise ArithmeticError(fmpt(mantissa, exponent,
 */
                __pyx_v_exponent = (__pyx_v_exponent + -1);

                /* "cogent/align/_pairwise_seqs.pyx":216
 *                                         mantissa *= SCALE_STEP
 *                                         exponent += -1
 *                                         if exponent <= MIN_SCALE:             # <<<<<<<<<<<<<<
 *                                           raise ArithmeticError(fmpt(mantissa, exponent,
 *                                                 "underflows"))
 */
                __pyx_t_6 = (__pyx_v_exponent <= __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_SCALE);
                if (__pyx_t_6) {

                  /* "cogent/align/_pairwise_seqs.pyx":217
 *                                         exponent += -1
 *                                         if exponent <= MIN_SCALE:
 *                                           raise ArithmeticError(fmpt(mantissa, exponent,             # <<<<<<<<<<<<<<
 *                                                 "underflows"))
 * 
 */
                  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__fmpt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_mantissa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_1);
                  __pyx_t_2 = PyInt_FromLong(__pyx_v_exponent); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_2);
                  __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_15);
                  PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_1);
                  __Pyx_GIVEREF(__pyx_t_1);
                  PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_2);
                  __Pyx_GIVEREF(__pyx_t_2);
                  __Pyx_INCREF(((PyObject *)__pyx_n_s__underflows));
                  PyTuple_SET_ITEM(__pyx_t_15, 2, ((PyObject *)__pyx_n_s__underflows));
                  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__underflows));
                  __pyx_t_1 = 0;
                  __pyx_t_2 = 0;
                  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_2);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;
                  __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_15);
                  PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_2);
                  __Pyx_GIVEREF(__pyx_t_2);
                  __pyx_t_2 = 0;
                  __pyx_t_2 = PyObject_Call(__pyx_builtin_ArithmeticError, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  __Pyx_GOTREF(__pyx_t_2);
                  __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;
                  __Pyx_Raise(__pyx_t_2, 0, 0, 0);
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                  {__pyx_filename = __pyx_f[1]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                  goto __pyx_L38;
                }
                __pyx_L38:;
              }
              goto __pyx_L32;
            }

            /* "cogent/align/_pairwise_seqs.pyx":220
 *                                                 "underflows"))
 * 
 *                                 elif mantissa > 1.0:             # <<<<<<<<<<<<<<
 *                                     mantissa *= MIN_FLOAT_VALUE
 *                                     exponent += 1
 */
            __pyx_t_6 = (__pyx_v_mantissa > 1.0);
            if (__pyx_t_6) {

              /* "cogent/align/_pairwise_seqs.pyx":221
 * 
 *                                 elif mantissa > 1.0:
 *                                     mantissa *= MIN_FLOAT_VALUE             # <<<<<<<<<<<<<<
 *                                     exponent += 1
 *                                     if exponent > MAX_SCALE:
 */
              __pyx_v_mantissa = (__pyx_v_mantissa * __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_FLOAT_VALUE);

              /* "cogent/align/_pairwise_seqs.pyx":222
 *                                 elif mantissa > 1.0:
 *                                     mantissa *= MIN_FLOAT_VALUE
 *                                     exponent += 1             # <<<<<<<<<<<<<<
 *                                     if exponent > MAX_SCALE:
 *                                         raise ArithmeticError(fmpt(mantissa, exponent,
 */
              __pyx_v_exponent = (__pyx_v_exponent + 1);

              /* "cogent/align/_pairwise_seqs.pyx":223
 *                                     mantissa *= MIN_FLOAT_VALUE
 *                                     exponent += 1
 *                                     if exponent > MAX_SCALE:             # <<<<<<<<<<<<<<
 *                                         raise ArithmeticError(fmpt(mantissa, exponent,
 *                                             "is unexpectedly large"))
 */
              __pyx_t_6 = (__pyx_v_exponent > __pyx_v_6cogent_5align_14_pairwise_seqs_MAX_SCALE);
              if (__pyx_t_6) {

                /* "cogent/align/_pairwise_seqs.pyx":224
 *                                     exponent += 1
 *                                     if exponent > MAX_SCALE:
 *                                         raise ArithmeticError(fmpt(mantissa, exponent,             # <<<<<<<<<<<<<<
 *                                             "is unexpectedly large"))
 * 
 */
                __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__fmpt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_15 = PyFloat_FromDouble(__pyx_v_mantissa); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_3 = PyInt_FromLong(__pyx_v_exponent); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_1);
                PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_15);
                __Pyx_GIVEREF(__pyx_t_15);
                PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_3);
                __Pyx_INCREF(((PyObject *)__pyx_kp_s_14));
                PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_kp_s_14));
                __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_14));
                __pyx_t_15 = 0;
                __pyx_t_3 = 0;
                __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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[1]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_1);
                PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_3);
                __pyx_t_3 = 0;
                __pyx_t_3 = PyObject_Call(__pyx_builtin_ArithmeticError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
                __Pyx_Raise(__pyx_t_3, 0, 0, 0);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                {__pyx_filename = __pyx_f[1]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                goto __pyx_L39;
              }
              __pyx_L39:;
              goto __pyx_L32;
            }
            __pyx_L32:;

            /* "cogent/align/_pairwise_seqs.pyx":227
 *                                             "is unexpectedly large"))
 * 
 *                                 if exponent > max_exponent:             # <<<<<<<<<<<<<<
 *                                     if exponent == max_exponent + 1:
 *                                         sub_partial_sum = partial_sum
 */
            __pyx_t_6 = (__pyx_v_exponent > __pyx_v_max_exponent);
            if (__pyx_t_6) {

              /* "cogent/align/_pairwise_seqs.pyx":228
 * 
 *                                 if exponent > max_exponent:
 *                                     if exponent == max_exponent + 1:             # <<<<<<<<<<<<<<
 *                                         sub_partial_sum = partial_sum
 *                                     else:
 */
              __pyx_t_6 = (__pyx_v_exponent == (__pyx_v_max_exponent + 1));
              if (__pyx_t_6) {

                /* "cogent/align/_pairwise_seqs.pyx":229
 *                                 if exponent > max_exponent:
 *                                     if exponent == max_exponent + 1:
 *                                         sub_partial_sum = partial_sum             # <<<<<<<<<<<<<<
 *                                     else:
 *                                         sub_partial_sum = 0.0
 */
                __pyx_v_sub_partial_sum = __pyx_v_partial_sum;
                goto __pyx_L41;
              }
              /*else*/ {

                /* "cogent/align/_pairwise_seqs.pyx":231
 *                                         sub_partial_sum = partial_sum
 *                                     else:
 *                                         sub_partial_sum = 0.0             # <<<<<<<<<<<<<<
 *                                     partial_sum = 0.0
 *                                     max_mantissa = 0.0
 */
                __pyx_v_sub_partial_sum = 0.0;
              }
              __pyx_L41:;

              /* "cogent/align/_pairwise_seqs.pyx":232
 *                                     else:
 *                                         sub_partial_sum = 0.0
 *                                     partial_sum = 0.0             # <<<<<<<<<<<<<<
 *                                     max_mantissa = 0.0
 *                                     max_exponent = exponent
 */
              __pyx_v_partial_sum = 0.0;

              /* "cogent/align/_pairwise_seqs.pyx":233
 *                                         sub_partial_sum = 0.0
 *                                     partial_sum = 0.0
 *                                     max_mantissa = 0.0             # <<<<<<<<<<<<<<
 *                                     max_exponent = exponent
 * 
 */
              __pyx_v_max_mantissa = 0.0;

              /* "cogent/align/_pairwise_seqs.pyx":234
 *                                     partial_sum = 0.0
 *                                     max_mantissa = 0.0
 *                                     max_exponent = exponent             # <<<<<<<<<<<<<<
 * 
 *                                 if exponent == max_exponent:
 */
              __pyx_v_max_exponent = __pyx_v_exponent;
              goto __pyx_L40;
            }
            __pyx_L40:;

            /* "cogent/align/_pairwise_seqs.pyx":236
 *                                     max_exponent = exponent
 * 
 *                                 if exponent == max_exponent:             # <<<<<<<<<<<<<<
 *                                     partial_sum += mantissa
 *                                     if viterbi and mantissa > max_mantissa:
 */
            __pyx_t_6 = (__pyx_v_exponent == __pyx_v_max_exponent);
            if (__pyx_t_6) {

              /* "cogent/align/_pairwise_seqs.pyx":237
 * 
 *                                 if exponent == max_exponent:
 *                                     partial_sum += mantissa             # <<<<<<<<<<<<<<
 *                                     if viterbi and mantissa > max_mantissa:
 *                                         max_mantissa = mantissa
 */
              __pyx_v_partial_sum = (__pyx_v_partial_sum + __pyx_v_mantissa);

              /* "cogent/align/_pairwise_seqs.pyx":238
 *                                 if exponent == max_exponent:
 *                                     partial_sum += mantissa
 *                                     if viterbi and mantissa > max_mantissa:             # <<<<<<<<<<<<<<
 *                                         max_mantissa = mantissa
 *                                         pointer_state = prev_state
 */
              if (__pyx_v_viterbi) {
                __pyx_t_6 = (__pyx_v_mantissa > __pyx_v_max_mantissa);
                __pyx_t_13 = __pyx_t_6;
              } else {
                __pyx_t_13 = __pyx_v_viterbi;
              }
              if (__pyx_t_13) {

                /* "cogent/align/_pairwise_seqs.pyx":239
 *                                     partial_sum += mantissa
 *                                     if viterbi and mantissa > max_mantissa:
 *                                         max_mantissa = mantissa             # <<<<<<<<<<<<<<
 *                                         pointer_state = prev_state
 *                                         pointer_a = a
 */
                __pyx_v_max_mantissa = __pyx_v_mantissa;

                /* "cogent/align/_pairwise_seqs.pyx":240
 *                                     if viterbi and mantissa > max_mantissa:
 *                                         max_mantissa = mantissa
 *                                         pointer_state = prev_state             # <<<<<<<<<<<<<<
 *                                         pointer_a = a
 *                                         pointer_b = b
 */
                __pyx_v_pointer_state = __pyx_v_prev_state;

                /* "cogent/align/_pairwise_seqs.pyx":241
 *                                         max_mantissa = mantissa
 *                                         pointer_state = prev_state
 *                                         pointer_a = a             # <<<<<<<<<<<<<<
 *                                         pointer_b = b
 * 
 */
                __pyx_v_pointer_a = __pyx_v_a;

                /* "cogent/align/_pairwise_seqs.pyx":242
 *                                         pointer_state = prev_state
 *                                         pointer_a = a
 *                                         pointer_b = b             # <<<<<<<<<<<<<<
 * 
 *                                 elif exponent == max_exponent - 1:
 */
                __pyx_v_pointer_b = __pyx_v_b;
                goto __pyx_L43;
              }
              __pyx_L43:;
              goto __pyx_L42;
            }

            /* "cogent/align/_pairwise_seqs.pyx":244
 *                                         pointer_b = b
 * 
 *                                 elif exponent == max_exponent - 1:             # <<<<<<<<<<<<<<
 *                                     sub_partial_sum += mantissa
 * 
 */
            __pyx_t_13 = (__pyx_v_exponent == (__pyx_v_max_exponent - 1));
            if (__pyx_t_13) {

              /* "cogent/align/_pairwise_seqs.pyx":245
 * 
 *                                 elif exponent == max_exponent - 1:
 *                                     sub_partial_sum += mantissa             # <<<<<<<<<<<<<<
 * 
 *                             partial_sum += sub_partial_sum * MIN_FLOAT_VALUE
 */
              __pyx_v_sub_partial_sum = (__pyx_v_sub_partial_sum + __pyx_v_mantissa);
              goto __pyx_L42;
            }
            __pyx_L42:;
            __pyx_L29_continue:;
          }

          /* "cogent/align/_pairwise_seqs.pyx":247
 *                                     sub_partial_sum += mantissa
 * 
 *                             partial_sum += sub_partial_sum * MIN_FLOAT_VALUE             # <<<<<<<<<<<<<<
 *                 else:
 *                             for prev_state from 1 <= prev_state < N:
 */
          __pyx_v_partial_sum = (__pyx_v_partial_sum + (__pyx_v_sub_partial_sum * __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_FLOAT_VALUE));
          goto __pyx_L28;
        }
        /*else*/ {

          /* "cogent/align/_pairwise_seqs.pyx":249
 *                             partial_sum += sub_partial_sum * MIN_FLOAT_VALUE
 *                 else:
 *                             for prev_state from 1 <= prev_state < N:             # <<<<<<<<<<<<<<
 *                                 index = prev_j*N + prev_state
 *                                 if use_logs:
 */
          __pyx_t_19 = __pyx_v_N;
          for (__pyx_v_prev_state = 1; __pyx_v_prev_state < __pyx_t_19; __pyx_v_prev_state++) {

            /* "cogent/align/_pairwise_seqs.pyx":250
 *                 else:
 *                             for prev_state from 1 <= prev_state < N:
 *                                 index = prev_j*N + prev_state             # <<<<<<<<<<<<<<
 *                                 if use_logs:
 *                                     mantissa = (source_row_data[index]
 */
            __pyx_v_index = ((__pyx_v_prev_j * __pyx_v_N) + __pyx_v_prev_state);

            /* "cogent/align/_pairwise_seqs.pyx":251
 *                             for prev_state from 1 <= prev_state < N:
 *                                 index = prev_j*N + prev_state
 *                                 if use_logs:             # <<<<<<<<<<<<<<
 *                                     mantissa = (source_row_data[index]
 *                                          + T_data[prev_state*N+state])
 */
            if (__pyx_v_use_logs) {

              /* "cogent/align/_pairwise_seqs.pyx":253
 *                                 if use_logs:
 *                                     mantissa = (source_row_data[index]
 *                                          + T_data[prev_state*N+state])             # <<<<<<<<<<<<<<
 *                                 else:
 *                                     mantissa = (source_row_data[index]
 */
              __pyx_v_mantissa = ((__pyx_v_source_row_data[__pyx_v_index]) + (__pyx_v_T_data[((__pyx_v_prev_state * __pyx_v_N) + __pyx_v_state)]));
              goto __pyx_L46;
            }
            /*else*/ {

              /* "cogent/align/_pairwise_seqs.pyx":256
 *                                 else:
 *                                     mantissa = (source_row_data[index]
 *                                          * T_data[prev_state*N+state])             # <<<<<<<<<<<<<<
 *                                     partial_sum += mantissa
 *                                 if viterbi and mantissa > max_mantissa:
 */
              __pyx_v_mantissa = ((__pyx_v_source_row_data[__pyx_v_index]) * (__pyx_v_T_data[((__pyx_v_prev_state * __pyx_v_N) + __pyx_v_state)]));

              /* "cogent/align/_pairwise_seqs.pyx":257
 *                                     mantissa = (source_row_data[index]
 *                                          * T_data[prev_state*N+state])
 *                                     partial_sum += mantissa             # <<<<<<<<<<<<<<
 *                                 if viterbi and mantissa > max_mantissa:
 *                                     max_mantissa = mantissa
 */
              __pyx_v_partial_sum = (__pyx_v_partial_sum + __pyx_v_mantissa);
            }
            __pyx_L46:;

            /* "cogent/align/_pairwise_seqs.pyx":258
 *                                          * T_data[prev_state*N+state])
 *                                     partial_sum += mantissa
 *                                 if viterbi and mantissa > max_mantissa:             # <<<<<<<<<<<<<<
 *                                     max_mantissa = mantissa
 *                                     pointer_state = prev_state
 */
            if (__pyx_v_viterbi) {
              __pyx_t_13 = (__pyx_v_mantissa > __pyx_v_max_mantissa);
              __pyx_t_6 = __pyx_t_13;
            } else {
              __pyx_t_6 = __pyx_v_viterbi;
            }
            if (__pyx_t_6) {

              /* "cogent/align/_pairwise_seqs.pyx":259
 *                                     partial_sum += mantissa
 *                                 if viterbi and mantissa > max_mantissa:
 *                                     max_mantissa = mantissa             # <<<<<<<<<<<<<<
 *                                     pointer_state = prev_state
 *                                     pointer_a = a
 */
              __pyx_v_max_mantissa = __pyx_v_mantissa;

              /* "cogent/align/_pairwise_seqs.pyx":260
 *                                 if viterbi and mantissa > max_mantissa:
 *                                     max_mantissa = mantissa
 *                                     pointer_state = prev_state             # <<<<<<<<<<<<<<
 *                                     pointer_a = a
 *                                     pointer_b = b
 */
              __pyx_v_pointer_state = __pyx_v_prev_state;

              /* "cogent/align/_pairwise_seqs.pyx":261
 *                                     max_mantissa = mantissa
 *                                     pointer_state = prev_state
 *                                     pointer_a = a             # <<<<<<<<<<<<<<
 *                                     pointer_b = b
 * 
 */
              __pyx_v_pointer_a = __pyx_v_a;

              /* "cogent/align/_pairwise_seqs.pyx":262
 *                                     pointer_state = prev_state
 *                                     pointer_a = a
 *                                     pointer_b = b             # <<<<<<<<<<<<<<
 * 
 *                 if viterbi:
 */
              __pyx_v_pointer_b = __pyx_v_b;
              goto __pyx_L47;
            }
            __pyx_L47:;
          }
        }
        __pyx_L28:;

        /* "cogent/align/_pairwise_seqs.pyx":264
 *                                     pointer_b = b
 * 
 *                 if viterbi:             # <<<<<<<<<<<<<<
 *                     mantissa = max_mantissa
 *                     if track_data:
 */
        if (__pyx_v_viterbi) {

          /* "cogent/align/_pairwise_seqs.pyx":265
 * 
 *                 if viterbi:
 *                     mantissa = max_mantissa             # <<<<<<<<<<<<<<
 *                     if track_data:
 *                         track_data[(i*row_length+j)*N+state] = (
 */
          __pyx_v_mantissa = __pyx_v_max_mantissa;

          /* "cogent/align/_pairwise_seqs.pyx":266
 *                 if viterbi:
 *                     mantissa = max_mantissa
 *                     if track_data:             # <<<<<<<<<<<<<<
 *                         track_data[(i*row_length+j)*N+state] = (
 *                             (pointer_a << tcode_x) |
 */
          __pyx_t_6 = (__pyx_v_track_data != 0);
          if (__pyx_t_6) {

            /* "cogent/align/_pairwise_seqs.pyx":267
 *                     mantissa = max_mantissa
 *                     if track_data:
 *                         track_data[(i*row_length+j)*N+state] = (             # <<<<<<<<<<<<<<
 *                             (pointer_a << tcode_x) |
 *                             (pointer_b << tcode_y) |
 */
            (__pyx_v_track_data[((((__pyx_v_i * __pyx_v_row_length) + __pyx_v_j) * __pyx_v_N) + __pyx_v_state)]) = (((__pyx_v_pointer_a << __pyx_v_tcode_x) | (__pyx_v_pointer_b << __pyx_v_tcode_y)) | (__pyx_v_pointer_state << __pyx_v_tcode_s));
            goto __pyx_L49;
          }
          __pyx_L49:;
          goto __pyx_L48;
        }
        /*else*/ {

          /* "cogent/align/_pairwise_seqs.pyx":272
 *                             (pointer_state << tcode_s))
 *                 else:
 *                     mantissa = partial_sum             # <<<<<<<<<<<<<<
 * 
 *                 if dy:
 */
          __pyx_v_mantissa = __pyx_v_partial_sum;
        }
        __pyx_L48:;

        /* "cogent/align/_pairwise_seqs.pyx":274
 *                     mantissa = partial_sum
 * 
 *                 if dy:             # <<<<<<<<<<<<<<
 *                     y = y_index[j]
 *                     if dx:
 */
        if (__pyx_v_dy) {

          /* "cogent/align/_pairwise_seqs.pyx":275
 * 
 *                 if dy:
 *                     y = y_index[j]             # <<<<<<<<<<<<<<
 *                     if dx:
 *                         d_score = match_score_data[((bin*max_x+x)*max_y)+y]
 */
          __pyx_v_y = (__pyx_v_y_index[__pyx_v_j]);

          /* "cogent/align/_pairwise_seqs.pyx":276
 *                 if dy:
 *                     y = y_index[j]
 *                     if dx:             # <<<<<<<<<<<<<<
 *                         d_score = match_score_data[((bin*max_x+x)*max_y)+y]
 *                     else:
 */
          if (__pyx_v_dx) {

            /* "cogent/align/_pairwise_seqs.pyx":277
 *                     y = y_index[j]
 *                     if dx:
 *                         d_score = match_score_data[((bin*max_x+x)*max_y)+y]             # <<<<<<<<<<<<<<
 *                     else:
 *                         d_score = ygap_score_data[bin*max_y+y]
 */
            __pyx_v_d_score = (__pyx_v_match_score_data[((((__pyx_v_bin * __pyx_v_max_x) + __pyx_v_x) * __pyx_v_max_y) + __pyx_v_y)]);
            goto __pyx_L51;
          }
          /*else*/ {

            /* "cogent/align/_pairwise_seqs.pyx":279
 *                         d_score = match_score_data[((bin*max_x+x)*max_y)+y]
 *                     else:
 *                         d_score = ygap_score_data[bin*max_y+y]             # <<<<<<<<<<<<<<
 *                 elif dx:
 *                     d_score = xgap_score_data[bin*max_x+x]
 */
            __pyx_v_d_score = (__pyx_v_ygap_score_data[((__pyx_v_bin * __pyx_v_max_y) + __pyx_v_y)]);
          }
          __pyx_L51:;
          goto __pyx_L50;
        }

        /* "cogent/align/_pairwise_seqs.pyx":280
 *                     else:
 *                         d_score = ygap_score_data[bin*max_y+y]
 *                 elif dx:             # <<<<<<<<<<<<<<
 *                     d_score = xgap_score_data[bin*max_x+x]
 *                 elif use_logs:
 */
        if (__pyx_v_dx) {

          /* "cogent/align/_pairwise_seqs.pyx":281
 *                         d_score = ygap_score_data[bin*max_y+y]
 *                 elif dx:
 *                     d_score = xgap_score_data[bin*max_x+x]             # <<<<<<<<<<<<<<
 *                 elif use_logs:
 *                     d_score = 0.0
 */
          __pyx_v_d_score = (__pyx_v_xgap_score_data[((__pyx_v_bin * __pyx_v_max_x) + __pyx_v_x)]);
          goto __pyx_L50;
        }

        /* "cogent/align/_pairwise_seqs.pyx":282
 *                 elif dx:
 *                     d_score = xgap_score_data[bin*max_x+x]
 *                 elif use_logs:             # <<<<<<<<<<<<<<
 *                     d_score = 0.0
 *                 else:
 */
        if (__pyx_v_use_logs) {

          /* "cogent/align/_pairwise_seqs.pyx":283
 *                     d_score = xgap_score_data[bin*max_x+x]
 *                 elif use_logs:
 *                     d_score = 0.0             # <<<<<<<<<<<<<<
 *                 else:
 *                     d_score = 1.0
 */
          __pyx_v_d_score = 0.0;
          goto __pyx_L50;
        }
        /*else*/ {

          /* "cogent/align/_pairwise_seqs.pyx":285
 *                     d_score = 0.0
 *                 else:
 *                     d_score = 1.0             # <<<<<<<<<<<<<<
 * 
 *                 if use_logs:
 */
          __pyx_v_d_score = 1.0;
        }
        __pyx_L50:;

        /* "cogent/align/_pairwise_seqs.pyx":287
 *                     d_score = 1.0
 * 
 *                 if use_logs:             # <<<<<<<<<<<<<<
 *                     mantissa += d_score
 *                 else:
 */
        if (__pyx_v_use_logs) {

          /* "cogent/align/_pairwise_seqs.pyx":288
 * 
 *                 if use_logs:
 *                     mantissa += d_score             # <<<<<<<<<<<<<<
 *                 else:
 *                     mantissa *= d_score
 */
          __pyx_v_mantissa = (__pyx_v_mantissa + __pyx_v_d_score);
          goto __pyx_L52;
        }
        /*else*/ {

          /* "cogent/align/_pairwise_seqs.pyx":290
 *                     mantissa += d_score
 *                 else:
 *                     mantissa *= d_score             # <<<<<<<<<<<<<<
 * 
 *                 current_row_data[j*N+state] = mantissa
 */
          __pyx_v_mantissa = (__pyx_v_mantissa * __pyx_v_d_score);
        }
        __pyx_L52:;

        /* "cogent/align/_pairwise_seqs.pyx":292
 *                     mantissa *= d_score
 * 
 *                 current_row_data[j*N+state] = mantissa             # <<<<<<<<<<<<<<
 *                 if use_scaling:
 *                     current_row_ex_data[j*N+state] = max_exponent
 */
        (__pyx_v_current_row_data[((__pyx_v_j * __pyx_v_N) + __pyx_v_state)]) = __pyx_v_mantissa;

        /* "cogent/align/_pairwise_seqs.pyx":293
 * 
 *                 current_row_data[j*N+state] = mantissa
 *                 if use_scaling:             # <<<<<<<<<<<<<<
 *                     current_row_ex_data[j*N+state] = max_exponent
 * 
 */
        if (__pyx_v_use_scaling) {

          /* "cogent/align/_pairwise_seqs.pyx":294
 *                 current_row_data[j*N+state] = mantissa
 *                 if use_scaling:
 *                     current_row_ex_data[j*N+state] = max_exponent             # <<<<<<<<<<<<<<
 * 
 *                 if local and dx and dy:
 */
          (__pyx_v_current_row_ex_data[((__pyx_v_j * __pyx_v_N) + __pyx_v_state)]) = __pyx_v_max_exponent;
          goto __pyx_L53;
        }
        __pyx_L53:;

        /* "cogent/align/_pairwise_seqs.pyx":296
 *                     current_row_ex_data[j*N+state] = max_exponent
 * 
 *                 if local and dx and dy:             # <<<<<<<<<<<<<<
 *                     if (use_scaling and max_exponent > overall_max_exponent) or (
 *                             (not use_scaling or max_exponent == overall_max_exponent) and (
 */
        if (__pyx_v_local) {
          if (__pyx_v_dx) {
            __pyx_t_6 = __pyx_v_dy;
          } else {
            __pyx_t_6 = __pyx_v_dx;
          }
          __pyx_t_13 = __pyx_t_6;
        } else {
          __pyx_t_13 = __pyx_v_local;
        }
        if (__pyx_t_13) {

          /* "cogent/align/_pairwise_seqs.pyx":297
 * 
 *                 if local and dx and dy:
 *                     if (use_scaling and max_exponent > overall_max_exponent) or (             # <<<<<<<<<<<<<<
 *                             (not use_scaling or max_exponent == overall_max_exponent) and (
 *                             mantissa > overall_max_mantissa)):
 */
          if (__pyx_v_use_scaling) {
            __pyx_t_13 = (__pyx_v_max_exponent > __pyx_v_overall_max_exponent);
            __pyx_t_6 = __pyx_t_13;
          } else {
            __pyx_t_6 = __pyx_v_use_scaling;
          }
          if (!__pyx_t_6) {

            /* "cogent/align/_pairwise_seqs.pyx":298
 *                 if local and dx and dy:
 *                     if (use_scaling and max_exponent > overall_max_exponent) or (
 *                             (not use_scaling or max_exponent == overall_max_exponent) and (             # <<<<<<<<<<<<<<
 *                             mantissa > overall_max_mantissa)):
 *                         overall_max_exponent = max_exponent
 */
            __pyx_t_13 = (!__pyx_v_use_scaling);
            if (!__pyx_t_13) {
              __pyx_t_12 = (__pyx_v_max_exponent == __pyx_v_overall_max_exponent);
              __pyx_t_5 = __pyx_t_12;
            } else {
              __pyx_t_5 = __pyx_t_13;
            }
            if (__pyx_t_5) {

              /* "cogent/align/_pairwise_seqs.pyx":299
 *                     if (use_scaling and max_exponent > overall_max_exponent) or (
 *                             (not use_scaling or max_exponent == overall_max_exponent) and (
 *                             mantissa > overall_max_mantissa)):             # <<<<<<<<<<<<<<
 *                         overall_max_exponent = max_exponent
 *                         overall_max_mantissa = mantissa
 */
              __pyx_t_13 = (__pyx_v_mantissa > __pyx_v_overall_max_mantissa);
              __pyx_t_12 = __pyx_t_13;
            } else {
              __pyx_t_12 = __pyx_t_5;
            }
            __pyx_t_5 = __pyx_t_12;
          } else {
            __pyx_t_5 = __pyx_t_6;
          }
          if (__pyx_t_5) {

            /* "cogent/align/_pairwise_seqs.pyx":300
 *                             (not use_scaling or max_exponent == overall_max_exponent) and (
 *                             mantissa > overall_max_mantissa)):
 *                         overall_max_exponent = max_exponent             # <<<<<<<<<<<<<<
 *                         overall_max_mantissa = mantissa
 *                         last_i = i
 */
            __pyx_v_overall_max_exponent = __pyx_v_max_exponent;

            /* "cogent/align/_pairwise_seqs.pyx":301
 *                             mantissa > overall_max_mantissa)):
 *                         overall_max_exponent = max_exponent
 *                         overall_max_mantissa = mantissa             # <<<<<<<<<<<<<<
 *                         last_i = i
 *                         last_j = j
 */
            __pyx_v_overall_max_mantissa = __pyx_v_mantissa;

            /* "cogent/align/_pairwise_seqs.pyx":302
 *                         overall_max_exponent = max_exponent
 *                         overall_max_mantissa = mantissa
 *                         last_i = i             # <<<<<<<<<<<<<<
 *                         last_j = j
 *                         last_state = state
 */
            __pyx_v_last_i = __pyx_v_i;

            /* "cogent/align/_pairwise_seqs.pyx":303
 *                         overall_max_mantissa = mantissa
 *                         last_i = i
 *                         last_j = j             # <<<<<<<<<<<<<<
 *                         last_state = state
 *     if not local:
 */
            __pyx_v_last_j = __pyx_v_j;

            /* "cogent/align/_pairwise_seqs.pyx":304
 *                         last_i = i
 *                         last_j = j
 *                         last_state = state             # <<<<<<<<<<<<<<
 *     if not local:
 *         last_i = i_high - 1
 */
            __pyx_v_last_state = __pyx_v_state;
            goto __pyx_L55;
          }
          __pyx_L55:;
          goto __pyx_L54;
        }
        __pyx_L54:;
        __pyx_L22_continue:;
      }
    }
  }

  /* "cogent/align/_pairwise_seqs.pyx":305
 *                         last_j = j
 *                         last_state = state
 *     if not local:             # <<<<<<<<<<<<<<
 *         last_i = i_high - 1
 *         last_j = j_high - 1
 */
  __pyx_t_5 = (!__pyx_v_local);
  if (__pyx_t_5) {

    /* "cogent/align/_pairwise_seqs.pyx":306
 *                         last_state = state
 *     if not local:
 *         last_i = i_high - 1             # <<<<<<<<<<<<<<
 *         last_j = j_high - 1
 *         last_state = state
 */
    __pyx_v_last_i = (__pyx_v_i_high - 1);

    /* "cogent/align/_pairwise_seqs.pyx":307
 *     if not local:
 *         last_i = i_high - 1
 *         last_j = j_high - 1             # <<<<<<<<<<<<<<
 *         last_state = state
 *     else:
 */
    __pyx_v_last_j = (__pyx_v_j_high - 1);

    /* "cogent/align/_pairwise_seqs.pyx":308
 *         last_i = i_high - 1
 *         last_j = j_high - 1
 *         last_state = state             # <<<<<<<<<<<<<<
 *     else:
 *         mantissa = overall_max_mantissa
 */
    __pyx_v_last_state = __pyx_v_state;
    goto __pyx_L56;
  }
  /*else*/ {

    /* "cogent/align/_pairwise_seqs.pyx":310
 *         last_state = state
 *     else:
 *         mantissa = overall_max_mantissa             # <<<<<<<<<<<<<<
 *         max_exponent = overall_max_exponent
 * 
 */
    __pyx_v_mantissa = __pyx_v_overall_max_mantissa;

    /* "cogent/align/_pairwise_seqs.pyx":311
 *     else:
 *         mantissa = overall_max_mantissa
 *         max_exponent = overall_max_exponent             # <<<<<<<<<<<<<<
 * 
 *     if use_scaling:
 */
    __pyx_v_max_exponent = __pyx_v_overall_max_exponent;
  }
  __pyx_L56:;

  /* "cogent/align/_pairwise_seqs.pyx":313
 *         max_exponent = overall_max_exponent
 * 
 *     if use_scaling:             # <<<<<<<<<<<<<<
 *         score = log(mantissa) + log(SCALE_STEP) * max_exponent
 *     elif use_logs:
 */
  if (__pyx_v_use_scaling) {

    /* "cogent/align/_pairwise_seqs.pyx":314
 * 
 *     if use_scaling:
 *         score = log(mantissa) + log(SCALE_STEP) * max_exponent             # <<<<<<<<<<<<<<
 *     elif use_logs:
 *         score = mantissa
 */
    __pyx_v_score = (log(__pyx_v_mantissa) + (log(__pyx_v_6cogent_5align_14_pairwise_seqs_SCALE_STEP) * __pyx_v_max_exponent));
    goto __pyx_L57;
  }

  /* "cogent/align/_pairwise_seqs.pyx":315
 *     if use_scaling:
 *         score = log(mantissa) + log(SCALE_STEP) * max_exponent
 *     elif use_logs:             # <<<<<<<<<<<<<<
 *         score = mantissa
 *     else:
 */
  if (__pyx_v_use_logs) {

    /* "cogent/align/_pairwise_seqs.pyx":316
 *         score = log(mantissa) + log(SCALE_STEP) * max_exponent
 *     elif use_logs:
 *         score = mantissa             # <<<<<<<<<<<<<<
 *     else:
 *         score = log(mantissa)
 */
    __pyx_v_score = __pyx_v_mantissa;
    goto __pyx_L57;
  }
  /*else*/ {

    /* "cogent/align/_pairwise_seqs.pyx":318
 *         score = mantissa
 *     else:
 *         score = log(mantissa)             # <<<<<<<<<<<<<<
 *     return ((last_i, last_j), last_state, score)
 */
    __pyx_v_score = log(__pyx_v_mantissa);
  }
  __pyx_L57:;

  /* "cogent/align/_pairwise_seqs.pyx":319
 *     else:
 *         score = log(mantissa)
 *     return ((last_i, last_j), last_state, score)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_last_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_last_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(__pyx_v_last_state); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_score); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_r = ((PyObject *)__pyx_t_15);
  __pyx_t_15 = 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_15);
  __Pyx_AddTraceback("cogent.align._pairwise_seqs.calc_rows", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_mantissas);
  __Pyx_XDECREF(__pyx_v_exponents);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("_pairwise_seqs"),
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
  {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
  {&__pyx_n_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 1},
  {&__pyx_n_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 1},
  {&__pyx_n_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 1},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
  {&__pyx_n_s__ArithmeticError, __pyx_k__ArithmeticError, sizeof(__pyx_k__ArithmeticError), 0, 0, 1, 1},
  {&__pyx_n_s__N, __pyx_k__N, sizeof(__pyx_k__N), 0, 0, 1, 1},
  {&__pyx_n_s__T, __pyx_k__T, sizeof(__pyx_k__T), 0, 0, 1, 1},
  {&__pyx_n_s__T_data, __pyx_k__T_data, sizeof(__pyx_k__T_data), 0, 0, 1, 1},
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s____array_struct__, __pyx_k____array_struct__, sizeof(__pyx_k____array_struct__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s____version__, __pyx_k____version__, sizeof(__pyx_k____version__), 0, 0, 1, 1},
  {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
  {&__pyx_n_s__a_count, __pyx_k__a_count, sizeof(__pyx_k__a_count), 0, 0, 1, 1},
  {&__pyx_n_s__a_high, __pyx_k__a_high, sizeof(__pyx_k__a_high), 0, 0, 1, 1},
  {&__pyx_n_s__a_low, __pyx_k__a_low, sizeof(__pyx_k__a_low), 0, 0, 1, 1},
  {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1},
  {&__pyx_n_s__b_count, __pyx_k__b_count, sizeof(__pyx_k__b_count), 0, 0, 1, 1},
  {&__pyx_n_s__b_high, __pyx_k__b_high, sizeof(__pyx_k__b_high), 0, 0, 1, 1},
  {&__pyx_n_s__b_low, __pyx_k__b_low, sizeof(__pyx_k__b_low), 0, 0, 1, 1},
  {&__pyx_n_s__bin, __pyx_k__bin, sizeof(__pyx_k__bin), 0, 0, 1, 1},
  {&__pyx_n_s__bin_count, __pyx_k__bin_count, sizeof(__pyx_k__bin_count), 0, 0, 1, 1},
  {&__pyx_n_s__calc_rows, __pyx_k__calc_rows, sizeof(__pyx_k__calc_rows), 0, 0, 1, 1},
  {&__pyx_n_s__chr, __pyx_k__chr, sizeof(__pyx_k__chr), 0, 0, 1, 1},
  {&__pyx_n_s__current_row_data, __pyx_k__current_row_data, sizeof(__pyx_k__current_row_data), 0, 0, 1, 1},
  {&__pyx_n_s__current_row_ex_data, __pyx_k__current_row_ex_data, sizeof(__pyx_k__current_row_ex_data), 0, 0, 1, 1},
  {&__pyx_n_s__d4, __pyx_k__d4, sizeof(__pyx_k__d4), 0, 0, 1, 1},
  {&__pyx_n_s__d_score, __pyx_k__d_score, sizeof(__pyx_k__d_score), 0, 0, 1, 1},
  {&__pyx_n_s__dest_state, __pyx_k__dest_state, sizeof(__pyx_k__dest_state), 0, 0, 1, 1},
  {&__pyx_n_s__dest_states, __pyx_k__dest_states, sizeof(__pyx_k__dest_states), 0, 0, 1, 1},
  {&__pyx_n_s__dest_states_data, __pyx_k__dest_states_data, sizeof(__pyx_k__dest_states_data), 0, 0, 1, 1},
  {&__pyx_n_s__dx, __pyx_k__dx, sizeof(__pyx_k__dx), 0, 0, 1, 1},
  {&__pyx_n_s__dy, __pyx_k__dy, sizeof(__pyx_k__dy), 0, 0, 1, 1},
  {&__pyx_n_s__exponent, __pyx_k__exponent, sizeof(__pyx_k__exponent), 0, 0, 1, 1},
  {&__pyx_n_s__exponents, __pyx_k__exponents, sizeof(__pyx_k__exponents), 0, 0, 1, 1},
  {&__pyx_n_s__fmpt, __pyx_k__fmpt, sizeof(__pyx_k__fmpt), 0, 0, 1, 1},
  {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1},
  {&__pyx_n_s__i_high, __pyx_k__i_high, sizeof(__pyx_k__i_high), 0, 0, 1, 1},
  {&__pyx_n_s__i_low, __pyx_k__i_low, sizeof(__pyx_k__i_low), 0, 0, 1, 1},
  {&__pyx_n_s__i_sources, __pyx_k__i_sources, sizeof(__pyx_k__i_sources), 0, 0, 1, 1},
  {&__pyx_n_s__impossible, __pyx_k__impossible, sizeof(__pyx_k__impossible), 0, 0, 1, 1},
  {&__pyx_n_s__index, __pyx_k__index, sizeof(__pyx_k__index), 0, 0, 1, 1},
  {&__pyx_n_s__j, __pyx_k__j, sizeof(__pyx_k__j), 0, 0, 1, 1},
  {&__pyx_n_s__j_high, __pyx_k__j_high, sizeof(__pyx_k__j_high), 0, 0, 1, 1},
  {&__pyx_n_s__j_low, __pyx_k__j_low, sizeof(__pyx_k__j_low), 0, 0, 1, 1},
  {&__pyx_n_s__j_sources, __pyx_k__j_sources, sizeof(__pyx_k__j_sources), 0, 0, 1, 1},
  {&__pyx_n_s__last_i, __pyx_k__last_i, sizeof(__pyx_k__last_i), 0, 0, 1, 1},
  {&__pyx_n_s__last_j, __pyx_k__last_j, sizeof(__pyx_k__last_j), 0, 0, 1, 1},
  {&__pyx_n_s__last_state, __pyx_k__last_state, sizeof(__pyx_k__last_state), 0, 0, 1, 1},
  {&__pyx_n_s__local, __pyx_k__local, sizeof(__pyx_k__local), 0, 0, 1, 1},
  {&__pyx_n_s__mantissa, __pyx_k__mantissa, sizeof(__pyx_k__mantissa), 0, 0, 1, 1},
  {&__pyx_n_s__mantissas, __pyx_k__mantissas, sizeof(__pyx_k__mantissas), 0, 0, 1, 1},
  {&__pyx_n_s__match_score_data, __pyx_k__match_score_data, sizeof(__pyx_k__match_score_data), 0, 0, 1, 1},
  {&__pyx_n_s__match_scores, __pyx_k__match_scores, sizeof(__pyx_k__match_scores), 0, 0, 1, 1},
  {&__pyx_n_s__max_exponent, __pyx_k__max_exponent, sizeof(__pyx_k__max_exponent), 0, 0, 1, 1},
  {&__pyx_n_s__max_mantissa, __pyx_k__max_mantissa, sizeof(__pyx_k__max_mantissa), 0, 0, 1, 1},
  {&__pyx_n_s__max_x, __pyx_k__max_x, sizeof(__pyx_k__max_x), 0, 0, 1, 1},
  {&__pyx_n_s__max_y, __pyx_k__max_y, sizeof(__pyx_k__max_y), 0, 0, 1, 1},
  {&__pyx_n_s__msg, __pyx_k__msg, sizeof(__pyx_k__msg), 0, 0, 1, 1},
  {&__pyx_n_s__partial_sum, __pyx_k__partial_sum, sizeof(__pyx_k__partial_sum), 0, 0, 1, 1},
  {&__pyx_n_s__plan, __pyx_k__plan, sizeof(__pyx_k__plan), 0, 0, 1, 1},
  {&__pyx_n_s__plan_data, __pyx_k__plan_data, sizeof(__pyx_k__plan_data), 0, 0, 1, 1},
  {&__pyx_n_s__plan_index, __pyx_k__plan_index, sizeof(__pyx_k__plan_index), 0, 0, 1, 1},
  {&__pyx_n_s__plan_index1, __pyx_k__plan_index1, sizeof(__pyx_k__plan_index1), 0, 0, 1, 1},
  {&__pyx_n_s__plan_index2, __pyx_k__plan_index2, sizeof(__pyx_k__plan_index2), 0, 0, 1, 1},
  {&__pyx_n_s__pointer_a, __pyx_k__pointer_a, sizeof(__pyx_k__pointer_a), 0, 0, 1, 1},
  {&__pyx_n_s__pointer_b, __pyx_k__pointer_b, sizeof(__pyx_k__pointer_b), 0, 0, 1, 1},
  {&__pyx_n_s__pointer_state, __pyx_k__pointer_state, sizeof(__pyx_k__pointer_state), 0, 0, 1, 1},
  {&__pyx_n_s__preds, __pyx_k__preds, sizeof(__pyx_k__preds), 0, 0, 1, 1},
  {&__pyx_n_s__prev_i, __pyx_k__prev_i, sizeof(__pyx_k__prev_i), 0, 0, 1, 1},
  {&__pyx_n_s__prev_j, __pyx_k__prev_j, sizeof(__pyx_k__prev_j), 0, 0, 1, 1},
  {&__pyx_n_s__prev_row_data, __pyx_k__prev_row_data, sizeof(__pyx_k__prev_row_data), 0, 0, 1, 1},
  {&__pyx_n_s__prev_row_ex_data, __pyx_k__prev_row_ex_data, sizeof(__pyx_k__prev_row_ex_data), 0, 0, 1, 1},
  {&__pyx_n_s__prev_state, __pyx_k__prev_state, sizeof(__pyx_k__prev_state), 0, 0, 1, 1},
  {&__pyx_n_s__row_count, __pyx_k__row_count, sizeof(__pyx_k__row_count), 0, 0, 1, 1},
  {&__pyx_n_s__row_length, __pyx_k__row_length, sizeof(__pyx_k__row_length), 0, 0, 1, 1},
  {&__pyx_n_s__row_length1, __pyx_k__row_length1, sizeof(__pyx_k__row_length1), 0, 0, 1, 1},
  {&__pyx_n_s__rows, __pyx_k__rows, sizeof(__pyx_k__rows), 0, 0, 1, 1},
  {&__pyx_n_s__score, __pyx_k__score, sizeof(__pyx_k__score), 0, 0, 1, 1},
  {&__pyx_n_s__seq1_index, __pyx_k__seq1_index, sizeof(__pyx_k__seq1_index), 0, 0, 1, 1},
  {&__pyx_n_s__seq2_index, __pyx_k__seq2_index, sizeof(__pyx_k__seq2_index), 0, 0, 1, 1},
  {&__pyx_n_s__source_i, __pyx_k__source_i, sizeof(__pyx_k__source_i), 0, 0, 1, 1},
  {&__pyx_n_s__source_row_data, __pyx_k__source_row_data, sizeof(__pyx_k__source_row_data), 0, 0, 1, 1},
  {&__pyx_n_s__source_row_ex_data, __pyx_k__source_row_ex_data, sizeof(__pyx_k__source_row_ex_data), 0, 0, 1, 1},
  {&__pyx_n_s__state, __pyx_k__state, sizeof(__pyx_k__state), 0, 0, 1, 1},
  {&__pyx_n_s__state_directions, __pyx_k__state_directions, sizeof(__pyx_k__state_directions), 0, 0, 1, 1},
  {&__pyx_n_s__sub_partial_sum, __pyx_k__sub_partial_sum, sizeof(__pyx_k__sub_partial_sum), 0, 0, 1, 1},
  {&__pyx_n_s__tcode_s, __pyx_k__tcode_s, sizeof(__pyx_k__tcode_s), 0, 0, 1, 1},
  {&__pyx_n_s__tcode_x, __pyx_k__tcode_x, sizeof(__pyx_k__tcode_x), 0, 0, 1, 1},
  {&__pyx_n_s__tcode_y, __pyx_k__tcode_y, sizeof(__pyx_k__tcode_y), 0, 0, 1, 1},
  {&__pyx_n_s__track, __pyx_k__track, sizeof(__pyx_k__track), 0, 0, 1, 1},
  {&__pyx_n_s__track_data, __pyx_k__track_data, sizeof(__pyx_k__track_data), 0, 0, 1, 1},
  {&__pyx_n_s__track_enc, __pyx_k__track_enc, sizeof(__pyx_k__track_enc), 0, 0, 1, 1},
  {&__pyx_n_s__underflows, __pyx_k__underflows, sizeof(__pyx_k__underflows), 0, 0, 1, 1},
  {&__pyx_n_s__use_logs, __pyx_k__use_logs, sizeof(__pyx_k__use_logs), 0, 0, 1, 1},
  {&__pyx_n_s__use_scaling, __pyx_k__use_scaling, sizeof(__pyx_k__use_scaling), 0, 0, 1, 1},
  {&__pyx_n_s__version_info, __pyx_k__version_info, sizeof(__pyx_k__version_info), 0, 0, 1, 1},
  {&__pyx_n_s__viterbi, __pyx_k__viterbi, sizeof(__pyx_k__viterbi), 0, 0, 1, 1},
  {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1},
  {&__pyx_n_s__x_index, __pyx_k__x_index, sizeof(__pyx_k__x_index), 0, 0, 1, 1},
  {&__pyx_n_s__xgap_score_data, __pyx_k__xgap_score_data, sizeof(__pyx_k__xgap_score_data), 0, 0, 1, 1},
  {&__pyx_n_s__xgap_scores, __pyx_k__xgap_scores, sizeof(__pyx_k__xgap_scores), 0, 0, 1, 1},
  {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1},
  {&__pyx_n_s__y_index, __pyx_k__y_index, sizeof(__pyx_k__y_index), 0, 0, 1, 1},
  {&__pyx_n_s__ygap_score_data, __pyx_k__ygap_score_data, sizeof(__pyx_k__ygap_score_data), 0, 0, 1, 1},
  {&__pyx_n_s__ygap_scores, __pyx_k__ygap_scores, sizeof(__pyx_k__ygap_scores), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_chr = __Pyx_GetName(__pyx_b, __pyx_n_s__chr); if (!__pyx_builtin_chr) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ArithmeticError = __Pyx_GetName(__pyx_b, __pyx_n_s__ArithmeticError); if (!__pyx_builtin_ArithmeticError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __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);

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":44
 *     cdef char kind
 *     if A is None:
 *         raise TypeError("Array required, got None")             # <<<<<<<<<<<<<<
 *     cobj = A.__array_struct__
 *     a = <PyArrayInterface *> PyCObject_AsVoidPtr(cobj)
 */
  __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_2);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
  PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_kp_s_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":62
 *                 (nd, a.nd))
 *     if not a.flags & CONTIGUOUS:
 *         raise ValueError ('Noncontiguous array')             # <<<<<<<<<<<<<<
 * 
 *     cdef int dimension, val
 */
  __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_8);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
  PyTuple_SET_ITEM(__pyx_k_tuple_8, 0, ((PyObject *)__pyx_kp_s_7));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8));

  /* "cogent/align/_pairwise_seqs.pyx":13
 *     double log (double x)
 * 
 * version_info = (3, 1)             # <<<<<<<<<<<<<<
 * __version__ = "('1', '5', '3')"
 * 
 */
  __pyx_k_tuple_16 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_16)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_16);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_k_tuple_16, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_k_tuple_16, 1, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_16));

  /* "cogent/align/_pairwise_seqs.pyx":36
 *     return <unsigned char *> checkArray3D(a, c'i', sizeof(char), x, y, z)
 * 
 * def fmpt(mantissa, exponent, msg=''):             # <<<<<<<<<<<<<<
 *     return "%s * SCALE_STEP ** %s %s" % (mantissa, exponent, msg)
 * 
 */
  __pyx_k_tuple_17 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_17);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__mantissa));
  PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_n_s__mantissa));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mantissa));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__exponent));
  PyTuple_SET_ITEM(__pyx_k_tuple_17, 1, ((PyObject *)__pyx_n_s__exponent));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__exponent));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__msg));
  PyTuple_SET_ITEM(__pyx_k_tuple_17, 2, ((PyObject *)__pyx_n_s__msg));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__msg));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17));
  __pyx_k_codeobj_18 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_19, __pyx_n_s__fmpt, 36, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_18)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cogent/align/_pairwise_seqs.pyx":39
 *     return "%s * SCALE_STEP ** %s %s" % (mantissa, exponent, msg)
 * 
 * def calc_rows(ArrayType plan, ArrayType seq1_index, ArrayType seq2_index,             # <<<<<<<<<<<<<<
 *         int i_low, int i_high, int j_low, int j_high, preds,
 *         ArrayType state_directions, ArrayType T,
 */
  __pyx_k_tuple_23 = PyTuple_New(93); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_23);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__plan));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 0, ((PyObject *)__pyx_n_s__plan));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__plan));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__seq1_index));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 1, ((PyObject *)__pyx_n_s__seq1_index));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__seq1_index));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__seq2_index));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 2, ((PyObject *)__pyx_n_s__seq2_index));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__seq2_index));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i_low));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 3, ((PyObject *)__pyx_n_s__i_low));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i_low));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i_high));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 4, ((PyObject *)__pyx_n_s__i_high));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i_high));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__j_low));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 5, ((PyObject *)__pyx_n_s__j_low));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__j_low));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__j_high));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 6, ((PyObject *)__pyx_n_s__j_high));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__j_high));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__preds));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 7, ((PyObject *)__pyx_n_s__preds));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__preds));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__state_directions));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 8, ((PyObject *)__pyx_n_s__state_directions));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__state_directions));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__T));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 9, ((PyObject *)__pyx_n_s__T));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__T));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__xgap_scores));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 10, ((PyObject *)__pyx_n_s__xgap_scores));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__xgap_scores));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__ygap_scores));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 11, ((PyObject *)__pyx_n_s__ygap_scores));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ygap_scores));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__match_scores));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 12, ((PyObject *)__pyx_n_s__match_scores));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__match_scores));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__rows));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 13, ((PyObject *)__pyx_n_s__rows));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rows));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__track));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 14, ((PyObject *)__pyx_n_s__track));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__track));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__track_enc));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 15, ((PyObject *)__pyx_n_s__track_enc));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__track_enc));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__viterbi));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 16, ((PyObject *)__pyx_n_s__viterbi));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__viterbi));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__use_logs));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 17, ((PyObject *)__pyx_n_s__use_logs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__use_logs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__local));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 18, ((PyObject *)__pyx_n_s__local));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__local));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__use_scaling));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 19, ((PyObject *)__pyx_n_s__use_scaling));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__use_scaling));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dx));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 20, ((PyObject *)__pyx_n_s__dx));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dx));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dy));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 21, ((PyObject *)__pyx_n_s__dy));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dy));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__prev_i));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 22, ((PyObject *)__pyx_n_s__prev_i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__prev_i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__prev_j));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 23, ((PyObject *)__pyx_n_s__prev_j));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__prev_j));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__state));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 24, ((PyObject *)__pyx_n_s__state));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__state));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__prev_state));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 25, ((PyObject *)__pyx_n_s__prev_state));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__prev_state));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__N));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 26, ((PyObject *)__pyx_n_s__N));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__N));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__row_length));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 27, ((PyObject *)__pyx_n_s__row_length));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__row_length));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__a_count));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 28, ((PyObject *)__pyx_n_s__a_count));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__a_count));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__b_count));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 29, ((PyObject *)__pyx_n_s__b_count));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b_count));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__a));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 30, ((PyObject *)__pyx_n_s__a));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__a));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__b));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 31, ((PyObject *)__pyx_n_s__b));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__a_low));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 32, ((PyObject *)__pyx_n_s__a_low));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__a_low));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__a_high));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 33, ((PyObject *)__pyx_n_s__a_high));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__a_high));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__b_low));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 34, ((PyObject *)__pyx_n_s__b_low));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b_low));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__b_high));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 35, ((PyObject *)__pyx_n_s__b_high));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b_high));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dest_states));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 36, ((PyObject *)__pyx_n_s__dest_states));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dest_states));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dest_state));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 37, ((PyObject *)__pyx_n_s__dest_state));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dest_state));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__d4));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 38, ((PyObject *)__pyx_n_s__d4));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__d4));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__j));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 39, ((PyObject *)__pyx_n_s__j));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__j));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 40, ((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__source_i));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 41, ((PyObject *)__pyx_n_s__source_i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__source_i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__last_i));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 42, ((PyObject *)__pyx_n_s__last_i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__last_i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__last_j));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 43, ((PyObject *)__pyx_n_s__last_j));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__last_j));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__last_state));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 44, ((PyObject *)__pyx_n_s__last_state));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__last_state));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_21));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 45, ((PyObject *)__pyx_n_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_21));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__tcode_x));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 46, ((PyObject *)__pyx_n_s__tcode_x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tcode_x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__tcode_y));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 47, ((PyObject *)__pyx_n_s__tcode_y));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tcode_y));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__tcode_s));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 48, ((PyObject *)__pyx_n_s__tcode_s));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tcode_s));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__track_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 49, ((PyObject *)__pyx_n_s__track_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__track_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_22));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 50, ((PyObject *)__pyx_n_s_22));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_22));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__d_score));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 51, ((PyObject *)__pyx_n_s__d_score));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__d_score));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__mantissa));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 52, ((PyObject *)__pyx_n_s__mantissa));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mantissa));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__partial_sum));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 53, ((PyObject *)__pyx_n_s__partial_sum));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__partial_sum));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__sub_partial_sum));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 54, ((PyObject *)__pyx_n_s__sub_partial_sum));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sub_partial_sum));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__max_mantissa));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 55, ((PyObject *)__pyx_n_s__max_mantissa));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__max_mantissa));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__exponent));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 56, ((PyObject *)__pyx_n_s__exponent));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__exponent));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__index));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 57, ((PyObject *)__pyx_n_s__index));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__index));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__max_exponent));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 58, ((PyObject *)__pyx_n_s__max_exponent));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__max_exponent));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__source_row_ex_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 59, ((PyObject *)__pyx_n_s__source_row_ex_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__source_row_ex_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__T_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 60, ((PyObject *)__pyx_n_s__T_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__T_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__source_row_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 61, ((PyObject *)__pyx_n_s__source_row_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__source_row_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__match_score_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 62, ((PyObject *)__pyx_n_s__match_score_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__match_score_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dest_states_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 63, ((PyObject *)__pyx_n_s__dest_states_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dest_states_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__plan_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 64, ((PyObject *)__pyx_n_s__plan_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__plan_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i_sources));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 65, ((PyObject *)__pyx_n_s__i_sources));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i_sources));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__j_sources));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 66, ((PyObject *)__pyx_n_s__j_sources));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__j_sources));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__current_row_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 67, ((PyObject *)__pyx_n_s__current_row_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__current_row_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__prev_row_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 68, ((PyObject *)__pyx_n_s__prev_row_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__prev_row_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__current_row_ex_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 69, ((PyObject *)__pyx_n_s__current_row_ex_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__current_row_ex_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__prev_row_ex_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 70, ((PyObject *)__pyx_n_s__prev_row_ex_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__prev_row_ex_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pointer_a));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 71, ((PyObject *)__pyx_n_s__pointer_a));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pointer_a));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pointer_b));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 72, ((PyObject *)__pyx_n_s__pointer_b));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pointer_b));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pointer_state));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 73, ((PyObject *)__pyx_n_s__pointer_state));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pointer_state));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__x_index));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 74, ((PyObject *)__pyx_n_s__x_index));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__x_index));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__y_index));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 75, ((PyObject *)__pyx_n_s__y_index));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_index));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__x));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 76, ((PyObject *)__pyx_n_s__x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__y));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 77, ((PyObject *)__pyx_n_s__y));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__max_x));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 78, ((PyObject *)__pyx_n_s__max_x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__max_x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__max_y));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 79, ((PyObject *)__pyx_n_s__max_y));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__max_y));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__row_count));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 80, ((PyObject *)__pyx_n_s__row_count));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__row_count));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__row_length1));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 81, ((PyObject *)__pyx_n_s__row_length1));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__row_length1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__plan_index));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 82, ((PyObject *)__pyx_n_s__plan_index));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__plan_index));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__plan_index2));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 83, ((PyObject *)__pyx_n_s__plan_index2));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__plan_index2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__mantissas));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 84, ((PyObject *)__pyx_n_s__mantissas));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mantissas));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__exponents));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 85, ((PyObject *)__pyx_n_s__exponents));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__exponents));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__bin_count));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 86, ((PyObject *)__pyx_n_s__bin_count));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bin_count));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__bin));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 87, ((PyObject *)__pyx_n_s__bin));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bin));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__xgap_score_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 88, ((PyObject *)__pyx_n_s__xgap_score_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__xgap_score_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__ygap_score_data));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 89, ((PyObject *)__pyx_n_s__ygap_score_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ygap_score_data));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__impossible));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 90, ((PyObject *)__pyx_n_s__impossible));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__impossible));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__plan_index1));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 91, ((PyObject *)__pyx_n_s__plan_index1));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__plan_index1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__score));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 92, ((PyObject *)__pyx_n_s__score));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__score));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23));
  __pyx_k_codeobj_24 = (PyObject*)__Pyx_PyCode_New(20, 0, 93, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_19, __pyx_n_s__calc_rows, 39, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_24)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __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[1]; __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[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_pairwise_seqs(void); /*proto*/
PyMODINIT_FUNC init_pairwise_seqs(void)
#else
PyMODINIT_FUNC PyInit__pairwise_seqs(void); /*proto*/
PyMODINIT_FUNC PyInit__pairwise_seqs(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  __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__pairwise_seqs(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[1]; __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[1]; __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[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[1]; __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("_pairwise_seqs"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_cogent__align___pairwise_seqs) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  /*--- Type import code ---*/
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "/Users/jrideout/.virtualenvs/pycogent/trunk/include/numerical_pyrex.pyx":13
 * #
 * 
 * __version__ = "('1', '5', '3')"             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "Python.h":
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____version__, ((PyObject *)__pyx_kp_s_15)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cogent/align/_pairwise_seqs.pyx":10
 *     double Py_HUGE_VAL
 * 
 * cdef extern from "math.h":             # <<<<<<<<<<<<<<
 *     double log (double x)
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__version_info, ((PyObject *)__pyx_k_tuple_16)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cogent/align/_pairwise_seqs.pyx":14
 * 
 * version_info = (3, 1)
 * __version__ = "('1', '5', '3')"             # <<<<<<<<<<<<<<
 * 
 * cdef double SCALE_STEP, MIN_FLOAT_VALUE
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____version__, ((PyObject *)__pyx_kp_s_15)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cogent/align/_pairwise_seqs.pyx":17
 * 
 * cdef double SCALE_STEP, MIN_FLOAT_VALUE
 * SCALE_STEP = 2.0**50             # <<<<<<<<<<<<<<
 * MIN_FLOAT_VALUE = 1.0 / SCALE_STEP
 * 
 */
  __pyx_v_6cogent_5align_14_pairwise_seqs_SCALE_STEP = pow(2.0, 50.0);

  /* "cogent/align/_pairwise_seqs.pyx":18
 * cdef double SCALE_STEP, MIN_FLOAT_VALUE
 * SCALE_STEP = 2.0**50
 * MIN_FLOAT_VALUE = 1.0 / SCALE_STEP             # <<<<<<<<<<<<<<
 * 
 * cdef int MAX_XCOUNT
 */
  if (unlikely(__pyx_v_6cogent_5align_14_pairwise_seqs_SCALE_STEP == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_FLOAT_VALUE = (1.0 / __pyx_v_6cogent_5align_14_pairwise_seqs_SCALE_STEP);

  /* "cogent/align/_pairwise_seqs.pyx":21
 * 
 * cdef int MAX_XCOUNT
 * MAX_XCOUNT = 256             # <<<<<<<<<<<<<<
 * 
 * cdef long MIN_SCALE, MAX_SCALE
 */
  __pyx_v_6cogent_5align_14_pairwise_seqs_MAX_XCOUNT = 256;

  /* "cogent/align/_pairwise_seqs.pyx":24
 * 
 * cdef long MIN_SCALE, MAX_SCALE
 * MIN_SCALE = -10000             # <<<<<<<<<<<<<<
 * MAX_SCALE = +10000  # or 0 if all numbers should be probabilities
 * 
 */
  __pyx_v_6cogent_5align_14_pairwise_seqs_MIN_SCALE = -10000;

  /* "cogent/align/_pairwise_seqs.pyx":25
 * cdef long MIN_SCALE, MAX_SCALE
 * MIN_SCALE = -10000
 * MAX_SCALE = +10000  # or 0 if all numbers should be probabilities             # <<<<<<<<<<<<<<
 * 
 * #cdef unsigned long * checkArrayULong3D(ArrayType a, int *x, int *y, int *z) except NULL:
 */
  __pyx_v_6cogent_5align_14_pairwise_seqs_MAX_SCALE = 10000;

  /* "cogent/align/_pairwise_seqs.pyx":36
 *     return <unsigned char *> checkArray3D(a, c'i', sizeof(char), x, y, z)
 * 
 * def fmpt(mantissa, exponent, msg=''):             # <<<<<<<<<<<<<<
 *     return "%s * SCALE_STEP ** %s %s" % (mantissa, exponent, msg)
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6cogent_5align_14_pairwise_seqs_1fmpt, NULL, __pyx_n_s_20); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__fmpt, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cogent/align/_pairwise_seqs.pyx":39
 *     return "%s * SCALE_STEP ** %s %s" % (mantissa, exponent, msg)
 * 
 * def calc_rows(ArrayType plan, ArrayType seq1_index, ArrayType seq2_index,             # <<<<<<<<<<<<<<
 *         int i_low, int i_high, int j_low, int j_high, preds,
 *         ArrayType state_directions, ArrayType T,
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6cogent_5align_14_pairwise_seqs_3calc_rows, NULL, __pyx_n_s_20); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__calc_rows, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cogent/align/_pairwise_seqs.pyx":1
 * include "numerical_pyrex.pyx"             # <<<<<<<<<<<<<<
 * 
 * # The weird indentation in this file is to match the POG version.
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[1]; __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 cogent.align._pairwise_seqs", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init cogent.align._pairwise_seqs");
  }
  __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_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result) {
        if (dict != __pyx_b) {
            PyErr_Clear();
            result = PyObject_GetAttr(__pyx_b, name);
        }
        if (!result) {
            PyErr_SetObject(PyExc_NameError, name);
        }
    }
    return result;
}

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);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        Py_DECREF(value);
        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) {
    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)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        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;
        }
        if (!value) {
            value = PyObject_CallObject(type, NULL);
        }
        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:
    return;
}
#endif

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

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_AS_STRING(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;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    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_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %"PY_FORMAT_SIZE_T"d value%s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %"PY_FORMAT_SIZE_T"d)", expected);
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else if (PyErr_Occurred()) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
}



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

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_VERSION_HEX < 0x03000000
    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 (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 {
            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;
    }
}

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_VERSION_HEX < 0x03000000
    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 (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 {
            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;
    }
}

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_VERSION_HEX < 0x03000000
    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 (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 {
            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;
    }
}

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_VERSION_HEX < 0x03000000
    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 (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 {
            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;
    }
}

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_VERSION_HEX < 0x03000000
    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 (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 {
            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;
    }
}

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_VERSION_HEX < 0x03000000
    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 (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 {
            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 void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static 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;
}


/* Type Conversion Functions */

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_VERSION_HEX < 0x03000000
  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_VERSION_HEX < 0x03000000
  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_VERSION_HEX < 0x03000000
    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)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
