/* Generated by Cython 0.12.1 on Thu Nov 25 11:38:16 2010 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#else

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#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)   PyInt_AsLong(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)
#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)

#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#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_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyString_Type                PyUnicode_Type
  #define PyString_CheckExact          PyUnicode_CheckExact
#else
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_CheckExact           PyString_CheckExact
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)

#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#else
  #define _USE_MATH_DEFINES
#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
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#define __PYX_HAVE_API__cogent__align___pairwise_pogs
#include "array_interface.h"
#include "math.h"

#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #else
    #define CYTHON_INLINE 
  #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 */

#if PY_MAJOR_VERSION < 3
#define __Pyx_PyBytes_FromString          PyString_FromString
#define __Pyx_PyBytes_FromStringAndSize   PyString_FromStringAndSize
#define __Pyx_PyBytes_AsString            PyString_AsString
#else
#define __Pyx_PyBytes_FromString          PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize   PyBytes_FromStringAndSize
#define __Pyx_PyBytes_AsString            PyBytes_AsString
#endif

#define __Pyx_PyBytes_FromUString(s)      __Pyx_PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)        ((unsigned char*) __Pyx_PyBytes_AsString(s))

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

#if !defined(T_PYSSIZET)
#if PY_VERSION_HEX < 0x02050000
#define T_PYSSIZET T_INT
#elif !defined(T_LONGLONG)
#define T_PYSSIZET \
        ((sizeof(Py_ssize_t) == sizeof(int))  ? T_INT  : \
        ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1))
#else
#define T_PYSSIZET \
        ((sizeof(Py_ssize_t) == sizeof(int))          ? T_INT      : \
        ((sizeof(Py_ssize_t) == sizeof(long))         ? T_LONG     : \
        ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))
#endif
#endif


#if !defined(T_ULONGLONG)
#define __Pyx_T_UNSIGNED_INT(x) \
        ((sizeof(x) == sizeof(unsigned char))  ? T_UBYTE : \
        ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \
        ((sizeof(x) == sizeof(unsigned int))   ? T_UINT : \
        ((sizeof(x) == sizeof(unsigned long))  ? T_ULONG : -1))))
#else
#define __Pyx_T_UNSIGNED_INT(x) \
        ((sizeof(x) == sizeof(unsigned char))  ? T_UBYTE : \
        ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \
        ((sizeof(x) == sizeof(unsigned int))   ? T_UINT : \
        ((sizeof(x) == sizeof(unsigned long))  ? T_ULONG : \
        ((sizeof(x) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))))
#endif
#if !defined(T_LONGLONG)
#define __Pyx_T_SIGNED_INT(x) \
        ((sizeof(x) == sizeof(char))  ? T_BYTE : \
        ((sizeof(x) == sizeof(short)) ? T_SHORT : \
        ((sizeof(x) == sizeof(int))   ? T_INT : \
        ((sizeof(x) == sizeof(long))  ? T_LONG : -1))))
#else
#define __Pyx_T_SIGNED_INT(x) \
        ((sizeof(x) == sizeof(char))  ? T_BYTE : \
        ((sizeof(x) == sizeof(short)) ? T_SHORT : \
        ((sizeof(x) == sizeof(int))   ? T_INT : \
        ((sizeof(x) == sizeof(long))  ? T_LONG : \
        ((sizeof(x) == sizeof(PY_LONG_LONG))   ? T_LONGLONG : -1)))))
#endif

#define __Pyx_T_FLOATING(x) \
        ((sizeof(x) == sizeof(float)) ? T_FLOAT : \
        ((sizeof(x) == sizeof(double)) ? T_DOUBLE : -1))

#if !defined(T_SIZET)
#if !defined(T_ULONGLONG)
#define T_SIZET \
        ((sizeof(size_t) == sizeof(unsigned int))  ? T_UINT  : \
        ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1))
#else
#define T_SIZET \
        ((sizeof(size_t) == sizeof(unsigned int))          ? T_UINT      : \
        ((sizeof(size_t) == sizeof(unsigned long))         ? T_ULONG     : \
        ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))
#endif
#endif

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


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


/* Type declarations */

typedef PyObject *__pyx_t_6cogent_5align_14_pairwise_pogs_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) {
    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;
  }
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  #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_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
#else
  #define __Pyx_RefNannySetupContext(name)
  #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_XDECREF(r) Py_XDECREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)

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

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

static 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(void);

static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
static int __Pyx_EndUnpack(PyObject *); /*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, size <= sizeof(long)) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
    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, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
}

#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i, size <= sizeof(long)) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
    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, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
}


#define __Pyx_GetItemInt(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i, size <= sizeof(long)) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
    PyObject *r;
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
        r = PySequence_GetItem(o, i);
    }
    else {
        r = __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
    }
    return r;
}

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

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

static void __Pyx_AddTraceback(const char *funcname); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from cogent.align._pairwise_pogs */

static double __pyx_v_6cogent_5align_14_pairwise_pogs_SCALE_STEP;
static double __pyx_v_6cogent_5align_14_pairwise_pogs_MIN_FLOAT_VALUE;
static int __pyx_v_6cogent_5align_14_pairwise_pogs_MAX_XCOUNT;
static long __pyx_v_6cogent_5align_14_pairwise_pogs_MIN_SCALE;
static long __pyx_v_6cogent_5align_14_pairwise_pogs_MAX_SCALE;
static double *__pyx_f_6cogent_5align_14_pairwise_pogs_uncheckedArrayDouble(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType); /*proto*/
static void *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArray(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, char, int, int, int **); /*proto*/
static void *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArray1D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, char, int, int *); /*proto*/
static void *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArray2D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, char, int, int *, int *); /*proto*/
static void *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArray3D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, char, int, int *, int *, int *); /*proto*/
static void *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArray4D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, char, int, int *, int *, int *, int *); /*proto*/
static double *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayDouble1D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, int *); /*proto*/
static double *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayDouble2D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, int *, int *); /*proto*/
static double *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayDouble3D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, int *, int *, int *); /*proto*/
static double *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayDouble4D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, int *, int *, int *, int *); /*proto*/
static long *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong1D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, int *); /*proto*/
static long *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong2D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, int *, int *); /*proto*/
static long *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong3D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, int *, int *, int *); /*proto*/
static long *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong4D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, int *, int *, int *, int *); /*proto*/
static unsigned char *__pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayUChar3D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType, int *, int *, int *); /*proto*/
#define __Pyx_MODULE_NAME "cogent.align._pairwise_pogs"
int __pyx_module_is_main_cogent__align___pairwise_pogs = 0;

/* Implementation of cogent.align._pairwise_pogs */
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_chr;
static PyObject *__pyx_builtin_ArithmeticError;
static char __pyx_k_1[] = "Array required, got None";
static char __pyx_k_2[] = "Unexpected array interface version %s";
static char __pyx_k_3[] = "'%s' type array required, got '%s'";
static char __pyx_k_4[] = "'%s%s' type array required, got '%s%s'";
static char __pyx_k_5[] = "%s dimensional array required, got %s";
static char __pyx_k_6[] = "Noncontiguous array";
static char __pyx_k_7[] = "Dimension %s is %s, expected %s";
static char __pyx_k_8[] = "";
static char __pyx_k_9[] = "%s * SCALE_STEP ** %s %s";
static char __pyx_k_10[] = "transition is a negative probability";
static char __pyx_k_11[] = "product is a negative probability";
static char __pyx_k_12[] = "is unexpectedly large";
static char __pyx_k_13[] = "('1', '6', '0', 'dev')";
static char __pyx_k_14[] = "calc_rows (line 37)";
static char __pyx_k__T[] = "T";
static char __pyx_k__nd[] = "nd";
static char __pyx_k__chr[] = "chr";
static char __pyx_k__msg[] = "msg";
static char __pyx_k__data[] = "data";
static char __pyx_k__fmpt[] = "fmpt";
static char __pyx_k__plan[] = "plan";
static char __pyx_k__rows[] = "rows";
static char __pyx_k__flags[] = "flags";
static char __pyx_k__i_low[] = "i_low";
static char __pyx_k__j_low[] = "j_low";
static char __pyx_k__local[] = "local";
static char __pyx_k__preds[] = "preds";
static char __pyx_k__shape[] = "shape";
static char __pyx_k__track[] = "track";
static char __pyx_k__i_high[] = "i_high";
static char __pyx_k__j_high[] = "j_high";
static char __pyx_k__version[] = "version";
static char __pyx_k__viterbi[] = "viterbi";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__exponent[] = "exponent";
static char __pyx_k__itemsize[] = "itemsize";
static char __pyx_k__mantissa[] = "mantissa";
static char __pyx_k__typekind[] = "typekind";
static char __pyx_k__use_logs[] = "use_logs";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k__calc_rows[] = "calc_rows";
static char __pyx_k__track_enc[] = "track_enc";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__seq1_index[] = "seq1_index";
static char __pyx_k__seq2_index[] = "seq2_index";
static char __pyx_k__underflows[] = "underflows";
static char __pyx_k____version__[] = "__version__";
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__version_info[] = "version_info";
static char __pyx_k__ArithmeticError[] = "ArithmeticError";
static char __pyx_k__asCombinedArray[] = "asCombinedArray";
static char __pyx_k____array_struct__[] = "__array_struct__";
static char __pyx_k__state_directions[] = "state_directions";
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_u_14;
static PyObject *__pyx_kp_s_2;
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_8;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__ArithmeticError;
static PyObject *__pyx_n_s__T;
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__asCombinedArray;
static PyObject *__pyx_n_s__calc_rows;
static PyObject *__pyx_n_s__chr;
static PyObject *__pyx_n_s__data;
static PyObject *__pyx_n_s__exponent;
static PyObject *__pyx_n_s__flags;
static PyObject *__pyx_n_s__fmpt;
static PyObject *__pyx_n_s__i_high;
static PyObject *__pyx_n_s__i_low;
static PyObject *__pyx_n_s__itemsize;
static PyObject *__pyx_n_s__j_high;
static PyObject *__pyx_n_s__j_low;
static PyObject *__pyx_n_s__local;
static PyObject *__pyx_n_s__mantissa;
static PyObject *__pyx_n_s__match_scores;
static PyObject *__pyx_n_s__msg;
static PyObject *__pyx_n_s__nd;
static PyObject *__pyx_n_s__plan;
static PyObject *__pyx_n_s__preds;
static PyObject *__pyx_n_s__rows;
static PyObject *__pyx_n_s__seq1_index;
static PyObject *__pyx_n_s__seq2_index;
static PyObject *__pyx_n_s__shape;
static PyObject *__pyx_n_s__state_directions;
static PyObject *__pyx_n_s__track;
static PyObject *__pyx_n_s__track_enc;
static PyObject *__pyx_n_s__typekind;
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;
static PyObject *__pyx_n_s__version_info;
static PyObject *__pyx_n_s__viterbi;
static PyObject *__pyx_n_s__xgap_scores;
static PyObject *__pyx_n_s__ygap_scores;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_3;

/* "/Users/gavin/DevRepos/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_pogs_uncheckedArrayDouble(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_A) {
  struct PyArrayInterface *__pyx_v_a;
  PyObject *__pyx_v_cobj;
  double *__pyx_r;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("uncheckedArrayDouble");
  __pyx_v_cobj = Py_None; __Pyx_INCREF(Py_None);

  /* "/Users/gavin/DevRepos/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_DECREF(__pyx_v_cobj);
  __pyx_v_cobj = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/Users/gavin/DevRepos/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/gavin/DevRepos/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_pogs.uncheckedArrayDouble");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_cobj);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArray(__pyx_t_6cogent_5align_14_pairwise_pogs_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;
  char __pyx_v_typecode2;
  int __pyx_v_dimension;
  int __pyx_v_val;
  int *__pyx_v_var;
  void *__pyx_r;
  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;
  __Pyx_RefNannySetupContext("checkArray");
  __Pyx_INCREF(__pyx_v_A);
  __pyx_v_cobj = Py_None; __Pyx_INCREF(Py_None);

  /* "/Users/gavin/DevRepos/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_pogs_ArrayType)Py_None));
  if (__pyx_t_1) {

    /* "/Users/gavin/DevRepos/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 = PyTuple_New(1); 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_INCREF(((PyObject *)__pyx_kp_s_1));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
    __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/gavin/DevRepos/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_3 = PyObject_GetAttr(((PyObject *)__pyx_v_A), __pyx_n_s____array_struct__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_v_cobj);
  __pyx_v_cobj = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "/Users/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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_3 = PyInt_FromLong(__pyx_v_a->version); 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);
    __pyx_t_2 = PyTuple_New(1); 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);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_2, NULL); 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);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), __pyx_t_3); 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(__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 = 48; __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(__pyx_builtin_ValueError, __pyx_t_3, NULL); 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);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/Users/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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_2 = PyInt_FromLong(__pyx_v_typecode); 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_3 = PyTuple_New(1); 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);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_chr, __pyx_t_3, 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(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyInt_FromLong(__pyx_v_typecode2); 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_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_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_chr, __pyx_t_4, 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(__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_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__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, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Users/gavin/DevRepos/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/gavin/DevRepos/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_3 = PyInt_FromLong(__pyx_v_typecode); 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_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_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_chr, __pyx_t_4, 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(__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_2 = PyInt_FromLong(__pyx_v_typecode2); 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_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_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_chr, __pyx_t_5, 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(__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_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __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(__pyx_t_5);
    __Pyx_DECREF(__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, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, __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(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 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/gavin/DevRepos/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/gavin/DevRepos/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_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 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_5), __pyx_t_2); 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(__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 = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, 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(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_6, 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/gavin/DevRepos/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/gavin/DevRepos/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 = PyTuple_New(1); 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_INCREF(((PyObject *)__pyx_kp_s_6));
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_6));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/Users/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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_2 = PyInt_FromLong(__pyx_v_dimension); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyInt_FromLong(__pyx_v_val); 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_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_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_2 = 0;
      __pyx_t_6 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), __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(__pyx_t_5);
      __Pyx_DECREF(__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, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __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(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 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/gavin/DevRepos/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_pogs.checkArray");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_cobj);
  __Pyx_DECREF(__pyx_v_A);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArray1D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_a, char __pyx_v_typecode, int __pyx_v_size, int *__pyx_v_x) {
  int *__pyx_v_dims[1];
  void *__pyx_r;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArray1D");

  /* "/Users/gavin/DevRepos/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/gavin/DevRepos/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_pogs_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_pogs.checkArray1D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArray2D(__pyx_t_6cogent_5align_14_pairwise_pogs_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;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArray2D");

  /* "/Users/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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_pogs_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_pogs.checkArray2D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArray3D(__pyx_t_6cogent_5align_14_pairwise_pogs_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;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArray3D");

  /* "/Users/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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_pogs_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_pogs.checkArray3D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArray4D(__pyx_t_6cogent_5align_14_pairwise_pogs_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;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArray4D");

  /* "/Users/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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/gavin/DevRepos/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_pogs_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_pogs.checkArray4D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArrayDouble1D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_a, int *__pyx_v_x) {
  double *__pyx_r;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArrayDouble1D");

  /* "/Users/gavin/DevRepos/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_pogs_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_pogs.checkArrayDouble1D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArrayDouble2D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_a, int *__pyx_v_x, int *__pyx_v_y) {
  double *__pyx_r;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArrayDouble2D");

  /* "/Users/gavin/DevRepos/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_pogs_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_pogs.checkArrayDouble2D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArrayDouble3D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_a, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  double *__pyx_r;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArrayDouble3D");

  /* "/Users/gavin/DevRepos/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_pogs_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_pogs.checkArrayDouble3D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArrayDouble4D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_a, int *__pyx_v_w, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  double *__pyx_r;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArrayDouble4D");

  /* "/Users/gavin/DevRepos/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_pogs_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_pogs.checkArrayDouble4D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArrayLong1D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_a, int *__pyx_v_x) {
  long *__pyx_r;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArrayLong1D");

  /* "/Users/gavin/DevRepos/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_pogs_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_pogs.checkArrayLong1D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArrayLong2D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_a, int *__pyx_v_x, int *__pyx_v_y) {
  long *__pyx_r;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArrayLong2D");

  /* "/Users/gavin/DevRepos/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_pogs_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_pogs.checkArrayLong2D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArrayLong3D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_a, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  long *__pyx_r;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArrayLong3D");

  /* "/Users/gavin/DevRepos/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_pogs_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_pogs.checkArrayLong3D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/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_pogs_checkArrayLong4D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_a, int *__pyx_v_w, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  long *__pyx_r;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArrayLong4D");

  /* "/Users/gavin/DevRepos/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_pogs_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_pogs.checkArrayLong4D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":31
 * #    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_pogs_checkArrayUChar3D(__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_a, int *__pyx_v_x, int *__pyx_v_y, int *__pyx_v_z) {
  unsigned char *__pyx_r;
  void *__pyx_t_1;
  __Pyx_RefNannySetupContext("checkArrayUChar3D");

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":32
 * 
 * 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_pogs_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 = 32; __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_pogs.checkArrayUChar3D");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":34
 *     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_pogs_fmpt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6cogent_5align_14_pairwise_pogs_fmpt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mantissa = 0;
  PyObject *__pyx_v_exponent = 0;
  PyObject *__pyx_v_msg = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__mantissa,&__pyx_n_s__exponent,&__pyx_n_s__msg,0};
  __Pyx_RefNannySetupContext("fmpt");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_kp_s_8);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_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 = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__msg);
        if (unlikely(value)) { values[2] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fmpt") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_mantissa = values[0];
    __pyx_v_exponent = values[1];
    __pyx_v_msg = values[2];
  } else {
    __pyx_v_msg = ((PyObject *)__pyx_kp_s_8);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3:
      __pyx_v_msg = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2:
      __pyx_v_exponent = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_mantissa = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  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 = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_pogs.fmpt");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":35
 * 
 * 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 = 35; __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_9), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __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_pogs.fmpt");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":37
 *     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_pogs_calc_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cogent_5align_14_pairwise_pogs_calc_rows[] = "The ultimate in 2D Pyrex dynamic programming - 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    One time to use something faster than this is when the inputs are sequences\n    rather than alignments.  This code expects alignments (which can be single\n    sequences) represented as POGs (ie: DAGs).\n    \n    Limitations\n       - HMM states must be in a sensible order: M and X, then Y, then END.\n    ";
static PyObject *__pyx_pf_6cogent_5align_14_pairwise_pogs_calc_rows(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_plan = 0;
  __pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_seq1_index = 0;
  __pyx_t_6cogent_5align_14_pairwise_pogs_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;
  PyObject *__pyx_v_preds = 0;
  __pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_state_directions = 0;
  __pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_T = 0;
  __pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_xgap_scores = 0;
  __pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_ygap_scores = 0;
  __pyx_t_6cogent_5align_14_pairwise_pogs_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;
  int __pyx_v_dx;
  int __pyx_v_dy;
  int __pyx_v_prev_i;
  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_count;
  int __pyx_v_a;
  int __pyx_v_b;
  int __pyx_v_a_low;
  int __pyx_v_a_high;
  int __pyx_v_b_low;
  int __pyx_v_b_high;
  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_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;
  __pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_i_sources;
  __pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType __pyx_v_j_sources;
  double *__pyx_v_current_row_data;
  double *__pyx_v_source_row_data_cache[256];
  long *__pyx_v_current_row_ex_data;
  long *__pyx_v_source_row_ex_data_cache[256];
  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;
  long *__pyx_v_i_sources_data;
  long *__pyx_v_i_sources_offsets_data;
  long *__pyx_v_j_sources_data;
  long *__pyx_v_j_sources_offsets_data;
  long __pyx_v_i_sources_start;
  long __pyx_v_i_sources_end;
  long __pyx_v_j_sources_start;
  long __pyx_v_j_sources_end;
  int __pyx_v_i_link_count;
  int __pyx_v_j_link_count;
  int __pyx_v_row_count;
  int __pyx_v_row_length1;
  int __pyx_v_plan_index;
  int __pyx_v_row_count1;
  PyObject *__pyx_v_mantissas;
  PyObject *__pyx_v_exponents;
  int __pyx_v_bin_count;
  int __pyx_v_bin;
  double *__pyx_v_xgap_score_data;
  double *__pyx_v_ygap_score_data;
  PyObject *__pyx_v_pog1;
  PyObject *__pyx_v_pog2;
  PyObject *__pyx_v_j_sources_offsets;
  PyObject *__pyx_v_i_sources_offsets;
  double __pyx_v_impossible;
  PyObject *__pyx_v_score;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  double *__pyx_t_6;
  long *__pyx_t_7;
  long *__pyx_t_8;
  double *__pyx_t_9;
  int __pyx_t_10;
  long __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  unsigned char *__pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  int __pyx_t_21;
  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};
  __Pyx_RefNannySetupContext("calc_rows");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    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);
      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;
    }
    switch (PyTuple_GET_SIZE(__pyx_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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 = 37; __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 (unlikely(value)) { values[17] = value; kw_args--; }
      }
      case 18:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__local);
        if (unlikely(value)) { values[18] = value; kw_args--; }
      }
      case 19:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_scaling);
        if (unlikely(value)) { values[19] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "calc_rows") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_plan = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)values[0]);
    __pyx_v_seq1_index = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)values[1]);
    __pyx_v_seq2_index = ((__pyx_t_6cogent_5align_14_pairwise_pogs_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 = 38; __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 = 38; __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 = 38; __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 = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_preds = values[7];
    __pyx_v_state_directions = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)values[8]);
    __pyx_v_T = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)values[9]);
    __pyx_v_xgap_scores = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)values[10]);
    __pyx_v_ygap_scores = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)values[11]);
    __pyx_v_match_scores = ((__pyx_t_6cogent_5align_14_pairwise_pogs_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 = 41; __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 = 41; __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 = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":41
 *         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 = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":42
 *         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 ultimate in 2D Pyrex dynamic programming - Forward or Viterbi
 */
      __pyx_v_use_scaling = ((int)1);
    }
  } else {
    __pyx_v_use_logs = ((int)0);

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":41
 *         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);

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":42
 *         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 ultimate in 2D Pyrex dynamic programming - Forward or Viterbi
 */
    __pyx_v_use_scaling = ((int)1);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case 20:
      __pyx_v_use_scaling = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 19)); if (unlikely((__pyx_v_use_scaling == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case 19:
      __pyx_v_local = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 18)); if (unlikely((__pyx_v_local == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case 18:
      __pyx_v_use_logs = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 17)); if (unlikely((__pyx_v_use_logs == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case 17:
      __pyx_v_viterbi = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 16)); if (unlikely((__pyx_v_viterbi == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_track_enc = PyTuple_GET_ITEM(__pyx_args, 15);
      __pyx_v_track = PyTuple_GET_ITEM(__pyx_args, 14);
      __pyx_v_rows = PyTuple_GET_ITEM(__pyx_args, 13);
      __pyx_v_match_scores = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)PyTuple_GET_ITEM(__pyx_args, 12));
      __pyx_v_ygap_scores = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)PyTuple_GET_ITEM(__pyx_args, 11));
      __pyx_v_xgap_scores = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)PyTuple_GET_ITEM(__pyx_args, 10));
      __pyx_v_T = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)PyTuple_GET_ITEM(__pyx_args, 9));
      __pyx_v_state_directions = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)PyTuple_GET_ITEM(__pyx_args, 8));
      __pyx_v_preds = PyTuple_GET_ITEM(__pyx_args, 7);
      __pyx_v_j_high = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 6)); if (unlikely((__pyx_v_j_high == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_j_low = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_j_low == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_i_high = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_i_high == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_i_low = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_i_low == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_seq2_index = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)PyTuple_GET_ITEM(__pyx_args, 2));
      __pyx_v_seq1_index = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)PyTuple_GET_ITEM(__pyx_args, 1));
      __pyx_v_plan = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)PyTuple_GET_ITEM(__pyx_args, 0));
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  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 = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cogent.align._pairwise_pogs.calc_rows");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_plan);
  __Pyx_INCREF(__pyx_v_seq1_index);
  __Pyx_INCREF(__pyx_v_seq2_index);
  __Pyx_INCREF(__pyx_v_preds);
  __Pyx_INCREF(__pyx_v_state_directions);
  __Pyx_INCREF(__pyx_v_T);
  __Pyx_INCREF(__pyx_v_xgap_scores);
  __Pyx_INCREF(__pyx_v_ygap_scores);
  __Pyx_INCREF(__pyx_v_match_scores);
  __Pyx_INCREF(__pyx_v_rows);
  __Pyx_INCREF(__pyx_v_track);
  __Pyx_INCREF(__pyx_v_track_enc);
  __pyx_v_i_sources = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_j_sources = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_mantissas = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_exponents = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_pog1 = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_pog2 = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_j_sources_offsets = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_i_sources_offsets = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_score = Py_None; __Pyx_INCREF(Py_None);

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":84
 *     cdef int row_count, row_length1, plan_index, row_count1
 * 
 *     (mantissas, exponents) = rows             # <<<<<<<<<<<<<<
 * 
 *     assert not (use_logs and not viterbi)
 */
  if (PyTuple_CheckExact(__pyx_v_rows) && likely(PyTuple_GET_SIZE(__pyx_v_rows) == 2)) {
    PyObject* tuple = __pyx_v_rows;
    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_mantissas);
    __pyx_v_mantissas = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_exponents);
    __pyx_v_exponents = __pyx_t_2;
    __pyx_t_2 = 0;
  } else {
    __pyx_t_3 = PyObject_GetIter(__pyx_v_rows); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_3, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_3, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_EndUnpack(__pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_v_mantissas);
    __pyx_v_mantissas = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_exponents);
    __pyx_v_exponents = __pyx_t_2;
    __pyx_t_2 = 0;
  }

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":86
 *     (mantissas, exponents) = rows
 * 
 *     assert not (use_logs and not viterbi)             # <<<<<<<<<<<<<<
 *     assert not (use_logs and use_scaling)
 *     assert not (local and not viterbi)
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (__pyx_v_use_logs) {
    __pyx_t_4 = (!__pyx_v_viterbi);
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_v_use_logs;
  }
  if (unlikely(!(!__pyx_t_5))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":87
 * 
 *     assert not (use_logs and not viterbi)
 *     assert not (use_logs and use_scaling)             # <<<<<<<<<<<<<<
 *     assert not (local and not viterbi)
 * 
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (__pyx_v_use_logs) {
    __pyx_t_5 = __pyx_v_use_scaling;
  } else {
    __pyx_t_5 = __pyx_v_use_logs;
  }
  if (unlikely(!(!__pyx_t_5))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":88
 *     assert not (use_logs and not viterbi)
 *     assert not (use_logs and use_scaling)
 *     assert not (local and not viterbi)             # <<<<<<<<<<<<<<
 * 
 *     N = 0
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (__pyx_v_local) {
    __pyx_t_5 = (!__pyx_v_viterbi);
    __pyx_t_4 = __pyx_t_5;
  } else {
    __pyx_t_4 = __pyx_v_local;
  }
  if (unlikely(!(!__pyx_t_4))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":90
 *     assert not (local and not viterbi)
 * 
 *     N = 0             # <<<<<<<<<<<<<<
 *     T_data = checkArrayDouble2D(T, &N, &N)
 *     row_length = 0
 */
  __pyx_v_N = 0;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":91
 * 
 *     N = 0
 *     T_data = checkArrayDouble2D(T, &N, &N)             # <<<<<<<<<<<<<<
 *     row_length = 0
 *     row_count = 0
 */
  __pyx_t_6 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayDouble2D(__pyx_v_T, (&__pyx_v_N), (&__pyx_v_N)); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_T_data = __pyx_t_6;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":92
 *     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;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":93
 *     T_data = checkArrayDouble2D(T, &N, &N)
 *     row_length = 0
 *     row_count = 0             # <<<<<<<<<<<<<<
 *     plan_data = checkArrayLong1D(plan, &row_count)
 * 
 */
  __pyx_v_row_count = 0;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":94
 *     row_length = 0
 *     row_count = 0
 *     plan_data = checkArrayLong1D(plan, &row_count)             # <<<<<<<<<<<<<<
 * 
 *     dest_states = 0
 */
  __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong1D(__pyx_v_plan, (&__pyx_v_row_count)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_plan_data = __pyx_t_7;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":96
 *     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;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":97
 * 
 *     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;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":99
 *     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_8 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong2D(__pyx_v_state_directions, (&__pyx_v_dest_states), (&__pyx_v_d4)); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_dest_states_data = __pyx_t_8;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":104
 *     cdef double *xgap_score_data, *ygap_score_data
 * 
 *     x_index = checkArrayLong1D(seq1_index, &row_count)             # <<<<<<<<<<<<<<
 *     y_index = checkArrayLong1D(seq2_index, &row_length)
 * 
 */
  __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong1D(__pyx_v_seq1_index, (&__pyx_v_row_count)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_x_index = __pyx_t_7;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":105
 * 
 *     x_index = checkArrayLong1D(seq1_index, &row_count)
 *     y_index = checkArrayLong1D(seq2_index, &row_length)             # <<<<<<<<<<<<<<
 * 
 *     max_x = max_y = bin_count = 0
 */
  __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong1D(__pyx_v_seq2_index, (&__pyx_v_row_length)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_y_index = __pyx_t_7;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":107
 *     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;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":109
 *     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_9 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayDouble3D(__pyx_v_match_scores, (&__pyx_v_bin_count), (&__pyx_v_max_x), (&__pyx_v_max_y)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_match_score_data = __pyx_t_9;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":110
 *     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_6 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayDouble2D(__pyx_v_xgap_scores, (&__pyx_v_bin_count), (&__pyx_v_max_x)); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_xgap_score_data = __pyx_t_6;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":111
 *             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_6 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayDouble2D(__pyx_v_ygap_scores, (&__pyx_v_bin_count), (&__pyx_v_max_y)); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_ygap_score_data = __pyx_t_6;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":113
 *     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_10 = __pyx_v_row_count;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":114
 * 
 *     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 PYREX_WITHOUT_ASSERTIONS
    __pyx_t_11 = (__pyx_v_x_index[__pyx_v_i]);
    __pyx_t_4 = (0 <= __pyx_t_11);
    if (__pyx_t_4) {
      __pyx_t_4 = (__pyx_t_11 < __pyx_v_max_x);
    }
    if (unlikely(!__pyx_t_4)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif
  }

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":115
 *     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_10 = __pyx_v_row_length;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_10; __pyx_v_j++) {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":116
 *         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 PYREX_WITHOUT_ASSERTIONS
    __pyx_t_11 = (__pyx_v_y_index[__pyx_v_j]);
    __pyx_t_4 = (0 <= __pyx_t_11);
    if (__pyx_t_4) {
      __pyx_t_4 = (__pyx_t_11 < __pyx_v_max_y);
    }
    if (unlikely(!__pyx_t_4)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif
  }

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":118
 *         assert 0 <= y_index[j] < max_y
 * 
 *     assert j_low >= 0 and j_high > j_low and j_high <= row_length             # <<<<<<<<<<<<<<
 * 
 *     (pog1, pog2) = preds
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_t_4 = (__pyx_v_j_low >= 0);
  if (__pyx_t_4) {
    __pyx_t_5 = (__pyx_v_j_high > __pyx_v_j_low);
    if (__pyx_t_5) {
      __pyx_t_12 = (__pyx_v_j_high <= __pyx_v_row_length);
      __pyx_t_13 = __pyx_t_12;
    } else {
      __pyx_t_13 = __pyx_t_5;
    }
    __pyx_t_5 = __pyx_t_13;
  } else {
    __pyx_t_5 = __pyx_t_4;
  }
  if (unlikely(!__pyx_t_5)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":120
 *     assert j_low >= 0 and j_high > j_low and j_high <= row_length
 * 
 *     (pog1, pog2) = preds             # <<<<<<<<<<<<<<
 *     (j_sources, j_sources_offsets) = pog2.asCombinedArray()
 *     j_link_count = 0
 */
  if (PyTuple_CheckExact(__pyx_v_preds) && likely(PyTuple_GET_SIZE(__pyx_v_preds) == 2)) {
    PyObject* tuple = __pyx_v_preds;
    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_v_pog1);
    __pyx_v_pog1 = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_pog2);
    __pyx_v_pog2 = __pyx_t_1;
    __pyx_t_1 = 0;
  } else {
    __pyx_t_3 = PyObject_GetIter(__pyx_v_preds); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_3, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_3, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_EndUnpack(__pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_v_pog1);
    __pyx_v_pog1 = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_pog2);
    __pyx_v_pog2 = __pyx_t_1;
    __pyx_t_1 = 0;
  }

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":121
 * 
 *     (pog1, pog2) = preds
 *     (j_sources, j_sources_offsets) = pog2.asCombinedArray()             # <<<<<<<<<<<<<<
 *     j_link_count = 0
 *     j_sources_data = checkArrayLong1D(j_sources, &j_link_count)
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_pog2, __pyx_n_s__asCombinedArray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyTuple_CheckExact(__pyx_t_2) && likely(PyTuple_GET_SIZE(__pyx_t_2) == 2)) {
    PyObject* tuple = __pyx_t_2;
    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_j_sources));
    __pyx_v_j_sources = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)__pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_j_sources_offsets);
    __pyx_v_j_sources_offsets = __pyx_t_3;
    __pyx_t_3 = 0;
  } else {
    __pyx_t_14 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_14, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_14, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_EndUnpack(__pyx_t_14) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_j_sources));
    __pyx_v_j_sources = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)__pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_j_sources_offsets);
    __pyx_v_j_sources_offsets = __pyx_t_3;
    __pyx_t_3 = 0;
  }

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":122
 *     (pog1, pog2) = preds
 *     (j_sources, j_sources_offsets) = pog2.asCombinedArray()
 *     j_link_count = 0             # <<<<<<<<<<<<<<
 *     j_sources_data = checkArrayLong1D(j_sources, &j_link_count)
 *     row_length1 = row_length + 1
 */
  __pyx_v_j_link_count = 0;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":123
 *     (j_sources, j_sources_offsets) = pog2.asCombinedArray()
 *     j_link_count = 0
 *     j_sources_data = checkArrayLong1D(j_sources, &j_link_count)             # <<<<<<<<<<<<<<
 *     row_length1 = row_length + 1
 *     j_sources_offsets_data = checkArrayLong1D(j_sources_offsets, &row_length1)
 */
  __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong1D(__pyx_v_j_sources, (&__pyx_v_j_link_count)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_j_sources_data = __pyx_t_7;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":124
 *     j_link_count = 0
 *     j_sources_data = checkArrayLong1D(j_sources, &j_link_count)
 *     row_length1 = row_length + 1             # <<<<<<<<<<<<<<
 *     j_sources_offsets_data = checkArrayLong1D(j_sources_offsets, &row_length1)
 * 
 */
  __pyx_v_row_length1 = (__pyx_v_row_length + 1);

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":125
 *     j_sources_data = checkArrayLong1D(j_sources, &j_link_count)
 *     row_length1 = row_length + 1
 *     j_sources_offsets_data = checkArrayLong1D(j_sources_offsets, &row_length1)             # <<<<<<<<<<<<<<
 * 
 *     (i_sources, i_sources_offsets) = pog1.asCombinedArray()
 */
  __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong1D(((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)__pyx_v_j_sources_offsets), (&__pyx_v_row_length1)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_j_sources_offsets_data = __pyx_t_7;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":127
 *     j_sources_offsets_data = checkArrayLong1D(j_sources_offsets, &row_length1)
 * 
 *     (i_sources, i_sources_offsets) = pog1.asCombinedArray()             # <<<<<<<<<<<<<<
 *     i_link_count = 0
 *     i_sources_data = checkArrayLong1D(i_sources, &i_link_count)
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_pog1, __pyx_n_s__asCombinedArray); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyTuple_CheckExact(__pyx_t_3) && likely(PyTuple_GET_SIZE(__pyx_t_3) == 2)) {
    PyObject* tuple = __pyx_t_3;
    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_i_sources));
    __pyx_v_i_sources = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)__pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_i_sources_offsets);
    __pyx_v_i_sources_offsets = __pyx_t_1;
    __pyx_t_1 = 0;
  } else {
    __pyx_t_14 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_14, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_14, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_EndUnpack(__pyx_t_14) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_i_sources));
    __pyx_v_i_sources = ((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)__pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_i_sources_offsets);
    __pyx_v_i_sources_offsets = __pyx_t_1;
    __pyx_t_1 = 0;
  }

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":128
 * 
 *     (i_sources, i_sources_offsets) = pog1.asCombinedArray()
 *     i_link_count = 0             # <<<<<<<<<<<<<<
 *     i_sources_data = checkArrayLong1D(i_sources, &i_link_count)
 *     row_count1 = row_count + 1 # ???
 */
  __pyx_v_i_link_count = 0;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":129
 *     (i_sources, i_sources_offsets) = pog1.asCombinedArray()
 *     i_link_count = 0
 *     i_sources_data = checkArrayLong1D(i_sources, &i_link_count)             # <<<<<<<<<<<<<<
 *     row_count1 = row_count + 1 # ???
 *     i_sources_offsets_data = checkArrayLong1D(i_sources_offsets, &row_count1)
 */
  __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong1D(__pyx_v_i_sources, (&__pyx_v_i_link_count)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_i_sources_data = __pyx_t_7;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":130
 *     i_link_count = 0
 *     i_sources_data = checkArrayLong1D(i_sources, &i_link_count)
 *     row_count1 = row_count + 1 # ???             # <<<<<<<<<<<<<<
 *     i_sources_offsets_data = checkArrayLong1D(i_sources_offsets, &row_count1)
 * 
 */
  __pyx_v_row_count1 = (__pyx_v_row_count + 1);

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":131
 *     i_sources_data = checkArrayLong1D(i_sources, &i_link_count)
 *     row_count1 = row_count + 1 # ???
 *     i_sources_offsets_data = checkArrayLong1D(i_sources_offsets, &row_count1)             # <<<<<<<<<<<<<<
 * 
 *     cdef double impossible
 */
  __pyx_t_7 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong1D(((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)__pyx_v_i_sources_offsets), (&__pyx_v_row_count1)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_i_sources_offsets_data = __pyx_t_7;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":134
 * 
 *     cdef double impossible
 *     if use_logs:             # <<<<<<<<<<<<<<
 *         impossible = log(0.0) # -inf
 *     else:
 */
  __pyx_t_10 = __pyx_v_use_logs;
  if (__pyx_t_10) {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":135
 *     cdef double impossible
 *     if use_logs:
 *         impossible = log(0.0) # -inf             # <<<<<<<<<<<<<<
 *     else:
 *         impossible = 0.0
 */
    __pyx_v_impossible = log(0.0);
    goto __pyx_L10;
  }
  /*else*/ {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":137
 *         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_L10:;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":139
 *         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_5 = (__pyx_v_track != Py_None);
    if (__pyx_t_5) {
      __pyx_t_4 = (__pyx_v_track_enc != Py_None);
      __pyx_t_13 = __pyx_t_4;
    } else {
      __pyx_t_13 = __pyx_t_5;
    }
    __pyx_t_5 = __pyx_t_13;
  } else {
    __pyx_t_5 = __pyx_v_viterbi;
  }
  if (__pyx_t_5) {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":140
 * 
 *     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_15 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayUChar3D(((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)__pyx_v_track), (&__pyx_v_row_count), (&__pyx_v_row_length), (&__pyx_v_N)); if (unlikely(__pyx_t_15 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_track_data = __pyx_t_15;

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":141
 *     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 (PyTuple_CheckExact(__pyx_v_track_enc) && likely(PyTuple_GET_SIZE(__pyx_v_track_enc) == 3)) {
      PyObject* tuple = __pyx_v_track_enc;
      __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3);
      __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
      __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 = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_2 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_2);
      __pyx_t_17 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_tcode_x = __pyx_t_10;
      __pyx_v_tcode_y = __pyx_t_16;
      __pyx_v_tcode_s = __pyx_t_17;
    } else {
      __pyx_t_14 = PyObject_GetIter(__pyx_v_track_enc); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_14, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __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 = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_14, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __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 = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_14, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__Pyx_EndUnpack(__pyx_t_14) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_v_tcode_x = __pyx_t_17;
      __pyx_v_tcode_y = __pyx_t_16;
      __pyx_v_tcode_s = __pyx_t_10;
    }
    goto __pyx_L11;
  }
  /*else*/ {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":143
 *         (tcode_x, tcode_y, tcode_s) = track_enc
 *     else:
 *         track_data = NULL             # <<<<<<<<<<<<<<
 *         tcode_x = tcode_y = tcode_s = 0
 * 
 */
    __pyx_v_track_data = NULL;

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":144
 *     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_L11:;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":147
 * 
 *     # 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_pogs_MIN_SCALE;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":148
 *     # 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;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":149
 *     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;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":151
 *     last_i = last_j = last_state = -1
 * 
 *     for i from i_low <= i < i_high:             # <<<<<<<<<<<<<<
 *         x = x_index[i]
 * 
 */
  __pyx_t_10 = __pyx_v_i_high;
  for (__pyx_v_i = __pyx_v_i_low; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":152
 * 
 *     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]);

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":154
 *         x = x_index[i]
 * 
 *         if PyErr_CheckSignals():             # <<<<<<<<<<<<<<
 *             raise PyErr_Occurred()
 * 
 */
    __pyx_t_16 = PyErr_CheckSignals();
    if (__pyx_t_16) {

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":155
 * 
 *         if PyErr_CheckSignals():
 *             raise PyErr_Occurred()             # <<<<<<<<<<<<<<
 * 
 *         plan_index = plan_data[i]
 */
      __pyx_t_2 = PyErr_Occurred(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L14;
    }
    __pyx_L14:;

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":157
 *             raise PyErr_Occurred()
 * 
 *         plan_index = plan_data[i]             # <<<<<<<<<<<<<<
 *         current_row_data = checkArrayDouble2D(mantissas[plan_index], &row_length, &N)
 *         if use_scaling:
 */
    __pyx_v_plan_index = (__pyx_v_plan_data[__pyx_v_i]);

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":158
 * 
 *         plan_index = plan_data[i]
 *         current_row_data = checkArrayDouble2D(mantissas[plan_index], &row_length, &N)             # <<<<<<<<<<<<<<
 *         if use_scaling:
 *             current_row_ex_data = checkArrayLong2D(exponents[plan_index], &row_length, &N)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mantissas, __pyx_v_plan_index, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayDouble2D(((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)__pyx_t_2), (&__pyx_v_row_length), (&__pyx_v_N)); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_current_row_data = __pyx_t_6;

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":159
 *         plan_index = plan_data[i]
 *         current_row_data = checkArrayDouble2D(mantissas[plan_index], &row_length, &N)
 *         if use_scaling:             # <<<<<<<<<<<<<<
 *             current_row_ex_data = checkArrayLong2D(exponents[plan_index], &row_length, &N)
 *         else:
 */
    __pyx_t_16 = __pyx_v_use_scaling;
    if (__pyx_t_16) {

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":160
 *         current_row_data = checkArrayDouble2D(mantissas[plan_index], &row_length, &N)
 *         if use_scaling:
 *             current_row_ex_data = checkArrayLong2D(exponents[plan_index], &row_length, &N)             # <<<<<<<<<<<<<<
 *         else:
 *             current_row_ex_data = NULL
 */
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_exponents, __pyx_v_plan_index, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong2D(((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)__pyx_t_2), (&__pyx_v_row_length), (&__pyx_v_N)); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_current_row_ex_data = __pyx_t_8;
      goto __pyx_L15;
    }
    /*else*/ {

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":162
 *             current_row_ex_data = checkArrayLong2D(exponents[plan_index], &row_length, &N)
 *         else:
 *             current_row_ex_data = NULL             # <<<<<<<<<<<<<<
 * 
 *         i_sources_start = i_sources_offsets[i]
 */
      __pyx_v_current_row_ex_data = NULL;
    }
    __pyx_L15:;

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":164
 *             current_row_ex_data = NULL
 * 
 *         i_sources_start = i_sources_offsets[i]             # <<<<<<<<<<<<<<
 *         i_sources_end = i_sources_offsets[i+1]
 * 
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_i_sources_offsets, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = __Pyx_PyInt_AsLong(__pyx_t_2); if (unlikely((__pyx_t_11 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_i_sources_start = __pyx_t_11;

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":165
 * 
 *         i_sources_start = i_sources_offsets[i]
 *         i_sources_end = i_sources_offsets[i+1]             # <<<<<<<<<<<<<<
 * 
 *         source_row_data_cache[0] = current_row_data
 */
    __pyx_t_11 = (__pyx_v_i + 1);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_i_sources_offsets, __pyx_t_11, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = __Pyx_PyInt_AsLong(__pyx_t_2); if (unlikely((__pyx_t_11 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_i_sources_end = __pyx_t_11;

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":167
 *         i_sources_end = i_sources_offsets[i+1]
 * 
 *         source_row_data_cache[0] = current_row_data             # <<<<<<<<<<<<<<
 *         source_row_ex_data_cache[0] = current_row_ex_data
 * 
 */
    (__pyx_v_source_row_data_cache[0]) = __pyx_v_current_row_data;

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":168
 * 
 *         source_row_data_cache[0] = current_row_data
 *         source_row_ex_data_cache[0] = current_row_ex_data             # <<<<<<<<<<<<<<
 * 
 *         a_count = i_sources_end-i_sources_start
 */
    (__pyx_v_source_row_ex_data_cache[0]) = __pyx_v_current_row_ex_data;

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":170
 *         source_row_ex_data_cache[0] = current_row_ex_data
 * 
 *         a_count = i_sources_end-i_sources_start             # <<<<<<<<<<<<<<
 *         for a from 0 <= a < a_count:
 *             prev_i = i_sources_data[a+i_sources_start]
 */
    __pyx_v_a_count = (__pyx_v_i_sources_end - __pyx_v_i_sources_start);

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":171
 * 
 *         a_count = i_sources_end-i_sources_start
 *         for a from 0 <= a < a_count:             # <<<<<<<<<<<<<<
 *             prev_i = i_sources_data[a+i_sources_start]
 *             plan_index = plan_data[prev_i]
 */
    __pyx_t_16 = __pyx_v_a_count;
    for (__pyx_v_a = 0; __pyx_v_a < __pyx_t_16; __pyx_v_a++) {

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":172
 *         a_count = i_sources_end-i_sources_start
 *         for a from 0 <= a < a_count:
 *             prev_i = i_sources_data[a+i_sources_start]             # <<<<<<<<<<<<<<
 *             plan_index = plan_data[prev_i]
 *             source_row_data_cache[a+1] = checkArrayDouble2D(
 */
      __pyx_v_prev_i = (__pyx_v_i_sources_data[(__pyx_v_a + __pyx_v_i_sources_start)]);

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":173
 *         for a from 0 <= a < a_count:
 *             prev_i = i_sources_data[a+i_sources_start]
 *             plan_index = plan_data[prev_i]             # <<<<<<<<<<<<<<
 *             source_row_data_cache[a+1] = checkArrayDouble2D(
 *                     mantissas[plan_index], &row_length, &N)
 */
      __pyx_v_plan_index = (__pyx_v_plan_data[__pyx_v_prev_i]);

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":175
 *             plan_index = plan_data[prev_i]
 *             source_row_data_cache[a+1] = checkArrayDouble2D(
 *                     mantissas[plan_index], &row_length, &N)             # <<<<<<<<<<<<<<
 *             if use_scaling:
 *                 source_row_ex_data_cache[a+1] = checkArrayLong2D(
 */
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mantissas, __pyx_v_plan_index, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayDouble2D(((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)__pyx_t_2), (&__pyx_v_row_length), (&__pyx_v_N)); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":174
 *             prev_i = i_sources_data[a+i_sources_start]
 *             plan_index = plan_data[prev_i]
 *             source_row_data_cache[a+1] = checkArrayDouble2D(             # <<<<<<<<<<<<<<
 *                     mantissas[plan_index], &row_length, &N)
 *             if use_scaling:
 */
      (__pyx_v_source_row_data_cache[(__pyx_v_a + 1)]) = __pyx_t_6;

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":176
 *             source_row_data_cache[a+1] = checkArrayDouble2D(
 *                     mantissas[plan_index], &row_length, &N)
 *             if use_scaling:             # <<<<<<<<<<<<<<
 *                 source_row_ex_data_cache[a+1] = checkArrayLong2D(
 *                         exponents[plan_index], &row_length, &N)
 */
      __pyx_t_17 = __pyx_v_use_scaling;
      if (__pyx_t_17) {

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":178
 *             if use_scaling:
 *                 source_row_ex_data_cache[a+1] = checkArrayLong2D(
 *                         exponents[plan_index], &row_length, &N)             # <<<<<<<<<<<<<<
 *             else:
 *                 source_row_ex_data_cache[a+1] = NULL
 */
        __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_exponents, __pyx_v_plan_index, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = __pyx_f_6cogent_5align_14_pairwise_pogs_checkArrayLong2D(((__pyx_t_6cogent_5align_14_pairwise_pogs_ArrayType)__pyx_t_2), (&__pyx_v_row_length), (&__pyx_v_N)); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":177
 *                     mantissas[plan_index], &row_length, &N)
 *             if use_scaling:
 *                 source_row_ex_data_cache[a+1] = checkArrayLong2D(             # <<<<<<<<<<<<<<
 *                         exponents[plan_index], &row_length, &N)
 *             else:
 */
        (__pyx_v_source_row_ex_data_cache[(__pyx_v_a + 1)]) = __pyx_t_8;
        goto __pyx_L18;
      }
      /*else*/ {

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":180
 *                         exponents[plan_index], &row_length, &N)
 *             else:
 *                 source_row_ex_data_cache[a+1] = NULL             # <<<<<<<<<<<<<<
 * 
 *         if i == 0:
 */
        (__pyx_v_source_row_ex_data_cache[(__pyx_v_a + 1)]) = NULL;
      }
      __pyx_L18:;
    }

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":182
 *                 source_row_ex_data_cache[a+1] = NULL
 * 
 *         if i == 0:             # <<<<<<<<<<<<<<
 *             if use_logs:
 *                 current_row_data[0] = 0.0
 */
    __pyx_t_5 = (__pyx_v_i == 0);
    if (__pyx_t_5) {

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":183
 * 
 *         if i == 0:
 *             if use_logs:             # <<<<<<<<<<<<<<
 *                 current_row_data[0] = 0.0
 *             else:
 */
      __pyx_t_16 = __pyx_v_use_logs;
      if (__pyx_t_16) {

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":184
 *         if i == 0:
 *             if use_logs:
 *                 current_row_data[0] = 0.0             # <<<<<<<<<<<<<<
 *             else:
 *                 current_row_data[0] = 1.0
 */
        (__pyx_v_current_row_data[0]) = 0.0;
        goto __pyx_L20;
      }
      /*else*/ {

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":186
 *                 current_row_data[0] = 0.0
 *             else:
 *                 current_row_data[0] = 1.0             # <<<<<<<<<<<<<<
 *             if use_scaling:
 *                 current_row_ex_data[0] = 0
 */
        (__pyx_v_current_row_data[0]) = 1.0;
      }
      __pyx_L20:;

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":187
 *             else:
 *                 current_row_data[0] = 1.0
 *             if use_scaling:             # <<<<<<<<<<<<<<
 *                 current_row_ex_data[0] = 0
 *         else:
 */
      __pyx_t_16 = __pyx_v_use_scaling;
      if (__pyx_t_16) {

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":188
 *                 current_row_data[0] = 1.0
 *             if use_scaling:
 *                 current_row_ex_data[0] = 0             # <<<<<<<<<<<<<<
 *         else:
 *             current_row_data[0*N+0] = impossible
 */
        (__pyx_v_current_row_ex_data[0]) = 0;
        goto __pyx_L21;
      }
      __pyx_L21:;
      goto __pyx_L19;
    }
    /*else*/ {

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":190
 *                 current_row_ex_data[0] = 0
 *         else:
 *             current_row_data[0*N+0] = impossible             # <<<<<<<<<<<<<<
 *             if use_scaling:
 *                 current_row_ex_data[0*N+0] = MIN_SCALE
 */
      (__pyx_v_current_row_data[((0 * __pyx_v_N) + 0)]) = __pyx_v_impossible;

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":191
 *         else:
 *             current_row_data[0*N+0] = impossible
 *             if use_scaling:             # <<<<<<<<<<<<<<
 *                 current_row_ex_data[0*N+0] = MIN_SCALE
 * 
 */
      __pyx_t_16 = __pyx_v_use_scaling;
      if (__pyx_t_16) {

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":192
 *             current_row_data[0*N+0] = impossible
 *             if use_scaling:
 *                 current_row_ex_data[0*N+0] = MIN_SCALE             # <<<<<<<<<<<<<<
 * 
 *         j_sources_end = j_sources_offsets_data[j_low]
 */
        (__pyx_v_current_row_ex_data[((0 * __pyx_v_N) + 0)]) = __pyx_v_6cogent_5align_14_pairwise_pogs_MIN_SCALE;
        goto __pyx_L22;
      }
      __pyx_L22:;
    }
    __pyx_L19:;

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":194
 *                 current_row_ex_data[0*N+0] = MIN_SCALE
 * 
 *         j_sources_end = j_sources_offsets_data[j_low]             # <<<<<<<<<<<<<<
 *         for j from j_low <= j < j_high:
 *             j_sources_start = j_sources_end
 */
    __pyx_v_j_sources_end = (__pyx_v_j_sources_offsets_data[__pyx_v_j_low]);

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":195
 * 
 *         j_sources_end = j_sources_offsets_data[j_low]
 *         for j from j_low <= j < j_high:             # <<<<<<<<<<<<<<
 *             j_sources_start = j_sources_end
 *             j_sources_end = j_sources_offsets_data[j+1]
 */
    __pyx_t_16 = __pyx_v_j_high;
    for (__pyx_v_j = __pyx_v_j_low; __pyx_v_j < __pyx_t_16; __pyx_v_j++) {

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":196
 *         j_sources_end = j_sources_offsets_data[j_low]
 *         for j from j_low <= j < j_high:
 *             j_sources_start = j_sources_end             # <<<<<<<<<<<<<<
 *             j_sources_end = j_sources_offsets_data[j+1]
 * 
 */
      __pyx_v_j_sources_start = __pyx_v_j_sources_end;

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":197
 *         for j from j_low <= j < j_high:
 *             j_sources_start = j_sources_end
 *             j_sources_end = j_sources_offsets_data[j+1]             # <<<<<<<<<<<<<<
 * 
 *             for dest_state from 0 <= dest_state < dest_states:
 */
      __pyx_v_j_sources_end = (__pyx_v_j_sources_offsets_data[(__pyx_v_j + 1)]);

      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":199
 *             j_sources_end = j_sources_offsets_data[j+1]
 * 
 *             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_17 = __pyx_v_dest_states;
      for (__pyx_v_dest_state = 0; __pyx_v_dest_state < __pyx_t_17; __pyx_v_dest_state++) {

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":200
 * 
 *             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)]);

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":201
 *             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)]);

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":202
 *                 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)]);

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":203
 *                 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)]);

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":205
 *                 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;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":206
 * 
 *                 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_pogs_MIN_SCALE;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":207
 *                 max_mantissa = impossible
 *                 max_exponent = MIN_SCALE
 *                 partial_sum = 0.0             # <<<<<<<<<<<<<<
 *                 pointer_state = N  # ie ERROR
 * 
 */
        __pyx_v_partial_sum = 0.0;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":208
 *                 max_exponent = MIN_SCALE
 *                 partial_sum = 0.0
 *                 pointer_state = N  # ie ERROR             # <<<<<<<<<<<<<<
 * 
 *                 if dx:
 */
        __pyx_v_pointer_state = __pyx_v_N;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":210
 *                 pointer_state = N  # ie ERROR
 * 
 *                 if dx:             # <<<<<<<<<<<<<<
 *                     a_low = 1
 *                     a_high = a_count + 1
 */
        __pyx_t_18 = __pyx_v_dx;
        if (__pyx_t_18) {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":211
 * 
 *                 if dx:
 *                     a_low = 1             # <<<<<<<<<<<<<<
 *                     a_high = a_count + 1
 *                 else:
 */
          __pyx_v_a_low = 1;

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":212
 *                 if dx:
 *                     a_low = 1
 *                     a_high = a_count + 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     a_low = 0
 */
          __pyx_v_a_high = (__pyx_v_a_count + 1);
          goto __pyx_L27;
        }
        /*else*/ {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":214
 *                     a_high = a_count + 1
 *                 else:
 *                     a_low = 0             # <<<<<<<<<<<<<<
 *                     a_high = 1
 * 
 */
          __pyx_v_a_low = 0;

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":215
 *                 else:
 *                     a_low = 0
 *                     a_high = 1             # <<<<<<<<<<<<<<
 * 
 *                 if dy:
 */
          __pyx_v_a_high = 1;
        }
        __pyx_L27:;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":217
 *                     a_high = 1
 * 
 *                 if dy:             # <<<<<<<<<<<<<<
 *                     b_low = 1
 *                     b_high = j_sources_end - j_sources_start + 1
 */
        __pyx_t_18 = __pyx_v_dy;
        if (__pyx_t_18) {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":218
 * 
 *                 if dy:
 *                     b_low = 1             # <<<<<<<<<<<<<<
 *                     b_high = j_sources_end - j_sources_start + 1
 *                 else:
 */
          __pyx_v_b_low = 1;

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":219
 *                 if dy:
 *                     b_low = 1
 *                     b_high = j_sources_end - j_sources_start + 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     b_low = 0
 */
          __pyx_v_b_high = ((__pyx_v_j_sources_end - __pyx_v_j_sources_start) + 1);
          goto __pyx_L28;
        }
        /*else*/ {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":221
 *                     b_high = j_sources_end - j_sources_start + 1
 *                 else:
 *                     b_low = 0             # <<<<<<<<<<<<<<
 *                     b_high = 1
 * 
 */
          __pyx_v_b_low = 0;

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":222
 *                 else:
 *                     b_low = 0
 *                     b_high = 1             # <<<<<<<<<<<<<<
 * 
 *                 if use_scaling:
 */
          __pyx_v_b_high = 1;
        }
        __pyx_L28:;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":224
 *                     b_high = 1
 * 
 *                 if use_scaling:             # <<<<<<<<<<<<<<
 *                     sub_partial_sum = 0.0
 *                     # keep these next 8 lines same as below, plus source_row_ex_data
 */
        __pyx_t_18 = __pyx_v_use_scaling;
        if (__pyx_t_18) {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":225
 * 
 *                 if use_scaling:
 *                     sub_partial_sum = 0.0             # <<<<<<<<<<<<<<
 *                     # keep these next 8 lines same as below, plus source_row_ex_data
 *                     for a from a_low <= a < a_high:
 */
          __pyx_v_sub_partial_sum = 0.0;

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":227
 *                     sub_partial_sum = 0.0
 *                     # keep these next 8 lines same as below, plus source_row_ex_data
 *                     for a from a_low <= a < a_high:             # <<<<<<<<<<<<<<
 *                         source_row_data = source_row_data_cache[a]
 *                         source_row_ex_data = source_row_ex_data_cache[a]
 */
          __pyx_t_18 = __pyx_v_a_high;
          for (__pyx_v_a = __pyx_v_a_low; __pyx_v_a < __pyx_t_18; __pyx_v_a++) {

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":228
 *                     # keep these next 8 lines same as below, plus source_row_ex_data
 *                     for a from a_low <= a < a_high:
 *                         source_row_data = source_row_data_cache[a]             # <<<<<<<<<<<<<<
 *                         source_row_ex_data = source_row_ex_data_cache[a]
 *                         for b from b_low <= b < b_high:
 */
            __pyx_v_source_row_data = (__pyx_v_source_row_data_cache[__pyx_v_a]);

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":229
 *                     for a from a_low <= a < a_high:
 *                         source_row_data = source_row_data_cache[a]
 *                         source_row_ex_data = source_row_ex_data_cache[a]             # <<<<<<<<<<<<<<
 *                         for b from b_low <= b < b_high:
 *                             if dy:
 */
            __pyx_v_source_row_ex_data = (__pyx_v_source_row_ex_data_cache[__pyx_v_a]);

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":230
 *                         source_row_data = source_row_data_cache[a]
 *                         source_row_ex_data = source_row_ex_data_cache[a]
 *                         for b from b_low <= b < b_high:             # <<<<<<<<<<<<<<
 *                             if dy:
 *                                 prev_j = j_sources_data[b-1+j_sources_start]
 */
            __pyx_t_19 = __pyx_v_b_high;
            for (__pyx_v_b = __pyx_v_b_low; __pyx_v_b < __pyx_t_19; __pyx_v_b++) {

              /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":231
 *                         source_row_ex_data = source_row_ex_data_cache[a]
 *                         for b from b_low <= b < b_high:
 *                             if dy:             # <<<<<<<<<<<<<<
 *                                 prev_j = j_sources_data[b-1+j_sources_start]
 *                             else:
 */
              __pyx_t_20 = __pyx_v_dy;
              if (__pyx_t_20) {

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":232
 *                         for b from b_low <= b < b_high:
 *                             if dy:
 *                                 prev_j = j_sources_data[b-1+j_sources_start]             # <<<<<<<<<<<<<<
 *                             else:
 *                                 prev_j = j
 */
                __pyx_v_prev_j = (__pyx_v_j_sources_data[((__pyx_v_b - 1) + __pyx_v_j_sources_start)]);
                goto __pyx_L34;
              }
              /*else*/ {

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":234
 *                                 prev_j = j_sources_data[b-1+j_sources_start]
 *                             else:
 *                                 prev_j = j             # <<<<<<<<<<<<<<
 *                             for prev_state from (prev_j>0) <= prev_state < N:
 *                                 index = prev_j*N + prev_state
 */
                __pyx_v_prev_j = __pyx_v_j;
              }
              __pyx_L34:;

              /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":235
 *                             else:
 *                                 prev_j = j
 *                             for prev_state from (prev_j>0) <= prev_state < N:             # <<<<<<<<<<<<<<
 *                                 index = prev_j*N + prev_state
 * 
 */
              __pyx_t_20 = __pyx_v_N;
              for (__pyx_v_prev_state = (__pyx_v_prev_j > 0); __pyx_v_prev_state < __pyx_t_20; __pyx_v_prev_state++) {

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":236
 *                                 prev_j = j
 *                             for prev_state from (prev_j>0) <= 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);

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":238
 *                                 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]);

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":239
 * 
 *                                 exponent = source_row_ex_data[index]
 *                                 if exponent == MIN_SCALE:             # <<<<<<<<<<<<<<
 *                                     continue
 * 
 */
                __pyx_t_5 = (__pyx_v_exponent == __pyx_v_6cogent_5align_14_pairwise_pogs_MIN_SCALE);
                if (__pyx_t_5) {

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":240
 *                                 exponent = source_row_ex_data[index]
 *                                 if exponent == MIN_SCALE:
 *                                     continue             # <<<<<<<<<<<<<<
 * 
 *                                 mantissa = (source_row_data[index]
 */
                  goto __pyx_L35_continue;
                  goto __pyx_L37;
                }
                __pyx_L37:;

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":243
 * 
 *                                 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)]));

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":245
 *                                      * T_data[prev_state*N+state])
 * 
 *                                 if mantissa < MIN_FLOAT_VALUE:             # <<<<<<<<<<<<<<
 *                                     if mantissa == 0.0:
 *                                         continue
 */
                __pyx_t_5 = (__pyx_v_mantissa < __pyx_v_6cogent_5align_14_pairwise_pogs_MIN_FLOAT_VALUE);
                if (__pyx_t_5) {

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":246
 * 
 *                                 if mantissa < MIN_FLOAT_VALUE:
 *                                     if mantissa == 0.0:             # <<<<<<<<<<<<<<
 *                                         continue
 *                                     if mantissa < 0.0:
 */
                  __pyx_t_5 = (__pyx_v_mantissa == 0.0);
                  if (__pyx_t_5) {

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":247
 *                                 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_L35_continue;
                    goto __pyx_L39;
                  }
                  __pyx_L39:;

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":248
 *                                     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_5 = (__pyx_v_mantissa < 0.0);
                  if (__pyx_t_5) {

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":249
 *                                         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_5 = ((__pyx_v_T_data[((__pyx_v_prev_state * __pyx_v_N) + __pyx_v_state)]) < 0.0);
                    if (__pyx_t_5) {

                      /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":250
 *                                     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_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__fmpt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                      __Pyx_GOTREF(__pyx_t_2);
                      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_mantissa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                      __Pyx_GOTREF(__pyx_t_1);
                      __pyx_t_3 = PyInt_FromLong(__pyx_v_exponent); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                      __Pyx_GOTREF(__pyx_t_3);
                      __pyx_t_14 = PyTuple_New(3); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                      __Pyx_GOTREF(__pyx_t_14);
                      PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1);
                      __Pyx_GIVEREF(__pyx_t_1);
                      PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_3);
                      __Pyx_GIVEREF(__pyx_t_3);
                      __Pyx_INCREF(((PyObject *)__pyx_kp_s_10));
                      PyTuple_SET_ITEM(__pyx_t_14, 2, ((PyObject *)__pyx_kp_s_10));
                      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_10));
                      __pyx_t_1 = 0;
                      __pyx_t_3 = 0;
                      __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                      __Pyx_GOTREF(__pyx_t_3);
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                      __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                      __Pyx_GOTREF(__pyx_t_14);
                      PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_3);
                      __Pyx_GIVEREF(__pyx_t_3);
                      __pyx_t_3 = 0;
                      __pyx_t_3 = PyObject_Call(__pyx_builtin_ArithmeticError, __pyx_t_14, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                      __Pyx_GOTREF(__pyx_t_3);
                      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                      __Pyx_Raise(__pyx_t_3, 0, 0);
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                      goto __pyx_L41;
                    }
                    __pyx_L41:;

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":252
 *                                             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_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__fmpt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_14 = PyFloat_FromDouble(__pyx_v_mantissa); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_14);
                    __pyx_t_2 = PyInt_FromLong(__pyx_v_exponent); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_1);
                    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_14);
                    __Pyx_GIVEREF(__pyx_t_14);
                    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
                    __Pyx_GIVEREF(__pyx_t_2);
                    __Pyx_INCREF(((PyObject *)__pyx_kp_s_11));
                    PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_kp_s_11));
                    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11));
                    __pyx_t_14 = 0;
                    __pyx_t_2 = 0;
                    __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_1);
                    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
                    __Pyx_GIVEREF(__pyx_t_2);
                    __pyx_t_2 = 0;
                    __pyx_t_2 = PyObject_Call(__pyx_builtin_ArithmeticError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_Raise(__pyx_t_2, 0, 0);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    goto __pyx_L40;
                  }
                  __pyx_L40:;

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":254
 *                                         raise ArithmeticError(fmpt(mantissa, exponent,
 *                                                 "product is a negative probability"))
 *                                     while mantissa < MIN_FLOAT_VALUE:             # <<<<<<<<<<<<<<
 *                                         mantissa *= SCALE_STEP
 *                                         exponent += -1
 */
                  while (1) {
                    __pyx_t_5 = (__pyx_v_mantissa < __pyx_v_6cogent_5align_14_pairwise_pogs_MIN_FLOAT_VALUE);
                    if (!__pyx_t_5) break;

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":255
 *                                                 "product is a negative probability"))
 *                                     while mantissa < MIN_FLOAT_VALUE:
 *                                         mantissa *= SCALE_STEP             # <<<<<<<<<<<<<<
 *                                         exponent += -1
 *                                         if exponent <= MIN_SCALE:
 */
                    __pyx_v_mantissa *= __pyx_v_6cogent_5align_14_pairwise_pogs_SCALE_STEP;

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":256
 *                                     while mantissa < MIN_FLOAT_VALUE:
 *                                         mantissa *= SCALE_STEP
 *                                         exponent += -1             # <<<<<<<<<<<<<<
 *                                         if exponent <= MIN_SCALE:
 *                                           raise ArithmeticError(fmpt(mantissa, exponent,
 */
                    __pyx_v_exponent += -1;

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":257
 *                                         mantissa *= SCALE_STEP
 *                                         exponent += -1
 *                                         if exponent <= MIN_SCALE:             # <<<<<<<<<<<<<<
 *                                           raise ArithmeticError(fmpt(mantissa, exponent,
 *                                                 "underflows"))
 */
                    __pyx_t_5 = (__pyx_v_exponent <= __pyx_v_6cogent_5align_14_pairwise_pogs_MIN_SCALE);
                    if (__pyx_t_5) {

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

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":261
 *                                                 "underflows"))
 * 
 *                                 elif mantissa > 1.0:             # <<<<<<<<<<<<<<
 *                                     mantissa *= MIN_FLOAT_VALUE
 *                                     exponent += 1
 */
                __pyx_t_5 = (__pyx_v_mantissa > 1.0);
                if (__pyx_t_5) {

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":262
 * 
 *                                 elif mantissa > 1.0:
 *                                     mantissa *= MIN_FLOAT_VALUE             # <<<<<<<<<<<<<<
 *                                     exponent += 1
 *                                     if exponent > MAX_SCALE:
 */
                  __pyx_v_mantissa *= __pyx_v_6cogent_5align_14_pairwise_pogs_MIN_FLOAT_VALUE;

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":263
 *                                 elif mantissa > 1.0:
 *                                     mantissa *= MIN_FLOAT_VALUE
 *                                     exponent += 1             # <<<<<<<<<<<<<<
 *                                     if exponent > MAX_SCALE:
 *                                         raise ArithmeticError(fmpt(mantissa, exponent,
 */
                  __pyx_v_exponent += 1;

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":264
 *                                     mantissa *= MIN_FLOAT_VALUE
 *                                     exponent += 1
 *                                     if exponent > MAX_SCALE:             # <<<<<<<<<<<<<<
 *                                         raise ArithmeticError(fmpt(mantissa, exponent,
 *                                             "is unexpectedly large"))
 */
                  __pyx_t_5 = (__pyx_v_exponent > __pyx_v_6cogent_5align_14_pairwise_pogs_MAX_SCALE);
                  if (__pyx_t_5) {

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":265
 *                                     exponent += 1
 *                                     if exponent > MAX_SCALE:
 *                                         raise ArithmeticError(fmpt(mantissa, exponent,             # <<<<<<<<<<<<<<
 *                                             "is unexpectedly large"))
 * 
 */
                    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__fmpt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_14 = PyFloat_FromDouble(__pyx_v_mantissa); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_14);
                    __pyx_t_2 = PyInt_FromLong(__pyx_v_exponent); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_1);
                    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_14);
                    __Pyx_GIVEREF(__pyx_t_14);
                    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
                    __Pyx_GIVEREF(__pyx_t_2);
                    __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
                    PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_kp_s_12));
                    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
                    __pyx_t_14 = 0;
                    __pyx_t_2 = 0;
                    __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_1);
                    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
                    __Pyx_GIVEREF(__pyx_t_2);
                    __pyx_t_2 = 0;
                    __pyx_t_2 = PyObject_Call(__pyx_builtin_ArithmeticError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_Raise(__pyx_t_2, 0, 0);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                    goto __pyx_L45;
                  }
                  __pyx_L45:;
                  goto __pyx_L38;
                }
                __pyx_L38:;

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":268
 *                                             "is unexpectedly large"))
 * 
 *                                 if exponent > max_exponent:             # <<<<<<<<<<<<<<
 *                                     if exponent == max_exponent + 1:
 *                                         sub_partial_sum = partial_sum
 */
                __pyx_t_5 = (__pyx_v_exponent > __pyx_v_max_exponent);
                if (__pyx_t_5) {

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":269
 * 
 *                                 if exponent > max_exponent:
 *                                     if exponent == max_exponent + 1:             # <<<<<<<<<<<<<<
 *                                         sub_partial_sum = partial_sum
 *                                     else:
 */
                  __pyx_t_5 = (__pyx_v_exponent == (__pyx_v_max_exponent + 1));
                  if (__pyx_t_5) {

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":270
 *                                 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_L47;
                  }
                  /*else*/ {

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":272
 *                                         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_L47:;

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":273
 *                                     else:
 *                                         sub_partial_sum = 0.0
 *                                     partial_sum = 0.0             # <<<<<<<<<<<<<<
 *                                     max_mantissa = 0.0
 *                                     max_exponent = exponent
 */
                  __pyx_v_partial_sum = 0.0;

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":274
 *                                         sub_partial_sum = 0.0
 *                                     partial_sum = 0.0
 *                                     max_mantissa = 0.0             # <<<<<<<<<<<<<<
 *                                     max_exponent = exponent
 * 
 */
                  __pyx_v_max_mantissa = 0.0;

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":275
 *                                     partial_sum = 0.0
 *                                     max_mantissa = 0.0
 *                                     max_exponent = exponent             # <<<<<<<<<<<<<<
 * 
 *                                 if exponent == max_exponent:
 */
                  __pyx_v_max_exponent = __pyx_v_exponent;
                  goto __pyx_L46;
                }
                __pyx_L46:;

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":277
 *                                     max_exponent = exponent
 * 
 *                                 if exponent == max_exponent:             # <<<<<<<<<<<<<<
 *                                     partial_sum += mantissa
 *                                     if viterbi and mantissa > max_mantissa:
 */
                __pyx_t_5 = (__pyx_v_exponent == __pyx_v_max_exponent);
                if (__pyx_t_5) {

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":278
 * 
 *                                 if exponent == max_exponent:
 *                                     partial_sum += mantissa             # <<<<<<<<<<<<<<
 *                                     if viterbi and mantissa > max_mantissa:
 *                                         max_mantissa = mantissa
 */
                  __pyx_v_partial_sum += __pyx_v_mantissa;

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":279
 *                                 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_5 = (__pyx_v_mantissa > __pyx_v_max_mantissa);
                    __pyx_t_13 = __pyx_t_5;
                  } else {
                    __pyx_t_13 = __pyx_v_viterbi;
                  }
                  if (__pyx_t_13) {

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":280
 *                                     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;

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":281
 *                                     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;

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":282
 *                                         max_mantissa = mantissa
 *                                         pointer_state = prev_state
 *                                         pointer_a = a             # <<<<<<<<<<<<<<
 *                                         pointer_b = b
 * 
 */
                    __pyx_v_pointer_a = __pyx_v_a;

                    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":283
 *                                         pointer_state = prev_state
 *                                         pointer_a = a
 *                                         pointer_b = b             # <<<<<<<<<<<<<<
 * 
 *                                 elif exponent == max_exponent - 1:
 */
                    __pyx_v_pointer_b = __pyx_v_b;
                    goto __pyx_L49;
                  }
                  __pyx_L49:;
                  goto __pyx_L48;
                }

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":285
 *                                         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) {

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":286
 * 
 *                                 elif exponent == max_exponent - 1:
 *                                     sub_partial_sum += mantissa             # <<<<<<<<<<<<<<
 * 
 *                             partial_sum += sub_partial_sum * MIN_FLOAT_VALUE
 */
                  __pyx_v_sub_partial_sum += __pyx_v_mantissa;
                  goto __pyx_L48;
                }
                __pyx_L48:;
                __pyx_L35_continue:;
              }

              /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":288
 *                                     sub_partial_sum += mantissa
 * 
 *                             partial_sum += sub_partial_sum * MIN_FLOAT_VALUE             # <<<<<<<<<<<<<<
 *                 else:
 *                     # keep these next 7 lines same as above/below,
 */
              __pyx_v_partial_sum += (__pyx_v_sub_partial_sum * __pyx_v_6cogent_5align_14_pairwise_pogs_MIN_FLOAT_VALUE);
            }
          }
          goto __pyx_L29;
        }
        /*else*/ {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":292
 *                     # keep these next 7 lines same as above/below,
 *                     # less source_row_ex_data
 *                     for a from a_low <= a < a_high:             # <<<<<<<<<<<<<<
 *                         source_row_data = source_row_data_cache[a]
 *                         for b from b_low <= b < b_high:
 */
          __pyx_t_18 = __pyx_v_a_high;
          for (__pyx_v_a = __pyx_v_a_low; __pyx_v_a < __pyx_t_18; __pyx_v_a++) {

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":293
 *                     # less source_row_ex_data
 *                     for a from a_low <= a < a_high:
 *                         source_row_data = source_row_data_cache[a]             # <<<<<<<<<<<<<<
 *                         for b from b_low <= b < b_high:
 *                             if dy:
 */
            __pyx_v_source_row_data = (__pyx_v_source_row_data_cache[__pyx_v_a]);

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":294
 *                     for a from a_low <= a < a_high:
 *                         source_row_data = source_row_data_cache[a]
 *                         for b from b_low <= b < b_high:             # <<<<<<<<<<<<<<
 *                             if dy:
 *                                 prev_j = j_sources_data[b-1+j_sources_start]
 */
            __pyx_t_19 = __pyx_v_b_high;
            for (__pyx_v_b = __pyx_v_b_low; __pyx_v_b < __pyx_t_19; __pyx_v_b++) {

              /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":295
 *                         source_row_data = source_row_data_cache[a]
 *                         for b from b_low <= b < b_high:
 *                             if dy:             # <<<<<<<<<<<<<<
 *                                 prev_j = j_sources_data[b-1+j_sources_start]
 *                             else:
 */
              __pyx_t_20 = __pyx_v_dy;
              if (__pyx_t_20) {

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":296
 *                         for b from b_low <= b < b_high:
 *                             if dy:
 *                                 prev_j = j_sources_data[b-1+j_sources_start]             # <<<<<<<<<<<<<<
 *                             else:
 *                                 prev_j = j
 */
                __pyx_v_prev_j = (__pyx_v_j_sources_data[((__pyx_v_b - 1) + __pyx_v_j_sources_start)]);
                goto __pyx_L54;
              }
              /*else*/ {

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":298
 *                                 prev_j = j_sources_data[b-1+j_sources_start]
 *                             else:
 *                                 prev_j = j             # <<<<<<<<<<<<<<
 *                             for prev_state from (prev_j>0) <= prev_state < N:
 *                                 index = prev_j*N + prev_state
 */
                __pyx_v_prev_j = __pyx_v_j;
              }
              __pyx_L54:;

              /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":299
 *                             else:
 *                                 prev_j = j
 *                             for prev_state from (prev_j>0) <= prev_state < N:             # <<<<<<<<<<<<<<
 *                                 index = prev_j*N + prev_state
 *                                 if use_logs:
 */
              __pyx_t_20 = __pyx_v_N;
              for (__pyx_v_prev_state = (__pyx_v_prev_j > 0); __pyx_v_prev_state < __pyx_t_20; __pyx_v_prev_state++) {

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":300
 *                                 prev_j = j
 *                             for prev_state from (prev_j>0) <= 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);

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":301
 *                             for prev_state from (prev_j>0) <= prev_state < N:
 *                                 index = prev_j*N + prev_state
 *                                 if use_logs:             # <<<<<<<<<<<<<<
 *                                     mantissa = (source_row_data[index]
 *                                          + T_data[prev_state*N+state])
 */
                __pyx_t_21 = __pyx_v_use_logs;
                if (__pyx_t_21) {

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":303
 *                                 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_L57;
                }
                /*else*/ {

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":306
 *                                 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)]));

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":307
 *                                     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_mantissa;
                }
                __pyx_L57:;

                /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":308
 *                                          * 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_5 = __pyx_t_13;
                } else {
                  __pyx_t_5 = __pyx_v_viterbi;
                }
                if (__pyx_t_5) {

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":309
 *                                     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;

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":310
 *                                 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;

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":311
 *                                     max_mantissa = mantissa
 *                                     pointer_state = prev_state
 *                                     pointer_a = a             # <<<<<<<<<<<<<<
 *                                     pointer_b = b
 * 
 */
                  __pyx_v_pointer_a = __pyx_v_a;

                  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":312
 *                                     pointer_state = prev_state
 *                                     pointer_a = a
 *                                     pointer_b = b             # <<<<<<<<<<<<<<
 * 
 *                 if viterbi:
 */
                  __pyx_v_pointer_b = __pyx_v_b;
                  goto __pyx_L58;
                }
                __pyx_L58:;
              }
            }
          }
        }
        __pyx_L29:;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":314
 *                                     pointer_b = b
 * 
 *                 if viterbi:             # <<<<<<<<<<<<<<
 *                     mantissa = max_mantissa
 *                     if track_data:
 */
        __pyx_t_18 = __pyx_v_viterbi;
        if (__pyx_t_18) {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":315
 * 
 *                 if viterbi:
 *                     mantissa = max_mantissa             # <<<<<<<<<<<<<<
 *                     if track_data:
 *                         track_data[(i*row_length+j)*N+state] = (
 */
          __pyx_v_mantissa = __pyx_v_max_mantissa;

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":316
 *                 if viterbi:
 *                     mantissa = max_mantissa
 *                     if track_data:             # <<<<<<<<<<<<<<
 *                         track_data[(i*row_length+j)*N+state] = (
 *                             (pointer_a << tcode_x) |
 */
          __pyx_t_5 = (__pyx_v_track_data != 0);
          if (__pyx_t_5) {

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":317
 *                     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_L60;
          }
          __pyx_L60:;
          goto __pyx_L59;
        }
        /*else*/ {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":322
 *                             (pointer_state << tcode_s))
 *                 else:
 *                     mantissa = partial_sum             # <<<<<<<<<<<<<<
 * 
 *                 if dy:
 */
          __pyx_v_mantissa = __pyx_v_partial_sum;
        }
        __pyx_L59:;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":324
 *                     mantissa = partial_sum
 * 
 *                 if dy:             # <<<<<<<<<<<<<<
 *                     y = y_index[j]
 *                     if dx:
 */
        __pyx_t_18 = __pyx_v_dy;
        if (__pyx_t_18) {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":325
 * 
 *                 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]);

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":326
 *                 if dy:
 *                     y = y_index[j]
 *                     if dx:             # <<<<<<<<<<<<<<
 *                         d_score = match_score_data[((bin*max_x+x)*max_y)+y]
 *                     else:
 */
          __pyx_t_18 = __pyx_v_dx;
          if (__pyx_t_18) {

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":327
 *                     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_L62;
          }
          /*else*/ {

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":329
 *                         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_L62:;
          goto __pyx_L61;
        }

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":330
 *                     else:
 *                         d_score = ygap_score_data[bin*max_y+y]
 *                 elif dx:             # <<<<<<<<<<<<<<
 *                     d_score = xgap_score_data[bin*max_x+x]
 *                 elif use_logs:
 */
        __pyx_t_18 = __pyx_v_dx;
        if (__pyx_t_18) {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":331
 *                         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_L61;
        }

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":332
 *                 elif dx:
 *                     d_score = xgap_score_data[bin*max_x+x]
 *                 elif use_logs:             # <<<<<<<<<<<<<<
 *                     d_score = 0.0
 *                 else:
 */
        __pyx_t_18 = __pyx_v_use_logs;
        if (__pyx_t_18) {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":333
 *                     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_L61;
        }
        /*else*/ {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":335
 *                     d_score = 0.0
 *                 else:
 *                     d_score = 1.0             # <<<<<<<<<<<<<<
 * 
 *                 if use_logs:
 */
          __pyx_v_d_score = 1.0;
        }
        __pyx_L61:;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":337
 *                     d_score = 1.0
 * 
 *                 if use_logs:             # <<<<<<<<<<<<<<
 *                     mantissa += d_score
 *                 else:
 */
        __pyx_t_18 = __pyx_v_use_logs;
        if (__pyx_t_18) {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":338
 * 
 *                 if use_logs:
 *                     mantissa += d_score             # <<<<<<<<<<<<<<
 *                 else:
 *                     mantissa *= d_score
 */
          __pyx_v_mantissa += __pyx_v_d_score;
          goto __pyx_L63;
        }
        /*else*/ {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":340
 *                     mantissa += d_score
 *                 else:
 *                     mantissa *= d_score             # <<<<<<<<<<<<<<
 * 
 *                 current_row_data[j*N+state] = mantissa
 */
          __pyx_v_mantissa *= __pyx_v_d_score;
        }
        __pyx_L63:;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":342
 *                     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;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":343
 * 
 *                 current_row_data[j*N+state] = mantissa
 *                 if use_scaling:             # <<<<<<<<<<<<<<
 *                     current_row_ex_data[j*N+state] = max_exponent
 * 
 */
        __pyx_t_18 = __pyx_v_use_scaling;
        if (__pyx_t_18) {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":344
 *                 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_L64;
        }
        __pyx_L64:;

        /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":346
 *                     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_5 = __pyx_v_dy;
          } else {
            __pyx_t_5 = __pyx_v_dx;
          }
          __pyx_t_13 = __pyx_t_5;
        } else {
          __pyx_t_13 = __pyx_v_local;
        }
        if (__pyx_t_13) {

          /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":347
 * 
 *                 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_5 = __pyx_t_13;
          } else {
            __pyx_t_5 = __pyx_v_use_scaling;
          }
          if (!__pyx_t_5) {

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":348
 *                 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_4 = (__pyx_v_max_exponent == __pyx_v_overall_max_exponent);
              __pyx_t_12 = __pyx_t_4;
            } else {
              __pyx_t_12 = __pyx_t_13;
            }
            if (__pyx_t_12) {

              /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":349
 *                     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_4 = __pyx_t_13;
            } else {
              __pyx_t_4 = __pyx_t_12;
            }
            __pyx_t_12 = __pyx_t_4;
          } else {
            __pyx_t_12 = __pyx_t_5;
          }
          if (__pyx_t_12) {

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":350
 *                             (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;

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":351
 *                             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;

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":352
 *                         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;

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":353
 *                         overall_max_mantissa = mantissa
 *                         last_i = i
 *                         last_j = j             # <<<<<<<<<<<<<<
 *                         last_state = state
 *     if not local:
 */
            __pyx_v_last_j = __pyx_v_j;

            /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":354
 *                         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_L66;
          }
          __pyx_L66:;
          goto __pyx_L65;
        }
        __pyx_L65:;
      }
    }
  }

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":355
 *                         last_j = j
 *                         last_state = state
 *     if not local:             # <<<<<<<<<<<<<<
 *         last_i = i_high - 1
 *         last_j = j_high - 1
 */
  __pyx_t_12 = (!__pyx_v_local);
  if (__pyx_t_12) {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":356
 *                         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);

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":357
 *     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);

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":358
 *         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_L67;
  }
  /*else*/ {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":360
 *         last_state = state
 *     else:
 *         mantissa = overall_max_mantissa             # <<<<<<<<<<<<<<
 *         max_exponent = overall_max_exponent
 * 
 */
    __pyx_v_mantissa = __pyx_v_overall_max_mantissa;

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":361
 *     else:
 *         mantissa = overall_max_mantissa
 *         max_exponent = overall_max_exponent             # <<<<<<<<<<<<<<
 * 
 *     if use_scaling:
 */
    __pyx_v_max_exponent = __pyx_v_overall_max_exponent;
  }
  __pyx_L67:;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":363
 *         max_exponent = overall_max_exponent
 * 
 *     if use_scaling:             # <<<<<<<<<<<<<<
 *         score = log(mantissa) + log(SCALE_STEP) * max_exponent
 *     elif use_logs:
 */
  __pyx_t_10 = __pyx_v_use_scaling;
  if (__pyx_t_10) {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":364
 * 
 *     if use_scaling:
 *         score = log(mantissa) + log(SCALE_STEP) * max_exponent             # <<<<<<<<<<<<<<
 *     elif use_logs:
 *         score = mantissa
 */
    __pyx_t_2 = PyFloat_FromDouble((log(__pyx_v_mantissa) + (log(__pyx_v_6cogent_5align_14_pairwise_pogs_SCALE_STEP) * __pyx_v_max_exponent))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_score);
    __pyx_v_score = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L68;
  }

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":365
 *     if use_scaling:
 *         score = log(mantissa) + log(SCALE_STEP) * max_exponent
 *     elif use_logs:             # <<<<<<<<<<<<<<
 *         score = mantissa
 *     else:
 */
  __pyx_t_10 = __pyx_v_use_logs;
  if (__pyx_t_10) {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":366
 *         score = log(mantissa) + log(SCALE_STEP) * max_exponent
 *     elif use_logs:
 *         score = mantissa             # <<<<<<<<<<<<<<
 *     else:
 *         score = log(mantissa)
 */
    __pyx_t_2 = PyFloat_FromDouble(__pyx_v_mantissa); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_score);
    __pyx_v_score = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L68;
  }
  /*else*/ {

    /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":368
 *         score = mantissa
 *     else:
 *         score = log(mantissa)             # <<<<<<<<<<<<<<
 *     return ((last_i, last_j), last_state, score)
 */
    __pyx_t_2 = PyFloat_FromDouble(log(__pyx_v_mantissa)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_score);
    __pyx_v_score = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L68:;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":369
 *     else:
 *         score = log(mantissa)
 *     return ((last_i, last_j), last_state, score)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_last_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_last_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 369; __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);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_2 = 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 = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 369; __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_INCREF(__pyx_v_score);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_score);
  __Pyx_GIVEREF(__pyx_v_score);
  __pyx_t_3 = 0;
  __pyx_t_1 = 0;
  __pyx_r = __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_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cogent.align._pairwise_pogs.calc_rows");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_i_sources);
  __Pyx_DECREF(__pyx_v_j_sources);
  __Pyx_DECREF(__pyx_v_mantissas);
  __Pyx_DECREF(__pyx_v_exponents);
  __Pyx_DECREF(__pyx_v_pog1);
  __Pyx_DECREF(__pyx_v_pog2);
  __Pyx_DECREF(__pyx_v_j_sources_offsets);
  __Pyx_DECREF(__pyx_v_i_sources_offsets);
  __Pyx_DECREF(__pyx_v_score);
  __Pyx_DECREF(__pyx_v_plan);
  __Pyx_DECREF(__pyx_v_seq1_index);
  __Pyx_DECREF(__pyx_v_seq2_index);
  __Pyx_DECREF(__pyx_v_preds);
  __Pyx_DECREF(__pyx_v_state_directions);
  __Pyx_DECREF(__pyx_v_T);
  __Pyx_DECREF(__pyx_v_xgap_scores);
  __Pyx_DECREF(__pyx_v_ygap_scores);
  __Pyx_DECREF(__pyx_v_match_scores);
  __Pyx_DECREF(__pyx_v_rows);
  __Pyx_DECREF(__pyx_v_track);
  __Pyx_DECREF(__pyx_v_track_enc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static struct PyMethodDef __pyx_methods[] = {
  {__Pyx_NAMESTR("fmpt"), (PyCFunction)__pyx_pf_6cogent_5align_14_pairwise_pogs_fmpt, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("calc_rows"), (PyCFunction)__pyx_pf_6cogent_5align_14_pairwise_pogs_calc_rows, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6cogent_5align_14_pairwise_pogs_calc_rows)},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("_pairwise_pogs"),
    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_u_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 1, 0, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__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_8, __pyx_k_8, sizeof(__pyx_k_8), 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__T, __pyx_k__T, sizeof(__pyx_k__T), 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__asCombinedArray, __pyx_k__asCombinedArray, sizeof(__pyx_k__asCombinedArray), 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__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
  {&__pyx_n_s__exponent, __pyx_k__exponent, sizeof(__pyx_k__exponent), 0, 0, 1, 1},
  {&__pyx_n_s__flags, __pyx_k__flags, sizeof(__pyx_k__flags), 0, 0, 1, 1},
  {&__pyx_n_s__fmpt, __pyx_k__fmpt, sizeof(__pyx_k__fmpt), 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__itemsize, __pyx_k__itemsize, sizeof(__pyx_k__itemsize), 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__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__match_scores, __pyx_k__match_scores, sizeof(__pyx_k__match_scores), 0, 0, 1, 1},
  {&__pyx_n_s__msg, __pyx_k__msg, sizeof(__pyx_k__msg), 0, 0, 1, 1},
  {&__pyx_n_s__nd, __pyx_k__nd, sizeof(__pyx_k__nd), 0, 0, 1, 1},
  {&__pyx_n_s__plan, __pyx_k__plan, sizeof(__pyx_k__plan), 0, 0, 1, 1},
  {&__pyx_n_s__preds, __pyx_k__preds, sizeof(__pyx_k__preds), 0, 0, 1, 1},
  {&__pyx_n_s__rows, __pyx_k__rows, sizeof(__pyx_k__rows), 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__shape, __pyx_k__shape, sizeof(__pyx_k__shape), 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__track, __pyx_k__track, sizeof(__pyx_k__track), 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__typekind, __pyx_k__typekind, sizeof(__pyx_k__typekind), 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, __pyx_k__version, sizeof(__pyx_k__version), 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__xgap_scores, __pyx_k__xgap_scores, sizeof(__pyx_k__xgap_scores), 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 = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  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_pogs(void); /*proto*/
PyMODINIT_FUNC init_pairwise_pogs(void)
#else
PyMODINIT_FUNC PyInit__pairwise_pogs(void); /*proto*/
PyMODINIT_FUNC PyInit__pairwise_pogs(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  #if CYTHON_REFNANNY
  void* __pyx_refnanny = NULL;
  __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");
  }
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit__pairwise_pogs(void)", __LINE__, __FILE__);
  #endif
  __pyx_init_filenames();
  __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;}
  #if PY_MAJOR_VERSION < 3
  __pyx_empty_bytes = PyString_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #else
  __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;}
  #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_pogs"), __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_pogs) {
    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;}
  /*--- Global init code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  /*--- Type import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "/Users/gavin/DevRepos/PyCogent-trunk/include/numerical_pyrex.pyx":13
 * #
 * 
 * __version__ = "('1', '6', '0', 'dev')"             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "Python.h":
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____version__, ((PyObject *)__pyx_kp_s_13)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":11
 *     double log (double x)
 * 
 * version_info = (3, 1)             # <<<<<<<<<<<<<<
 * __version__ = "('1', '6', '0', 'dev')"
 * 
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __Pyx_INCREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__version_info, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":12
 * 
 * version_info = (3, 1)
 * __version__ = "('1', '6', '0', 'dev')"             # <<<<<<<<<<<<<<
 * 
 * cdef double SCALE_STEP, MIN_FLOAT_VALUE
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____version__, ((PyObject *)__pyx_kp_s_13)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":15
 * 
 * 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_pogs_SCALE_STEP = pow(2.0, 50);

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":16
 * 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_pogs_SCALE_STEP == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_6cogent_5align_14_pairwise_pogs_MIN_FLOAT_VALUE = (1.0 / __pyx_v_6cogent_5align_14_pairwise_pogs_SCALE_STEP);

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":19
 * 
 * cdef int MAX_XCOUNT
 * MAX_XCOUNT = 256             # <<<<<<<<<<<<<<
 * 
 * cdef long MIN_SCALE, MAX_SCALE
 */
  __pyx_v_6cogent_5align_14_pairwise_pogs_MAX_XCOUNT = 256;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":22
 * 
 * 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_pogs_MIN_SCALE = -10000;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":23
 * 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_pogs_MAX_SCALE = 10000;

  /* "/Users/gavin/DevRepos/PyCogent-trunk/cogent/align/_pairwise_pogs.pyx":1
 * include "numerical_pyrex.pyx"             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "Python.h":
 */
  __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));
  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__calc_rows); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__");
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_14), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  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);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  if (__pyx_m) {
    __Pyx_AddTraceback("init cogent.align._pairwise_pogs");
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init cogent.align._pairwise_pogs");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

static const char *__pyx_filenames[] = {
  "numerical_pyrex.pyx",
  "_pairwise_pogs.pyx",
};

/* Runtime support code */

static void __pyx_init_filenames(void) {
  __pyx_f = __pyx_filenames;
}

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 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 *number, *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";
    }
    number = (num_expected == 1) ? "" : "s";
    PyErr_Format(PyExc_TypeError,
        #if PY_VERSION_HEX < 0x02050000
            "%s() takes %s %d positional argument%s (%d given)",
        #else
            "%s() takes %s %zd positional argument%s (%zd given)",
        #endif
        func_name, more_or_less, num_expected, number, num_found);
}

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_CheckExact(key)) && 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 {
                    /* unexpected keyword found */
                    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,
        #if PY_VERSION_HEX < 0x02050000
                 "need more than %d value%s to unpack", (int)index,
        #else
                 "need more than %zd value%s to unpack", index,
        #endif
                 (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void) {
    PyErr_SetString(PyExc_ValueError, "too many values to unpack");
}

static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
    PyObject *item;
    if (!(item = PyIter_Next(iter))) {
        if (!PyErr_Occurred()) {
            __Pyx_RaiseNeedMoreValuesError(index);
        }
    }
    return item;
}

static int __Pyx_EndUnpack(PyObject *iter) {
    PyObject *item;
    if ((item = PyIter_Next(iter))) {
        Py_DECREF(item);
        __Pyx_RaiseTooManyValuesError();
        return -1;
    }
    else if (!PyErr_Occurred())
        return 0;
    else
        return -1;
}


static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
    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);
}

static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    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;
}


#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    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;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        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) {
    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;
    }

    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 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 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 PyLong_AsUnsignedLong(x);
        } else {
            return 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 PyLong_AsUnsignedLongLong(x);
        } else {
            return 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 PyLong_AsUnsignedLong(x);
        } else {
            return 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 PyLong_AsUnsignedLongLong(x);
        } else {
            return 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 PyLong_AsUnsignedLong(x);
        } else {
            return 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 PyLong_AsUnsignedLongLong(x);
        } else {
            return 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) {
    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);
    }
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #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_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        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,*/
        __pyx_lineno,   /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    if (!py_code) 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 = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    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) {
   if (x == Py_True) return 1;
   else if ((x == Py_False) | (x == Py_None)) return 0;
   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 */
